Hi! I am trying to deploy a run that uses a prebui...
# ask-community
o
Hi! I am trying to deploy a run that uses a prebuilt docker container that contains my flow. My intention is to have the worker pull that image (at the schedule determined by the deployment), and run the flow inside it. • i have one repo that has my flow and other business logic in it. The business logic runs correctly. I am creating a docker image from that whose entry point just runs the main function in my business logic (which is decorated as a flow) • a want to send deployments to prefect to trigger a worker to pull the image and run it. The closest i've got is this
deploy.py
script which i run to make the deployment
Copy code
from prefect.client.schemas.schedules import IntervalSchedule
from prefect import deploy, flow
import datetime

if __name__ == "__main__":
    
    @flow
    def dummy_flow():
        pass
    
    dummy_flow.deploy(
        name="gmk-ollie",
        image="registry.gitlab.com/mycompany/lab/project/project:dev",
        work_pool_name="ollie-pool",
        job_variables={"env": {}},
        parameters={"prefect_secret_to_env_var": {}},
        schedules=[
            IntervalSchedule(
                interval=datetime.timedelta(minutes=10),
            )
        ],
        build=False,
        push=False
    )
which does trigger the worker to pull the docker container, but then i get an error on the worker
Copy code
19:41:53.184 | INFO    | prefect.workers.docker.ollie - Docker container 'steady-shrimp' has status 'running' 
19:41:58.844 | INFO    | prefect.flow_runs.runner - Opening process...
19:42:03.176 | INFO    | Flow run 'steady-shrimp' - Downloading flow code from storage at '.'
19:42:03.200 | ERROR   | prefect.engine - Engine execution of flow run 'c526cdfc-ff92-4909-9cfe-cee07ac09ecc' exited with unexpected exception
Traceback (most recent call last):
  File "<frozen importlib._bootstrap_external>", line 936, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1073, in get_code
  File "<frozen importlib._bootstrap_external>", line 1130, in get_data
FileNotFoundError: [Errno 2] No such file or directory: '/app/deploy.py
so the worker is trying to run the
deploy.py
which is definitely not correct. (In addition there is that
dummy_flow()
which seems to be suggested whenever i try and search for this). Much appreciated for any advice on how to proceed? Thanks!
the dockerfile in my business logic repo is this, if that is any help:
Copy code
FROM python:3.11-slim

WORKDIR /app

COPY ./gold_mine_keysight /app/gold_mine_keysight
COPY ./pyproject.toml /app/

RUN pip install --upgrade pip
RUN pip install .

# run the file to run the flow function
# run.py contains
#
# @flow
# def run():
#    ..
#
# if __name__ == "__main__":
#    run()
CMD ["python", "-m", "project.run"]