Skip to content

Question: example with dynamically defined states? #518

Description

@vsoch

Hi! I stumbled on your library today, and it's exactly what I'm looking for to drive a series of jobs in a workflow that will be run in Kubernetes. For most of the examples, it looks like the State and relationships need to be defined in advance (and added as class attributes) and I'm wondering if you could point me to an example where this is done dynamically? E.g., ideally I could either define the class in a function (and return it) or somehow add the objects dynamically to the base StateMachine. I started looking at that class and seeing if I could figure out how to do it, but this seems like it would be a common want so I wanted to ask here first. Thanks!

Activity

  1. fgmacedo commented on Jan 21, 2025

    @fgmacedo
    Owner

    Hi @vsoch, how are you?

    I've put an example here: #414 (reply in thread)

    Currently, this method is not bundled with the library, but I'm working on this in the #501 PR. The version in the PR is newest and more mature, including a formal schema using typed dicts. I've used to test all the examples in the .scxml format.

    Please let me know if it works for you.

    Best!

  2. vsoch commented on Jan 21, 2025

    @vsoch
    Author

    Ah, that is perfect! ❤

    I'll use that strategy for now, and I subscribed to the PR thread so I'll be notified when it's merged.

    Thank you for your quick help, and this library! Closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions