Replies: 1 comment
-
Hi @dmerrick, with v5 we split out the coupling of tasks/templates, so the equivalent of from hera.workflows import DAG, Workflow, script
@script()
def echo(message: str):
print(message)
with Workflow(
generate_name="dag-diamond-",
entrypoint="diamond",
) as w:
with DAG(name="diamond"):
A = echo(name="A", arguments={"message": "A"})
B = echo(name="B", arguments={"message": "B"})
C = echo(name="C", arguments={"message": "C"})
D = echo(name="D", arguments={"message": "D"})
A >> [B, C] >> D
w.create() A more manual approach (but still using the context manager and implicitly adding your task) would be: from hera.workflows import DAG, Script, Workflow
with Workflow(
generate_name="one-script-task-",
entrypoint="one-script-task",
) as w:
my_script = Script(name="my-script", ...) # implicitly adds the "my-script" template to your workflow
with DAG(name="one-script-task"):
Task(name="A", template=my_script, arguments={...}) # implicitly adds the task "A" to the "one-script-task" dag
w.create() If you'd prefer an explicit, public API way to do |
Beta Was this translation helpful? Give feedback.
-
Related to #579, now that I have my Script created I'd like to attach it to a Workflow. We used to use
workflow.add_task()
, but that seems to have been removed in v5.Do we have to migrate to the contextmanager pattern, or is there a Hera v5 equivalent to
add_task()
?Beta Was this translation helpful? Give feedback.
All reactions