flyteorg / flyte

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

[BUG] LaunchPlan cannot be created within a function #6062

Open kumare3 opened 2 days ago

kumare3 commented 2 days ago

Describe the bug

Launchplans do not really need to be tracked as they do not exist during runtime. It should be possible to use launchplans without an LHS reference. But currently this fails, with an error like

def _task_module_from_callable(f: Callable):
        mod = inspect.getmodule(f)
        mod_name = getattr(mod, "__name__", f.__module__)
>       name = f.__name__.split(".")[-1]
E       AttributeError: 'LaunchPlan' object has no attribute '__name__'

Expected behavior

Ideally it should be possible to create Launchplan.create and use it inline programmatically

Additional context to reproduce

It should also be possible to use lps in jupyter

Screenshots

No response

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

Have you read the Code of Conduct?

kumare3 commented 2 days ago

There might be a few cases where __name__ attribute is not provided, but ideally all lps should have a human defined name and it is ok to use the tracker in the absence to maintain backwards compatiblity