You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar results as in #15153, but the cause seems to be unrelated.
Decorating a @flow in Prefect >= 3 results in an empty flow run graph, and no logs are shown in the Prefect UI. The contents of the decorator do not matter, and the bug occurs using both @flow and @flow() syntax.
Minimal reproducible example:
Start a local Prefect server with prefect server start
Run the file below using PREFECT_API_URL=http://127.0.0.1:4200/api python3 example.py
importfunctoolsfromprefectimporttask, flow, servehandler_ids= []
defdummy_decorator(func):
@functools.wraps(func)defwrapper(*args, **kwargs):
returnfunc(*args, **kwargs)
returnwrapper@task(log_prints=True)@dummy_decoratordeftask_1():
print("This was logged in Task 1")
@task(log_prints=True)@dummy_decoratordeftask_2():
print("This was logged in Task 2")
@flow(log_prints=True)@dummy_decoratorasyncdefdecorated_flow():
task_1()
task_2()
@flow(log_prints=True)asyncdefexample_flow():
task_1()
task_2()
if__name__=="__main__":
serve(
decorated_flow.to_deployment(name="decorated-flow"),
example_flow.to_deployment(name="example-flow"),
)
Running the flow decorated-flow yields an empty flow graph and no logs. Running the flow example-flow yields the expected flow graph and the expected logs. This issue was not present in Prefect 2.*, see additional context.
Version info
Version: 3.1.5
API version: 0.8.4
Python version: 3.13.0
Git commit: 3c06654e
Built: Mon, Dec 2, 2024 6:57 PM
OS/Arch: linux/x86_64
Profile: local
Server type: ephemeral
Pydantic version: 2.10.2
Server:
Database: sqlite
SQLite version: 3.46.0
Additional context
Decorated flow run example run:
Non-decorated flow run example run:
The issue was discovered while trying to configure loguru and Prefect, using the following decorator, which worked in Prefect 2.*, but results in the mentioned issues in Prefect 3.*:
Sadly, switching the decorators around doesn't work, since @flow returns an instance of <class 'prefect.flows.Flow'>, and not a plain function that we can further decorate. I agree, the behavior is really strange!
Bug summary
Similar results as in #15153, but the cause seems to be unrelated.
Decorating a
@flow
in Prefect >= 3 results in an empty flow run graph, and no logs are shown in the Prefect UI. The contents of the decorator do not matter, and the bug occurs using both@flow
and@flow()
syntax.Minimal reproducible example:
prefect server start
PREFECT_API_URL=http://127.0.0.1:4200/api python3 example.py
Running the flow
decorated-flow
yields an empty flow graph and no logs. Running the flowexample-flow
yields the expected flow graph and the expected logs. This issue was not present in Prefect 2.*, see additional context.Version info
Additional context
Decorated flow run example run:
Non-decorated flow run example run:
The issue was discovered while trying to configure
loguru
and Prefect, using the following decorator, which worked in Prefect 2.*, but results in the mentioned issues in Prefect 3.*:The text was updated successfully, but these errors were encountered: