Scott Asher
10/26/2020, 1:45 AMFile "/usr/scratch/sasher/pyenvs/prefect/lib/python3.6/site-packages/prefect/utilities/storage.py", line 85, in extract_flow_from_file
raise ValueError("No flow found in file.")
ValueError: No flow found in file.
from prefect import Flow
from prefect.environments import LocalEnvironment
from prefect.environments.storage import Local
import logging
logging.getLogger(__name__)
if __name__ == "__main__":
with Flow(
"Daily DAG",
environment=LocalEnvironment(),
storage=Local(stored_as_script=True, path=__file__)
) as flow:
from x import construct_dag, prefectize
tasks = prefectize(construct_dag(), flow)
for task in tasks:
flow.add_task(task)
Zanie
if __name__ == "__main__":
is not true when extract_flow_from_file
is run. It loads the code from your file and then executes it (but not as a script i.e. not in the main thread) then looks for your variable.Scott Asher
10/26/2020, 3:25 PMZanie