Has anyone seen the error: `'prefect.engine' is a ...
# prefect-community
s
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:
Copy code
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:
Copy code
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
looks like you have overwritten the default entrypoint - can you try with a simpler Dockerfile at first, sth like this?
Copy code
FROM prefecthq/prefect:2-python3.9
COPY requirements.txt .
RUN pip install -r requirements.txt
s
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
you can if you want to, default is /opt/prefect
s
What's the default entry point?
a
you shouldn't have to worry about it
s
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
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
I'm open to that, just not sure how to layer that properly.
a
ok I checked, if you want to build a custom image, the default entrypoint is
Copy code
CMD ["python", "-m", "prefect.engine"]
s
ok let me try that
a
or
Copy code
ENTRYPOINT ["python", "-m", "prefect.engine"]
s
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
yup true
Copy code
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
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