https://prefect.io logo
s

Scott Asher

10/25/2020, 9:03 PM
Running into problem - registering flow created in non
__main__
(moved code blocks into thread)
c

Chris White

10/25/2020, 9:04 PM
Hi Scott, can you please create a Slack thread for all of these tracebacks and code blocks so the main channel remains tidy?
1
Otherwise, your Flow needs to be created in the main script body if you are using script-based storage. The script will be rerun by a non-main process which means the flow definition and corresponding attributes need to be available outside the
if __name__ == "__main__"
block
s

Scott Asher

10/25/2020, 9:07 PM
If I create a flow in main, but add tasks to it in a module, is that ok?
CODE BLOCKS
Copy code
[2020-10-25 21:02:01,914] INFO - agent | Deploying flow run 33be3c15-89dd-4c27-9d65-c56fa41d12c3
No flow found in file.
Traceback (most recent call last):
  File "/usr/local/bin/prefect", line 11, in <module>
    sys.exit(cli())
  File "/usr/scratch/sasher/pyenvs/prefect/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/scratch/sasher/pyenvs/prefect/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/scratch/sasher/pyenvs/prefect/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/scratch/sasher/pyenvs/prefect/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/scratch/sasher/pyenvs/prefect/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/scratch/sasher/pyenvs/prefect/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/scratch/sasher/pyenvs/prefect/lib/python3.6/site-packages/prefect/cli/execute.py", line 34, in flow_run
    return _execute_flow_run()
  File "/usr/scratch/sasher/pyenvs/prefect/lib/python3.6/site-packages/prefect/cli/execute.py", line 99, in _execute_flow_run
    raise exc
  File "/usr/scratch/sasher/pyenvs/prefect/lib/python3.6/site-packages/prefect/cli/execute.py", line 84, in _execute_flow_run
    flow = storage.get_flow(storage.flows[flow_data.name])
  File "/usr/scratch/sasher/pyenvs/prefect/lib/python3.6/site-packages/prefect/environments/storage/local.py", line 100, in get_flow
    return extract_flow_from_file(file_path=flow_location)
  File "/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.
[2020-10-25 21:03:01,555] INFO - agent | Process PID 34324 returned non-zero exit code
c

Chris White

10/25/2020, 9:08 PM
Yup, so long as a rerun of the script itself (when
__name__
is not
__main__
) produces the Flow object that you expect
s

Scott Asher

10/25/2020, 9:08 PM
ok gotcha, so that’s a way to test