01/30/2023, 2:44 PM
Hello, does anyone know how to work with gitlab-repository as a flow storage? I’ve created the gitlab-repository storage and it exists. I have referenced it when i deploy the flow as well. But when I trigger the flow run from the UI, I get this error
Downloading flow code from storage at ''
03:31:49 PM
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: ''

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/", 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.9/site-packages/prefect/client/", line 47, in with_injected_client
    return await fn(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/prefect/", 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.9/site-packages/prefect/utilities/", line 91, in run_sync_in_worker_thread
    return await anyio.to_thread.run_sync(
  File "/usr/local/lib/python3.9/site-packages/anyio/", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.9/site-packages/anyio/_backends/", line 937, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.9/site-packages/anyio/_backends/", line 867, in run
    result =, *args)
  File "/usr/local/lib/python3.9/site-packages/prefect/", line 772, in load_flow_from_entrypoint
    flow = import_object(entrypoint)
  File "/usr/local/lib/python3.9/site-packages/prefect/utilities/", line 195, in import_object
    module = load_script_as_module(script_path)
  File "/usr/local/lib/python3.9/site-packages/prefect/utilities/", line 158, in load_script_as_module
    raise ScriptError(user_exc=exc, path=path) from exc
prefect.exceptions.ScriptError: Script at '' encountered an exception: FileNotFoundError(2, 'No such file or directory')

Guy Altman

01/30/2023, 3:34 PM
How are you deploying? CLI or python file? and where are you executing that? Either way I have seen this error before, for me, I was getting the error when I wasn't running my deployment from a parent location to my flows.


01/30/2023, 3:43 PM
i’m deploying using python file in the parent location of my flows. And I’m executing it in the UI.
so I figured out that the issue was i had the wrong gitlab repository path and token set. I’m using private gitlab repository and it should not be the full repository path but only the the domain, e.g. https://<private-gitlab>.com and the access token should be generated from the gitlab project. You can check whether you can access gitlab with your token by
<https://oauth2>:<access token>@<private-gitlab-url>.com
Now the next issue i’m facing is, how do I make the gitlab block to point to specific repo within the project? I tried running something like
my_repo = GitLabRepository(
             reference=<my branch name>,
But I’m still getting an error:
File "/usr/local/lib/python3.9/site-packages/prefect_gitlab/", line 177, in get_directory
    raise OSError(f"Failed to pull from remote:\n {}")
Ok I was wrong. I need to give full path to the repo url. So i’m back to original error