https://prefect.io logo
Title
m

max

10/11/2022, 9:27 AM
Hey! I moved to prefect 2.5.0 from prefect 2.0b11 and got an error with flow deployment. In my app architecture, I want to deploy flows to prefect server from different service with python, and when I do that, this error occurs. Can you help?
1
deployment.py
this is my deployment script
can someone help?
1
k

Kalise Richmond

10/11/2022, 3:59 PM
Hi @max, it looks like your error has to do with the temp storage location. I recommend clearing the storage and checking out our deployments faq
m

max

10/11/2022, 5:25 PM
I cant understand why should I clean my temp storage when the error is the prefect agent cant find flow's code to execute also I run my prefect server and agent in docker containers so I restarted them and still the same error
k

Kalise Richmond

10/11/2022, 6:48 PM
I'm not sure I understand your error. Is the issue when the flow is running or when you are creating the deployment?
m

max

10/11/2022, 6:51 PM
@Kalise Richmond thanks for your response! yes. the error occurs when the flow is running:
Agents now support multiple work queues. Instead of passing a single argument, 
provide work queue names with the `-q` or `--work-queue` flag: `prefect agent 
start -q synchronization-work-queue`

Starting v2.5.0 agent connected to <http://prefect-server:4200/api>...

  ___ ___ ___ ___ ___ ___ _____     _   ___ ___ _  _ _____
 | _ \ _ \ __| __| __/ __|_   _|   /_\ / __| __| \| |_   _|
 |  _/   / _|| _|| _| (__  | |    / _ \ (_ | _|| .` | | |
 |_| |_|_\___|_| |___\___| |_|   /_/ \_\___|___|_|\_| |_|


Agent started! Looking for work from queue(s): synchronization-work-queue...
16:52:55.503 | INFO    | prefect.agent - Submitting flow run '17eb5c67-5ed9-44b1-a190-8fbb8426bb4b'
16:52:55.644 | INFO    | prefect.infrastructure.process - Opening process 'nocturnal-agama'...
16:52:55.664 | INFO    | prefect.agent - Completed submission of flow run '17eb5c67-5ed9-44b1-a190-8fbb8426bb4b'
16:52:58.810 | ERROR   | Flow run 'nocturnal-agama' - Flow could not be retrieved from deployment.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/prefect/engine.py", line 257, in retrieve_flow_then_begin_flow_run
    flow = await load_flow_from_flow_run(flow_run, client=client)
  File "/usr/local/lib/python3.7/site-packages/prefect/client/orion.py", line 82, in with_injected_client
    return await fn(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/prefect/deployments.py", line 158, in load_flow_from_flow_run
    await storage_block.get_directory(from_path=deployment.path, local_path=".")
  File "/usr/local/lib/python3.7/site-packages/prefect/filesystems.py", line 142, in get_directory
    shutil.copytree(from_path, local_path)
  File "/usr/local/lib/python3.7/shutil.py", line 318, in copytree
    names = os.listdir(src)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmph881gjukprefect/D:\\projects\\krok-ai\\services\\prefect_service\\flows\\synchronization'
k

Kalise Richmond

10/11/2022, 6:57 PM
I think if you set up a remote storage for the flow code, the agent will be able to retrieve it. I think it's taking the file path for the flow at the local temp storage on the docker image when it built the deployment but that file path does not stay the same when a new docker image spins up.
m

max

10/11/2022, 7:00 PM
@Kalise Richmond got it, I will try thank you so much!
j

Jarvis Stubblefield

10/11/2022, 7:47 PM
@max I’m still learning with Prefect and trying to get my agent to run my code and I’m not using Docker containers…. however, all of that said, it definitely is attempt to find a
D:\
within a
/tmp
directory. Here is the relevant bit from your error showing it is looking in the improper pathing for your flow:
'/tmp/tmph881gjukprefect/D:\\projects\\krok-ai\\services\\prefect_service\\flows\\synchronization'
… Don’t know how to fix that, but remote storage might help as indicated by @Kalise Richmond.
m

max

10/12/2022, 10:49 AM
@Jarvis Stubblefield yep, remote storage helped. @Kalise Richmond thank you again!
👍 1