Constantino Schillebeeckx
09/13/2021, 9:09 PMKevin Kho
Constantino Schillebeeckx
09/13/2021, 9:24 PMConstantino Schillebeeckx
09/13/2021, 9:24 PMKevin Kho
sys.exit(exit_code)
right? These honestly don’t play well with Prefect though because what happens is the Flow abruptly exits and Prefect doesn’t know what happened to the process because it died.Constantino Schillebeeckx
09/13/2021, 9:31 PMpython some_flow.py
there's no way for me to programmatically know whether that flow was successful?Kevin Kho
python some_flow.py
using flow.run()
?Constantino Schillebeeckx
09/13/2021, 9:34 PMConstantino Schillebeeckx
09/13/2021, 9:35 PMflow.run()
return an exit code?Kevin Kho
Kevin Kho
import prefect
from prefect import task, Flow
from prefect.engine.state import Success
@task
def hello_task():
logger = prefect.context.get("logger")
<http://logger.info|logger.info>("Hello world!")
with Flow(
"hello-flow",
) as flow:
hello = hello_task()
test = flow.run()
print(isinstance(test, Success))
Zanie
prefect run
will do this for youConstantino Schillebeeckx
09/13/2021, 9:42 PMimport sys
from prefect import Flow
from prefect.engine.state import Success
with Flow("dbt_debug_canary") as flow:
# some tasks!
if __name__ == "__main__":
if not isinstance(flow.run(), Success):
sys.exit(1)
Constantino Schillebeeckx
09/13/2021, 9:45 PMprefect run -p some_flow.py
does what I want - thanks everyone!