Hello again <@ULVA73B9P> -- I'm getting an error `...
# ask-marvin
m
Hello again @Marvin -- I'm getting an error
No such file or directory: '/opt/prefect/modal-docker-test'
when attempting to run a Modal worker. The relevant parts of my prefect.yaml are:
Copy code
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`:
Copy code
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":
Copy code
from prefect import flow
from prefect.docker.docker_image import DockerImage

@flow(log_prints=True)
def my_flow():
    print("Hello, Modal!")
Any ideas?
m
It seems there are no open issues related to your error in the Prefect or Prefect-Docker repositories. However, let's address your problem with the available information. The error
No 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.
Copy code
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:
Copy code
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.
n
hi @Moishe - this example might be helpful • deployment definition • flow • dockerfile
gratitude thank you 1
m
Thanks so much for these pointers! Unfortunately I would be tearing my hair out trying to get this to work, if I had any hair to pull out šŸ˜‚ I'm having a lot of trouble getting a modal worker pool working with a Docker image. The setup I'm using is: Dockerfile deploy.yaml modal_from_docker_image.py Note that I have successfully deployed a Docker image when running a local worker pool, instead of using Modal as the worker pool (you can see that deployment in the yaml file above too). Sometimes I get an error in Modal that looks like this:
Copy code
Feb 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!
thinking about this a tiny bit more, I think the thing that would help me tremendously is a working demo that uses a modal worker pool and a docker image containing the flow. If there isn't one now I'll write up a blog post when I get this working!
hey @Nate any ideas about the above?
n
Hey, I think you were running into a bug with prefect cloud - have you tried again in the last couple hours?
m
oh! I have not -- will try soon and let you know, thank you!
hmm, I'm still seeing the "No such file or directory: `/opt/prefect`" error. Do I need to specify a Docker image in the work pool (where it says "base image to use for sandbox") and if so should this be the image that I specify in the deployment?
n
well before you were seeing this right?
Copy code
/bin/sh: 1: uv: not found
this was the bug this
Copy code
"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
step
or, since i see you already have that pull step
Copy code
pull:
  - prefect.deployments.steps.set_working_directory:
      directory: /opt/prefect/modal-docker-test
that path doesnt' exist in your image for some reason
i do see your lines here
Copy code
RUN mkdir -p /opt/prefect/modal-docker-test
COPY . /opt/prefect/modal-docker-test
but i suspect its somehow a pathing issue still. id recommend running
bash
on the image when you build it and `cd`ing around to make sure things are where you expect
m
hmm, yeah, the image does have that path:
Copy code
(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.
but I'll keep poking -- thank you!
(I updated the path in the Dockerfile to point at the
/opt/prefect/prefect-docker
directory that I create in my updated Dockerfile)
it feels like Modal's using the wrong image, somehow -- is there any way to inspect the image it's using?