https://prefect.io logo
Title
s

Seth Coussens

08/01/2022, 8:48 PM
Has anyone seen the error:
'prefect.engine' is a package and cannot be directly executed
when trying to run a DockerContainer flow in Prefect 2.0?
1
Here are the log entries:
20:46:10.664 | INFO    | prefect.agent - Completed submission of flow run 'f489116c-3ab8-45e9-9b0e-5b472bd94b2b'
20:46:10.676 | INFO    | prefect.infrastructure.docker-container - Docker container 'beige-basilisk' has status 'running'
/usr/local/bin/python: No module named prefect.engine.__main__; 'prefect.engine' is a package and cannot be directly executed
20:46:11.612 | INFO    | prefect.infrastructure.docker-container - Docker container 'beige-basilisk' has status 'exited'
Very simple flow too:
from prefect import flow, get_run_logger

@flow
def my_docker_flow():
    logger = get_run_logger()
    <http://logger.info|logger.info>("Hello from Docker!")


if __name__ == "__main__":
    my_docker_flow()
a

Anna Geller

08/01/2022, 8:49 PM
looks like you have overwritten the default entrypoint - can you try with a simpler Dockerfile at first, sth like this?
FROM prefecthq/prefect:2-python3.9
COPY requirements.txt .
RUN pip install -r requirements.txt
s

Seth Coussens

08/01/2022, 8:50 PM
Let me comment out the CMD in the dockerfile and see if that helps?
We do set the WORKDIR /root/workspace in the dockerfile?
a

Anna Geller

08/01/2022, 8:53 PM
you can if you want to, default is /opt/prefect
s

Seth Coussens

08/01/2022, 8:53 PM
What's the default entry point?
a

Anna Geller

08/01/2022, 8:54 PM
you shouldn't have to worry about it
s

Seth Coussens

08/01/2022, 8:54 PM
We need an ubuntu base image for some of our more complex flows (using prefect 1.0 currently), so we have to build the custom image and install prefect in it.
a

Anna Geller

08/01/2022, 8:54 PM
default entrypoint is something like "prefect engine starts your flow run"
how about multi-stage build then? you can then still leverage Prefect image
s

Seth Coussens

08/01/2022, 8:56 PM
I'm open to that, just not sure how to layer that properly.
a

Anna Geller

08/01/2022, 8:57 PM
ok I checked, if you want to build a custom image, the default entrypoint is
CMD ["python", "-m", "prefect.engine"]
s

Seth Coussens

08/01/2022, 8:58 PM
ok let me try that
a

Anna Geller

08/01/2022, 8:59 PM
or
ENTRYPOINT ["python", "-m", "prefect.engine"]
s

Seth Coussens

08/01/2022, 9:00 PM
I do see that in the deployment.yaml the command: property is already set to that, and that is what is generating the error on flow run.
a

Anna Geller

08/01/2022, 9:01 PM
yup true
command:
  - python
  - -m
  - prefect.engine
not sure what's your image is but Prefect is based on Python and Python is based on Linux, so chances are you can accomplish the same what you did on ubuntu with the Prefect image
s

Seth Coussens

08/01/2022, 9:02 PM
Correct. Let me try the base image and see if I get a different result.
🙌 1
Thanks for your help, I figured it out. I also got the RemoteFiles working with Azure. We had some custom packages that were being installed, and they relied on prefect 1.0, so they were overwriting the default package. I'll make note of that going forward.
🙌 2