flyteorg / flyte

Scalable and flexible workflow orchestration platform that seamlessly unifies data, ML and analytics stacks.
https://flyte.org
Apache License 2.0
5.18k stars 550 forks source link

[BUG] Reference workflow doesn't implement the `workflow.python_interface` attribute #4577

Open GeeCastro opened 6 months ago

GeeCastro commented 6 months ago

Describe the bug

Trying to reference a workflow with the reference_workflow decorator throws an error when used with Launchplan.create. The create method tries to access workflow.python_interface but the attribute doesn't exist.

Expected behavior

Should create a launch plan without an error or error with a helpful message.

Additional context to reproduce

@reference_workflow(
    project="proj",
    domain="development",
    name="myprod.wf",
    version="0.2.19",
)
def wf(
    param: str,
) -> str:
    ...

wf_lp = LaunchPlan.create(
    name="my_wf_lp",
    workflow=wf,
    fixed_inputs={"param": "yes"},
)

Yields

<...>/lib/python3.10/site-packages/flytekit/core/launch_plan.py:126 in create                                         │
│                                                                                                                                                                          │
│ ❱ 126 │   │   wf_signature_parameters = transform_inputs_to_parameters(ctx, workflow.python_in                                                                           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'function' object has no attribute 'python_interface'

Screenshots

No response

Are you sure this issue hasn't been raised already?

Have you read the Code of Conduct?

dosubot[bot] commented 6 months ago

🤖

Hello @Chichilele! I'm Dosu, a friendly bot here to assist you with your bugs, queries, and contributions to the Flyte repository. I'm here to help you while we wait for a human maintainer to join us. Don't worry, we'll get your issue sorted out together. 😊

Thank you for reporting this issue. It seems like the reference_workflow decorator is not implementing the python_interface attribute, which is causing the AttributeError when the LaunchPlan.create method tries to access it.

The python_interface attribute is typically used to define the inputs and outputs of a workflow in Flyte. However, based on the information available, it appears that the reference_workflow decorator does not implement this attribute.

The LaunchPlan.create method, on the other hand, seems to be expecting this attribute to be present in the workflow object. This discrepancy is likely what's causing the error you're seeing.

Unfortunately, without more information about the implementation of the reference_workflow decorator and the python_interface attribute, it's difficult to provide a definitive solution. It might be helpful to check the implementation of these components in the Flyte codebase or the documentation for more details.

If you have any additional information about these components or if there's anything else you'd like to know, please feel free to share.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

mao3267 commented 3 days ago

Hi @GeeCastro , are you still facing this problem? I tested with a small example and it successfully registered a LaunchPlan on the console. I ran the code below with pyflyte register wf_ref.py.

from flytekit import LaunchPlan, reference_workflow

@reference_workflow(
    project="flytesnacks",
    domain="development",
    name="int_test.wf",
    version="version_of_your_referenced_workflow",
)
def wf(a: int) -> int: ...

lp = LaunchPlan.create(
    name="new_lp",
    workflow=wf,
    fixed_inputs={"a": 3},
)