Patrick Düggelin
02/17/2025, 8:59 AMUnexpected exception encountered when trying to load flow
Traceback (most recent call last):
File "/home/data-collection/detectron/.venv/lib/python3.10/site-packages/prefect/engine.py", line 51, in <module>
flow: "Flow[..., Any]" = load_flow(flow_run)
File "/home/data-collection/detectron/.venv/lib/python3.10/site-packages/prefect/flow_engine.py", line 130, in load_flow
flow = run_coro_as_sync(
File "/home/data-collection/detectron/.venv/lib/python3.10/site-packages/prefect/utilities/asyncutils.py", line 209, in run_coro_as_sync
return call.result()
File "/home/data-collection/detectron/.venv/lib/python3.10/site-packages/prefect/_internal/concurrency/calls.py", line 330, in result
return self.future.result(timeout=timeout)
...
return await func(client, *args, **kwargs)
File "/home/data-collection/detectron/.venv/lib/python3.10/site-packages/prefect/flows.py", line 2315, in load_flow_from_flow_run
await storage_block.get_directory(from_path=from_path, local_path=".")
File "/home/data-collection/detectron/.venv/lib/python3.10/site-packages/prefect/utilities/asyncutils.py", line 343, in ctx_call
result = await async_fn(*args, **kwargs)
File "/home/data-collection/detectron/.venv/lib/python3.10/site-packages/prefect/filesystems.py", line 146, in get_directory
local_path = Path(local_path).resolve()
File "/usr/lib/python3.10/pathlib.py", line 1077, in resolve
s = self._accessor.realpath(self, strict=strict)
File "/usr/lib/python3.10/posixpath.py", line 397, in realpath
return abspath(path)
File "/usr/lib/python3.10/posixpath.py", line 384, in abspath
cwd = os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
Marvin
02/17/2025, 8:59 AMMarvin
02/17/2025, 9:00 AMFileNotFoundError: [Errno 2] No such file or directory
, typically occurs when the working directory is missing or has been deleted during the execution of your flow. This is likely related to the get_directory
method in the Prefect filesystem storage block, which tries to resolve a local path that no longer exists.
Here are some things you can check or try:
1. Ensure the Working Directory Exists: Verify that the directory from which you're running the Prefect flow exists and hasn't been deleted or moved. This includes any relative paths that might be used by the flow.
2. Check Storage Block Configuration: If you are using a storage block, ensure it is correctly configured to point to a valid directory. You might want to explicitly set the basepath
in your filesystem block configuration to a directory you know exists.
3. Debugging Path Resolution: The error originates from resolving the path using Python's pathlib
. You might want to add some debugging to ensure that the paths being resolved are correct.
4. Review Recent Changes: If you recently upgraded to Prefect 3.x, note that there are some changes in how agents and workers operate, as well as how storage is managed. Ensure that your flow is compatible with these changes. Prefect 3.x Gotchas
For more detailed information, you can refer to the Prefect Filesystems Code and Flow Engine Code where these functionalities are defined. If you're using a specific storage block, make sure it's correctly implemented according to these guidelines.
If these suggestions don't resolve your issue, consider checking for any additional context or logs that might provide more insights into what might be going wrong.