https://flyte.org logo
#ask-the-community
Title
# ask-the-community
c

Clint Zhang

10/31/2023, 7:01 PM
Hi team, can we use imperative workflow as a subworkflow? [confirm it is working] However, when I add an imperative workflow inside a helper function, I received the following error:
Copy code
File ".../site-packages/flytekit/core/workflow.py", line 545, in 
add_entity
raise Exception("Can't already be compiling")
Exception: Can't already be compiling
Sample code:
Copy code
@task
def upload_sources() -> FlyteDirectory:
    ...

def helper_func(
    params: str,
    name: str
) -> Workflow:
    test_workflow = Workflow(name=name)
    test_workflow.add_workflow_input("params", str)
    uploaded_sources_node = test_workflow.add_entity(upload_sources)
    ...

    return test_workflow(
        params=params
    )
We want to customize the workflow name for users using imperative workflow. If this doesn't work, do we have any other workaround? cc: @Kevin Su
y

Yee

11/01/2023, 10:00 AM
name is just an attribute.
should be pretty easy to override after the fact.
but when you do test_workflow(…) you’re invoking the workflow. is that what you want to do?
c

Clint Zhang

11/01/2023, 10:15 AM
Can we override a normal workflow’s name?
Yeah we want to return the workflow and have the users to call this helper function to customize the workflow’s name
Imperative workflow seems to be customizable
But the serialization will fail at uploaded_sources_node = test_workflow.add_entity(upload_sources)
Found the
with_overrides(name="...")
approach
y

Yee

11/02/2023, 2:18 AM
oh sorry, hopped off.
yes that is one yes.
2 Views