Skip to content

Question: example with dynamically defined states? #518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vsoch opened this issue Jan 21, 2025 · 2 comments
Closed

Question: example with dynamically defined states? #518

vsoch opened this issue Jan 21, 2025 · 2 comments

Comments

@vsoch
Copy link

vsoch commented Jan 21, 2025

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!

@fgmacedo
Copy link
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!

@vsoch
Copy link
Author

vsoch commented Jan 21, 2025

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.

@vsoch vsoch closed this as completed Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants