botify-labs / simpleflow

Python library for dataflow programming.
https://botify-labs.github.com/simpleflow/
MIT License
68 stars 24 forks source link

LOCAL: Unable to submit child Workflows to parent Workflow #151

Open jfwood opened 7 years ago

jfwood commented 7 years ago

I would like to create a child/sub-Workflow that I can 'submit()' to a parent Workflow, but currently this is not supported.

So a Workflow 'activity' can be submitted via this line: https://github.com/botify-labs/simpleflow/blob/master/simpleflow/workflow.py#L54

However, the local executor here doesn't support passing in Workflow instances: https://github.com/botify-labs/simpleflow/blob/master/simpleflow/local/executor.py#L25

This code probably needs to look more like this line: https://github.com/botify-labs/simpleflow/blob/master/simpleflow/swf/executor.py#L492

Is it possible this is intentional, in that local Workflow nesting is not possible?

Thanks, John

ybastide commented 7 years ago

Child workflow are not currently supported on master; however, could you try and provide feedback on https://github.com/botify-labs/simpleflow/pull/74?

It's not merged yet because

So another potential user is very exciting! :smile:

jfwood commented 7 years ago

Wow, this feature has been considered for a long time now! Myself and others on our team have been looking into simpleflow in earnest of lately. I'm really liking the 'repair' feature in addition to the overall approach to things. We are having to compose workflows into a master workflow however, and not being able to use the Workflow construct for child flows removes some of the power of the simpleflow approach (esp. the ability to use Pythonic variables from/to tasks within the Workflow). Having to use Canvas constructs for child workflows is not as powerful, and forces more coupling between tasks then I'd prefer.

I'm new to SWF in general though, so I think a lot of the complexity I see skimming the PR above is a bit lost on me now. Will try to dig into it for a review though.

I don't think a Workflow could simply extend an Activity from a composition perspective, though conceptually that makes sense. IF the issue is keeping SWF state synced to a Workflow class though, and then how to manage parent/child Workflow classes, perhaps the child Workflow needs to have a new field associated with it, such as parent Workflow class? And could the workflow ID of the parent be concatenated with the workflow name of the child/grand-children, etc.?