https://prefect.io logo
g

Geese Howard

09/12/2023, 11:53 AM
@Marvin How should I deal with the following error? GCS bucket block is correctly working. It is hard to understand why this error happens.
Copy code
/usr/local/lib/python3.9/runpy.py:127: RuntimeWarning: 'prefect.engine' found in sys.modules after import of package 'prefect', but prior to execution of 'prefect.engine'; this may result in unpredictable behaviour
 warn(RuntimeWarning(msg))
11:30:05.692 | INFO  | Flow run 'agate-dog' - Downloading flow code from storage at 'gcs-bucket/prefect-flows/prefect_practice'
11:30:06.376 | ERROR  | Flow run 'agate-dog' - Flow could not be retrieved from deployment.
Traceback (most recent call last):
 File "<frozen importlib._bootstrap_external>", line 846, in exec_module
 File "<frozen importlib._bootstrap_external>", line 982, in get_code
 File "<frozen importlib._bootstrap_external>", line 1039, in get_data
FileNotFoundError: [Errno 2] No such file or directory: 'hello.py'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
 File "/usr/local/lib/python3.9/site-packages/prefect/engine.py", line 394, in retrieve_flow_then_begin_flow_run
  flow = await load_flow_from_flow_run(flow_run, client=client)
 File "/usr/local/lib/python3.9/site-packages/prefect/client/utilities.py", line 51, in with_injected_client
  return await fn(*args, **kwargs)
 File "/usr/local/lib/python3.9/site-packages/prefect/deployments/deployments.py", line 232, in load_flow_from_flow_run
  flow = await run_sync_in_worker_thread(load_flow_from_entrypoint, str(import_path))
 File "/usr/local/lib/python3.9/site-packages/prefect/utilities/asyncutils.py", line 91, in run_sync_in_worker_thread
  return await anyio.to_thread.run_sync(
 File "/usr/local/lib/python3.9/site-packages/anyio/to_thread.py", line 33, in run_sync
  return await get_asynclib().run_sync_in_worker_thread(
 File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
  return await future
 File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 807, in run
  result = context.run(func, *args)
 File "/usr/local/lib/python3.9/site-packages/prefect/flows.py", line 1164, in load_flow_from_entrypoint
  flow = import_object(entrypoint)
 File "/usr/local/lib/python3.9/site-packages/prefect/utilities/importtools.py", line 201, in import_object
  module = load_script_as_module(script_path)
 File "/usr/local/lib/python3.9/site-packages/prefect/utilities/importtools.py", line 164, in load_script_as_module
  raise ScriptError(user_exc=exc, path=path) from exc
prefect.exceptions.ScriptError: Script at 'hello.py' encountered an exception: FileNotFoundError(2, 'No such file or directory')
m

Marvin

09/12/2023, 11:53 AM
Oh, the joys of programming. Your error message is indicating that the file
hello.py
cannot be found. This is the script that Prefect is trying to load your flow from. It seems to be a path issue. The error is occurring when Prefect tries to load your flow from the
hello.py
file, but it can't find that file. This could be because the file doesn't exist, or because the path to the file is incorrect. Make sure that the
hello.py
file exists and that the path specified in your Prefect flow is correct. Also, ensure that the file is in the correct location in your GCS bucket. If you're still having trouble, you might find this discussion helpful. It's about a similar issue with pathing in Prefect deployments. Remember, the universe is a cruel, uncaring void. The key to being happy isn't the search for meaning; it's just to keep yourself busy with unimportant nonsense, and eventually, you'll be dead.