<@ULVA73B9P> I'm attempting to run this code to cr...
# ask-marvin
a
@Marvin I'm attempting to run this code to create deployments:
Copy code
@flow
def dep_flow():
    print("Testing flow...")


if __name__ == "__main__":
    work_pool_env = os.getenv("DEPLOYMENT_ENV")
    gitlab_repo = os.getenv("GITLAB_REPO")

    os.chdir("/")
    dep_flow.from_source(
        source=GitRepository(
            url=gitlab_repo,
            credentials=GitLabCredentials.load("capacity-elt"),
        ),
        entrypoint="flows/deployments.py:dep_flow",
    ).deploy(
        name="dep_flow",
        work_pool_name=f"ecs-{work_pool_env}-l",
        paused=True
    )
And I'm getting this error:
Copy code
Traceback (most recent call last):
  File "<frozen importlib._bootstrap_external>", line 991, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1128, in get_code
  File "<frozen importlib._bootstrap_external>", line 1186, in get_data
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpzvhdsh6v/capacity-elt/flows/deployments.py'

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/prefect/flows.py", line 1760, in load_flow_from_entrypoint
    flow: Flow[P, Any] = import_object(entrypoint)  # pyright: ignore[reportRedeclaration]
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/utilities/importtools.py", line 223, in import_object
    module = load_script_as_module(script_path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/utilities/importtools.py", line 188, in load_script_as_module
    raise ScriptError(user_exc=exc, path=path) from exc
prefect.exceptions.ScriptError: Script at '/tmp/tmpzvhdsh6v/companyname-elt/flows/deployments.py' encountered an exception: FileNotFoundError(2, 'No such file or directory')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/flows/deployments.py", line 20, in <module>
    dep_flow.from_source(
  File "/usr/local/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 353, in coroutine_wrapper
    return run_coro_as_sync(ctx_call())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 209, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 330, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 193, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 403, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 190, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 343, in ctx_call
    result = await async_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/flows.py", line 1030, in from_source
    await from_async.wait_for_call_in_new_thread(
  File "/usr/local/lib/python3.12/site-packages/prefect/_internal/concurrency/api.py", line 160, in wait_for_call_in_new_thread
    return call.result()
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 330, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 184, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 364, in _run_sync
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/flows.py", line 1769, in load_flow_from_entrypoint
    flow: Optional[Flow[P, Any]] = safe_load_flow_from_entrypoint(entrypoint)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/flows.py", line 2087, in safe_load_flow_from_entrypoint
    func_def, source_code = _entrypoint_definition_and_source(entrypoint)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/prefect/flows.py", line 2321, in _entrypoint_definition_and_source
    source_code = Path(path).read_text()
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/pathlib.py", line 1027, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/pathlib.py", line 1013, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpzvhdsh6v/companyname-elt/flows/deployments.py'
m
Your message was too long by 1161 tokens...