Julien
08/04/2025, 4:16 PMMarvin
08/04/2025, 4:17 PMMarvin
08/04/2025, 4:18 PMpyproject.toml
file that specifies your dependencies. For example:
toml
[project]
name = "your-project-name"
dependencies = [
"your-dependencies-here"
]
[tool.uv]
package = false # Optional: if you want to use uv for dependency management only
2. In your prefect.yml
, you can reference the dependencies in two ways:
yaml
deployments:
- name: your-deployment
entrypoint: "path/to/your/flow.py:flow_function"
work_pool:
name: your-workpool
# Option 1: Use pull steps to set up the environment
pull:
- prefect.deployments.steps.set_working_directory:
directory: "." # Directory containing your pyproject.toml
- prefect.deployments.steps.run_shell_script:
script: "uv pip install -e ."
# Option 2: Specify dependencies directly
dependencies:
- -r pyproject.toml # This will use the dependencies from pyproject.toml
Important notes:
1. Make sure your deployment environment has uv installed and available in the PATH.
2. If you're using Docker, include the uv installation and dependency sync in your Dockerfile:
Dockerfile
FROM python:3.11
# Install uv
RUN curl -LsSf <https://astral.sh/uv/install.sh> | sh
WORKDIR /app
COPY pyproject.toml .
RUN uv pip install -e .
3. Be aware that there are some known issues:
- Some Prefect configuration settings in pyproject.toml might not be respected (as noted in issue #16044)
- There might be version conflicts with uv itself if Prefect has it as a dependency (issue #18552)
Best Practices:
1. Always test your dependency setup in a local environment first
2. Use explicit versions in your pyproject.toml to avoid unexpected behavior
3. Consider using a requirements.lock or uv.lock file for reproducible builds
4. If you encounter issues, try using the pull
steps method as it gives you more control over the environment setup process
Would you like me to elaborate on any of these points or provide more specific examples for your use case?