https://prefect.io logo
Title
s

Siva Balusu

02/14/2023, 4:27 PM
Hi I am encountering "No such file or directory" while using github as a storage. I am using prefect version: 2.7.9 and agent is running on a remote machine.
Flow could not be retrieved from deployment.
Traceback (most recent call last):
  File "<frozen importlib._bootstrap_external>", line 879, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1016, in get_code
  File "<frozen importlib._bootstrap_external>", line 1073, in get_data
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmppy44ikxrprefect/sample_flow.py'

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 266, in retrieve_flow_then_begin_flow_run
    flow = await load_flow_from_flow_run(flow_run, client=client)
  File "/usr/local/lib/python3.10/site-packages/prefect/client/utilities.py", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/prefect/deployments.py", line 186, 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.10/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.10/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/usr/local/lib/python3.10/site-packages/prefect/flows.py", line 772, in load_flow_from_entrypoint
    flow = import_object(entrypoint)
  File "/usr/local/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 195, in import_object
    module = load_script_as_module(script_path)
  File "/usr/local/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 158, in load_script_as_module
    raise ScriptError(user_exc=exc, path=path) from exc
prefect.exceptions.ScriptError: Script at 'sample_flow.py' encountered an exception: FileNotFoundError(2, 'No such file or directory')
Here is the deployment file:
from sample_flow import start_sample_flow
from prefect.deployments import Deployment
from prefect.filesystems import GitHub

deployment = Deployment.build_from_flow(
    flow=start_sample_flow,
    name="sample-pipeline",
    version="2",
    tags=["VA_PIPELINE"],
    storage=GitHub.load("dev"),
    skip_upload=True,
    infra_overrides={"env": {"PREFECT_LOGGING_LEVEL": "DEBUG"}},
    path="cloud/prefectflows"
)

if __name__ == "__main__":
    deployment.apply()
any help here is much appreciated
j

Jeff Hale

02/15/2023, 3:28 AM
Did you use caching when you ran your flow previously? Looks like its’ trying to find a cache file in temporary storage that doesn’t exist in your GitHub repo.
s

Siva Balusu

02/16/2023, 4:13 AM
@Jeff Hale No I haven't used any cache. How to debug more?
j

Jeff Hale

02/17/2023, 2:46 PM
Hmm. It’s looking for your flow file in your temp directory.
'/tmp/tmppy44ikxrprefect/sample_flow.py'
Are you able to share your file structure and flow code (or an MRE?) This might be related to this issue.