Moishe
02/21/2025, 9:17 PMNo such file or directory: '/opt/prefect/modal-docker-test'
when attempting to run a Modal worker. The relevant parts of my prefect.yaml are:
name: modal-docker-test
prefect-version: 3.2.2
build:
- prefect_docker.deployments.steps.build_docker_image:
id: build_image
requires: prefect-docker>=0.3.1
image_name: <http://nnn.dkr.ecr.us-west-2.amazonaws.com/moishe-test/test|nnn.dkr.ecr.us-west-2.amazonaws.com/moishe-test/test>
tag: fromyaml12
dockerfile: Dockerfile
push:
- prefect_docker.deployments.steps.push_docker_image:
requires: prefect-docker>=0.3.1
image_name: '{{ build_image.image_name }}'
tag: '{{ build_image.tag }}'
pull:
- prefect.deployments.steps.set_working_directory:
directory: /opt/prefect/modal-docker-test
deployments:
- name: modal-deployment-yaml12
entrypoint: modal_from_docker_image.py:my_flow
work_pool:
name: 'my-modal-pool'
work_queue_name: null
job_variables:
image:
name: '{{ build_image.image_name }}:{{ build_image.tag }}'
My Dockerfile copies the root directory into `modal-docker-test`:
RUN mkdir -p /opt/prefect/modal-docker-test
COPY . /opt/prefect/modal-docker-test
The program I'm deploying is a flow that just says "hello world":
from prefect import flow
from prefect.docker.docker_image import DockerImage
@flow(log_prints=True)
def my_flow():
print("Hello, Modal!")
Any ideas?Marvin
02/21/2025, 9:17 PMNo such file or directory: '/opt/prefect/modal-docker-test'
indicates that the specified directory might not exist at runtime. Here are a few things to check:
1. Dockerfile Configuration: Make sure your Dockerfile correctly creates and copies the files to the directory /opt/prefect/modal-docker-test
. Your Dockerfile snippet looks correct, but double-check that the build context includes all necessary files.
dockerfile
RUN mkdir -p /opt/prefect/modal-docker-test
COPY . /opt/prefect/modal-docker-test
2. Working Directory: Confirm that the set_working_directory
step in your prefect.yaml
is correctly configured. Ensure that the directory exists in the built Docker image.
3. Build Context: Ensure that all the files you expect to be copied are within the build context of your Docker build. The build context is usually the directory you specify when running docker build
.
4. Verify the Docker Image: After building the Docker image, you can inspect it to verify that the directory is present. You can do this by running the image interactively and checking the filesystem:
bash
docker run -it <your-image-name> /bin/bash
ls /opt/prefect/modal-docker-test
5. Prefect Documentation: For further insights, you might want to explore Prefect's infrastructure concepts and YAML configuration guides:
- Prefect YAML Configuration
- Docker Infrastructure Examples
If these steps don't resolve the issue, consider checking the logs for more detailed error messages or verifying that the image is being built and pushed correctly.Nate
02/21/2025, 10:59 PMMoishe
02/22/2025, 8:42 PMFeb 22 13:36:46.667
Building image im-1dQOGIXTHI07xs81YG45nP
Feb 22 13:36:46.743
=> Step 0: FROM base
Feb 22 13:36:46.744
=> Step 1: RUN uv pip install prefect --system
Feb 22 13:36:47.085
/bin/sh: 1: uv: not found
Feb 22 13:36:47.306
Terminating task due to error: failed to run builder command "uv pip install prefect --system": container exit status: 127
Feb 22 13:36:47.468
Runner failed with exception: task exited with failure, status = exit status: 1
Other times I get an error in Modal like this (made gist because it's a little longer, but it's the "missing /opt/prefect
" error)
I've tried creating new deploys and workflows in case there's a caching issue someplace, and I've created new labels for each build in case there's a caching issue someplace else. None of this has worked.
The latest deploy to have these failures is: 'my-flow/modal-deployment-test' successfully created with id 'e3325bed-a9ee-4101-9155-f6dd840da16f'
I am very likely missing something obvious, but any pointers would be super appreciated! And Nate, thanks for your YouTube videos, they've been super helpful!Moishe
02/23/2025, 3:59 PMMoishe
02/24/2025, 9:17 PMNate
02/24/2025, 9:25 PMMoishe
02/24/2025, 9:25 PMMoishe
02/24/2025, 9:51 PMNate
02/24/2025, 9:52 PM/bin/sh: 1: uv: not found
this was the bug
this
"No such file or directory: /opt/prefect"
is likely a pathing issue where your entrypoint isnt pointed at the right spot in the image, ie you might need a set_working_directory
stepNate
02/24/2025, 9:53 PMpull:
- prefect.deployments.steps.set_working_directory:
directory: /opt/prefect/modal-docker-test
that path doesnt' exist in your image for some reasonNate
02/24/2025, 9:53 PMRUN mkdir -p /opt/prefect/modal-docker-test
COPY . /opt/prefect/modal-docker-test
Nate
02/24/2025, 9:54 PMbash
on the image when you build it and `cd`ing around to make sure things are where you expectMoishe
02/24/2025, 9:55 PM(env) ā prefect-docker-testing docker run -it <http://713696772979.dkr.ecr.us-east-1.amazonaws.com/prefect-flows:latest|713696772979.dkr.ecr.us-east-1.amazonaws.com/prefect-flows:latest> bash
root@fd9b454ecbef:/opt/prefect/prefect-docker# pwd
/opt/prefect/prefect-docker
root@fd9b454ecbef:/opt/prefect/prefect-docker# ls ../
entrypoint.sh prefect-docker
I was seeing the uv
error occasionally and also the "path not found" error, I couldn't figure out what caused which error to occur.Moishe
02/24/2025, 9:55 PMMoishe
02/24/2025, 9:56 PM/opt/prefect/prefect-docker
directory that I create in my updated Dockerfile)Moishe
02/24/2025, 9:57 PM