Skip to content

How to move the context into another function #688

Answered by elliotgunton
psmit asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @psmit - the context manager is implicitly alive during any function calls under a context. However, in your example you would need to be in a Workflow context to be able to define a DAG otherwise the Tasks will try to add the templates they use to a Workflow context that doesn't exist. It's also not currently possible for a list of Tasks to be the first item in a chain of dependencies - you would have to use a workaround to assign next for each task in the list. For a Workflow example using a function to create Tasks and this workaround, see below, hope this helps!

def create_tasks(names: List[str], container: Container) -> List[Task]:
    return [Task(name=f"container-in-function-{n}"

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by elliotgunton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants