Is there any way to run a workflow within another ...
# ask-the-community
n
Is there any way to run a workflow within another workflow such that both can be viewed under the same
execution_id
in the Flyte Console and such that the pods for pod workflows inherit this execution id? or is it best practice to not have nested workflows like this in flyte?
Such as
Copy code
# Workflow 2 
@task
def my_task_2(input: str) -> str:
    return input

@dynamic
def my_workflow_2(input: str) -> str:
    return my_task_2(input=input)

@workflow
def run_workflow_2(input: str) -> str:
    return my_workflow_2(input=input)

# Workflow 1 -> Calls Workflow 2 
@task
def my_task(input: str) -> str:
    execution_options = FlyteExecutionOptions(
        wait=False,
        local=False,
        project="flytetester",
        domain="development",
    )
    results = execute(
        run_workflow_2,
        inputs={"input": input},
        execution_options=execution_options,
    )
    return input

@dynamic
def my_workflow(input: str) -> str:
    return my_task(input=input)

@workflow
def run_workflow(input: str) -> str:
    return my_workflow(input=input)
the alternative here would just be to call
my_task_2
directly from
my_task_1
, but some of our devs have implemented things like this and we just want to confirm that we cannot concatenate two workflows in flyte such that the second inherits properties of the first.
y
tasks cannot call other workflows, but dynamic tasks and workflows can call other workflows.
can you delete
my_workflow
here and move the dynamic decorator to
my_task
?
n
ok let me try that
213 Views