<@ULVA73B9P> I get the following log sometimes whe...
# marvin-in-the-wild
m
@Marvin I get the following log sometimes when trying to run a pipeline. When I try to rerun the pipeline after it fails, I completes successfully. Why do I get this error, the python version used in my docker image is 3.11?
Copy code
Downloading flow code from storage at '.'
04:21:23 PM
prefect.flow_runs
Flow could not be retrieved from deployment.
Traceback (most recent call last):
  File "", line 879, in exec_module
  File "", line 1016, in get_code
  File "", line 1073, in get_data
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp4pi0z171prefect/flows/inspection/base.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 424, in retrieve_flow_then_begin_flow_run
    else await load_flow_from_flow_run(flow_run, client=client)
  File "/usr/local/lib/python3.10/site-packages/prefect/client/utilities.py", line 51, in with_injected_client
    return await fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/prefect/deployments/deployments.py", line 271, 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 95, 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 33, 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 877, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/usr/local/lib/python3.10/site-packages/prefect/flows.py", line 1551, in load_flow_from_entrypoint
    flow = import_object(entrypoint)
  File "/usr/local/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 201, in import_object
    module = load_script_as_module(script_path)
  File "/usr/local/lib/python3.10/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 'flows/inspection/base.py' encountered an exception: FileNotFoundError(2, 'No such file or directory')
m
Your message was too long by 348 tokens - please shorten it and try again. For reference, here's your message at the allowed limit:
I get the following log sometimes when trying to run a pipeline. When I try to rerun the pipeline after it fails, I completes successfully. Why do I get this error, the python version used in my docker image is 3.11?
```Downloading flow code from storage at '.' 042123 PM prefect.flow_runs Flow could not be retrieved from deployment. Traceback (most recent call last): File "", line 879, in exec_module File "", line 1016, in get_code File "", line 1073, in get_data FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp4pi0z171prefect/flows/inspection/base.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 424, in retrieve_flow_then_begin_flow_run else await load_flow_from_flow_run(flow_run, client=client) File "/usr/local/lib/python3.10/site-packages/prefect/client/utilities.py", line 51, in with_injected_client return await fn(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/prefect/deployments/deployments.py", line 271, in load_flow_from_flow_run
m
@Marvin I get the following log sometimes when trying to run a pipeline. When I try to rerun the pipeline after it fails, I completes successfully. Why do I get this error, the python version used in my docker image is 3.11?
Copy code
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 424, in retrieve_flow_then_begin_flow_run
    else await load_flow_from_flow_run(flow_run, client=client)
  File "/usr/local/lib/python3.10/site-packages/prefect/client/utilities.py", line 51, in with_injected_client
    return await fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/prefect/deployments/deployments.py", line 271, 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 95, 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 33, 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 877, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/usr/local/lib/python3.10/site-packages/prefect/flows.py", line 1551, in load_flow_from_entrypoint
    flow = import_object(entrypoint)
  File "/usr/local/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 201, in import_object
    module = load_script_as_module(script_path)
  File "/usr/local/lib/python3.10/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 'flows/inspection/base.py' encountered an exception: FileNotFoundError(2, 'No such file or directory')
m
Your message was too long by 231 tokens - please shorten it and try again. For reference, here's your message at the allowed limit:
I get the following log sometimes when trying to run a pipeline. When I try to rerun the pipeline after it fails, I completes successfully. Why do I get this error, the python version used in my docker image is 3.11?
```Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 424, in retrieve_flow_then_begin_flow_run else await load_flow_from_flow_run(flow_run, client=client) File "/usr/local/lib/python3.10/site-packages/prefect/client/utilities.py", line 51, in with_injected_client return await fn(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/prefect/deployments/deployments.py", line 271, 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 95, 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 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "/usr/local/lib/python3.10/site-pack
m
@Marvin I get the following log sometimes when trying to run a pipeline. When I try to rerun the pipeline after it fails, I completes successfully. Why do I get this error, the python version used in my docker image is 3.11?
Copy code
File "/usr/local/lib/python3.10/site-packages/prefect/utilities/asyncutils.py", line 95, 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 33, 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 877, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/usr/local/lib/python3.10/site-packages/prefect/flows.py", line 1551, in load_flow_from_entrypoint
    flow = import_object(entrypoint)
  File "/usr/local/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 201, in import_object
    module = load_script_as_module(script_path)
  File "/usr/local/lib/python3.10/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 'flows/inspection/base.py' encountered an exception: FileNotFoundError(2, 'No such file or directory')
m
Your message was too long by 81 tokens - please shorten it and try again. For reference, here's your message at the allowed limit:
I get the following log sometimes when trying to run a pipeline. When I try to rerun the pipeline after it fails, I completes successfully. Why do I get this error, the python version used in my docker image is 3.11?
``` File "/usr/local/lib/python3.10/site-packages/prefect/utilities/asyncutils.py", line 95, 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 33, 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 877, in run_sync_in_worker_thread return await future File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run result = context.run(func, *args) File "/usr/local/lib/python3.10/site-packages/prefect/flows.py", line 1551, in load_flow_from_entrypoint flow = import_object(entrypoint) File "/usr/local/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 201, in import_object module = load_script_as_module(script_path)
m
@Marvin I get the following log sometimes when trying to run a pipeline. When I try to rerun the pipeline after it fails, I completes successfully. Why do I get this error, the python version used in my docker image is 3.11?
Copy code
File "/usr/local/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 201, in import_object
    module = load_script_as_module(script_path)
  File "/usr/local/lib/python3.10/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 'flows/inspection/base.py' encountered an exception: FileNotFoundError(2, 'No such file or directory')
m
Your issue seems related to inconsistent environment setups and potentially race conditions or synchronization issues when running the pipeline in Docker. Here are a few relevant points gathered from documentation and GitHub issues: 1. Docker Environment Inconsistencies: - Make sure your Docker image has the correct paths and dependencies set up properly. A similar issue was found here, where deployments with Docker storage randomly failed due to missing files. Ensure that your Dockerfile correctly copies the necessary files:
Copy code
Dockerfile
     COPY . /opt/prefect/flows/
     WORKDIR /opt/prefect/flows/
2. Version Mismatch: - Confirm that the Python version in your Docker image is consistent with what Prefect expects. From your traceback, it looks like Python 3.10 is being used, but you mentioned Python 3.11. Verify the Python version in your Docker image and pipelines. - The Prefect documentation mentions setting up Prefect with a specific Python version here. 3. Handling ScriptError and FileNotFoundError: - A common issue is the deployment paths and the file locations not aligning. An issue here noted problems with file paths in custom Docker images. 4. CI/CD Configurations: - Ensure your CI/CD pipeline correctly handles file paths and environment variables across different stages. Prefect has a guide on CI/CD with Docker here. In summary, address each of these potential issues: - Double-check file paths in your Docker image. - Ensure consistent Python versions. - Properly handle file copying and working directory paths in your Dockerfile. For further support, you might find this GitHub issue particularly useful, as it closely resembles your situation.
m
The image works some of the time, the code is in the image and there's only python3.11. Why is there an error for python3.10 and why is it saying the files aren't found?