Hey team! I have a doubt about a way of creating w...
# ask-the-community
f
Hey team! I have a doubt about a way of creating wf’s programatically. I’m doing something like:
Copy code
def create_wf(name: str):
    @workflow
    def _create_wf():
        task_a() >> task_b()
    
    _create_wf.__name__ = name
    return _create_wf

wf_a = create_wf("a")
wf_b = create_wf("b")
But it’s not being recognized when I register workflows in my package
I took a look at the tests, and apparently this would be the way to go:
Copy code
def create_wf(name: str):
    wf = ImperativeWorkflow(name=name)
    wf.add_task(task_a)
    wf.add_task(task_b)
    return wf
But never used
ImperativeWorkflow
before. Would appreciate a confirmation on whether this makes sense whenever you have time
k
why do you need to define workflow in another function?
f
I’ll have many workflows that will look the same, and: • users should recreate the same workflow but with different arguments • i want to control the shape of the workflow that is instantiated
s
Imperative workflow is the ideal technique to create Flyte workflows programmatically.
f
Thanks!
Never used this nor read about this in the docs. Yet the code was documented perfectly and the tests were clear. Kudos for that 👏
f
Ah, better, there even is one. Thanks, once again 🙂