Giovanni Giacco
06/14/2023, 2:27 PMNate
06/14/2023, 4:59 PMreturn
value from a flow context, then the flow will return None
just like any other python function
if you successfully return a python object, it will behave from the outside like any python function, and Prefect will give the flow run a completed state in the backend - for example
from prefect import flow
@flow
def foo() -> str:
return "Hello Marvin!"
assert foo() == "Hello Marvin!"
11:59:33.104 | INFO | prefect.engine - Created flow run 'invaluable-limpet' for flow 'foo'
11:59:33.106 | INFO | Flow run 'invaluable-limpet' - View at <https://app.prefect.cloud/account/12242a57-9f05-4bf5-8853-9bff595d4bab/workspace/cafa2ffa-f6cc-4ed6-ab76-eaa4ba1ad40e/flow-runs/flow-run/bcc2aaa7-b05e-4f41-ad5b-59299027f9f9>
11:59:34.692 | INFO | Flow run 'invaluable-limpet' - Finished in state Completed()
Cristian Federiconi
06/15/2023, 4:46 PMNate
06/15/2023, 5:06 PMreturn
value from a flow context, then the flow will return None
just like any other python function
the link I sent refers more to the state assumed by the flow based on the return value, which doesn't seem to be your concern
as far as I'm aware, Prefect doesn't care what the return value is, if your flow-decorated function returns a value, it will be returned just like python
In [14]: @flow
...: def test():
...: return None
...:
In [15]: assert test() is None
12:00:28.672 | INFO | prefect.engine - Created flow run 'bright-toad' for flow 'test'
12:00:38.510 | INFO | Flow run 'bright-toad' - Finished in state Completed()
In [22]: @flow
...: def test():
...: pass
...:
In [23]: assert test() is None
12:07:44.222 | INFO | prefect.engine - Created flow run 'spirited-jaybird' for flow 'test'
12:07:45.243 | INFO | Flow run 'spirited-jaybird' - Finished in state Completed()
Nate
06/15/2023, 5:09 PMCristian Federiconi
06/16/2023, 7:51 AM