<@ULVA73B9P> I have python code that relies on a b...
# ask-marvin
k
@Marvin I have python code that relies on a binary package that has conflicting dependencies with the prefecthq/prefect:2-python3.10 docker image. I am running flows by copying them into a single docker image. Normally, I would just add that binary to our Dockerfile used to run all of the flows. Given the conflicting dependency, how do you suggest that I run my flow?
m
When dealing with conflicting dependencies in a Python project running with Prefect, you typically have a few options: 1. Pip Install at Runtime: Using the step
prefect.deployments.steps.pip_install_requirements
in the deployment pull step to install your dependencies at runtime is an option. However, if the installation requires compiling code or other expensive operations, this might not be the best approach. 2. Build a Custom Docker Image: A more robust solution would be to build a custom Docker image. You can base it off one of the Prefect-provided
prefecthq/prefect
images, or create your entirely custom image that includes all required dependencies, making sure it resolves any conflicts manually. When using a custom Docker image, Prefect will take advantage of the storage block to upload your project into a portable structure that can be run within any compatible Python environment. This approach would prevent the "module not found" type of errors for your relative imports and conflicting dependencies. To assist you better with building a custom Docker image, here's a guide by Prefect on using Docker for work pool deployment: Work pool deployment guide. Creating a custom Docker image tailored to your flow's needs should circumvent any issues with conflicting dependencies and allow you to include the binary package your code relies on. Remember to manage your Docker image efficiently to ensure it doesn't become bloated and remains secure.