You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* WIP pyproject toml support
* Docstrings
* Some docs
* Tests
* More tests
* Add link
* Fix install order mistake in docs
* Add support for installing local projects
* Add option to disable automatic requirements detection
* Fix some more conditions
* Local project installation docs
* Small docs and exception updates
* Remove wrong link
* Add enum to check
* Disable automatic detection by default
* Improve docs and log
* Adjust test to new default
Copy file name to clipboardExpand all lines: docs/book/how-to/containerization/containerization.md
+65-28Lines changed: 65 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -245,65 +245,102 @@ ZenML offers several ways to specify dependencies for your Docker containers:
245
245
246
246
### Python Dependencies
247
247
248
+
By default, ZenML automatically installs all packages required by your active ZenML stack.
249
+
250
+
{% hint style="warning" %}
251
+
In future versions, if none of the `replicate_local_python_environment`, `pyproject_path` or `requirements` attributes on `DockerSettings` are specified, ZenML will try to automatically find a `requirements.txt` and `pyproject.toml` files inside your current source root and install packages from the first one it finds. You can disable this behavior by setting `disable_automatic_requirements_detection=True`. If
252
+
you already want this automatic detection in current versions of ZenML, set `disable_automatic_requirements_detection=False`.
This will run `pip freeze` to get a list of the installed packages in your local Python environment and will install them in the Docker image. This ensures that the same
266
+
exact dependencies will be installed.
267
+
{% hint style="warning" %}
268
+
This does not work when you have a local project installed. To install local projects, check out the `Install Local Projects` section below.
269
+
{% endhint %}
270
+
2. **Specify a `pyproject.toml` file**:
249
271
250
272
```python
251
-
# Use pip freeze (outputs a requirements file with exact package versions)
252
-
from zenml.config import DockerSettings, PythonEnvironmentExportMethod
This feature allows you to easily replicate your local Python environment in the Docker container, ensuring that your pipeline runs with the same dependencies.
273
-
2. **Specify Requirements Directly**:
280
+
By default, ZenML will try to export the dependencies specified in the `pyproject.toml` by trying to run `uv export` and `poetry export`.
281
+
If both of these commands do not work for your `pyproject.toml` file or you want to customize the command (for example to install certain
282
+
extras), you can specify a custom command using the `pyproject_export_command` attribute. This command must output a list of requirements following the format of the [requirements file](https://pip.pypa.io/en/stable/reference/requirements-file-format/). The command can contain a `{directory}` placeholder which will be replaced with the directory in which the `pyproject.toml` file is stored.
You can combine these methods but do make sure that your list of requirements does not overlap with ones specified explicitly in the Docker settings to avoid version conflicts.
299
-
{% endhint %}
324
+
7. **Install Local Projects**:
325
+
If your code requires the installation of some local code files as a python package, you can specify a command
Installing a local python package only works if your code files are included in the Docker image, so make sure you have
333
+
`allow_including_files_in_images=True`in your Docker settings. If you want to instead use the [code download functionality](#source-code-management)
334
+
to avoid building new Docker images for each pipeline run, you can follow [this example](https://github.com/zenml-io/zenml-patterns/tree/main/docker-local-pkg).
335
+
{% endhint %}
300
336
301
337
Depending on the options specified in your Docker settings, ZenML installs the requirements in the following order (each step optional):
302
338
303
339
1. The packages installed in your local Python environment
304
340
2. The packages required by the stack (unless disabled by setting `install_stack_requirements=False`)
305
341
3. The packages specified via the `required_integrations`
306
-
4. The packages specified via the `requirements` attribute
342
+
4. The packages defined in the pyproject.toml file specified by the `pyproject_path` attribute
343
+
5. The packages specified via the `requirements` attribute
0 commit comments