Skip to content

Commit 46043b4

Browse files
committed
Update from upstream. This change breaks the current caching scheme. See README.
Notable changes: - much better handling of `--using` and, more generally, building environments using other environments (for example when building an environment that is jupyter-compatible) - fixes issues related to requirements parsing -- we now offload it to packaging which does a much better job :) - fixes an issue with transmutation of Conda packages - better handling of pip/conda decorator combinations
1 parent 2675d76 commit 46043b4

File tree

13 files changed

+2630
-1384
lines changed

13 files changed

+2630
-1384
lines changed

README.md

Lines changed: 80 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ This extension currently contains:
3232
- refactored [Conda decorator](#conda-v2)
3333

3434
## Conda V2
35-
This functionality is currently being actively tested within Netflix but has not yet
36-
been deployed in production.
35+
36+
*Version 0.2.0 of this extension is not fully backward compatible with previous versions due to
37+
where packages are cached. If you are using a previous version of the extension, it is recommended
38+
that you change the `CONDA_MAGIC_FILE_V2`, `CONDA_PACKAGES_DIRNAME` and `CONDA_ENVS_DIRNAME` to
39+
new values to be able to have both versions active at the same time.*
3740

3841
It is likely to evolve primarily in its implementation as we do further testing. Feedback
3942
on what is working and what is not is most welcome.
@@ -57,7 +60,7 @@ This decorator improves several aspects of the included Conda decorator:
5760

5861
### Installation
5962
To use, simply install this package alongside the `metaflow` package. This package
60-
requires Metaflow v2.7.22 or later.
63+
requires Metaflow v2.8.3 or later.
6164

6265
#### Configuration
6366
You have several configuration options that can be set in
@@ -105,6 +108,13 @@ The useful configuration values are listed below:
105108
package not available in the preferred format will be transmuted to it automatically.
106109
If left empty, whatever package is found will be used (ie: there is no preference)
107110
- `CONDA_DEFAULT_PIP_SOURCE`: mirror to use for PIP.
111+
- `CONDA_USE_REMOTE_LATEST`: by default, it is set to `:none:` which means that if a new
112+
environment is not locally known (for example first time resolving it on the machine), it
113+
will be re-resolved. You can also set it to `:username:`, `:any:` or a comma separated
114+
list of usernames to tell Metaflow to go check if there is a cached environment that matches
115+
the requested specification that has been resolved previously by either the current user,
116+
any user or the set of users.
117+
108118

109119
##### Azure specific setup
110120
For Azure, you need to do the following two steps once during setup:
@@ -126,14 +136,9 @@ If you want support for environments containing only pip packages, you will also
126136

127137
##### Mixed (pip + conda) package support
128138
If you want support for environments containing both pip and conda packages, you will also need:
129-
- `conda-lock>=1.3.0`
139+
- `conda-lock>=2.0.0`
130140
- `lockfile`
131141

132-
It is also best to apply the
133-
PR `https://github.com/conda-incubator/conda-lock/pull/290` to `conda-lock`. This is
134-
the unfortunate result of a bug in how `conda-lock` handles packages that are both
135-
present in the `conda` environment and `pypi` one.
136-
137142
##### Support for `.tar.bz2` and `.conda` packages
138143
If you set `CONDA_PREFERRED_FORMAT` to either `.tar.bz2` or `.conda`, for some packages,
139144
we will need to transmute them from one format to the other. For example if a package
@@ -142,7 +147,8 @@ the system will transmute (convert) the `.tar.bz2` package into one that ends in
142147
`.conda`. To do so, you need to have one of the following package installed:
143148
- `conda-package-handling>=1.9.0`
144149
- `micromamba>=1.4.0` (not supported for cross-platform transmutation due to
145-
https://github.com/mamba-org/mamba/issues/2328)
150+
https://github.com/mamba-org/mamba/issues/2328 or if you are transmuting to
151+
.tar.bz2 files).
146152

147153

148154
Also due to a bug in `conda` and the way we use it, if your resolved environment
@@ -157,11 +163,10 @@ constantly improved and there are a few outstanding issues that we are aware of:
157163
(see: https://github.com/conda/conda/issues/11775). The workaround is to have
158164
`micromamba` available which does not have this issue and which Metaflow will use
159165
if it is present
160-
- `conda-lock` has issues with certain name clashes between conda and pip packages.
161-
See https://github.com/conda/conda-lock/pull/290 for more information.
162166
- Transmuting packages with `micromamba` is not supported for cross-platform
163-
transmutes due to https://github.com/mamba-org/mamba/issues/2328. Install
164-
`conda-package-handling` as well to support this.
167+
transmutes due to https://github.com/mamba-org/mamba/issues/2328. It also does
168+
not work properly when transmuting from `.conda` packages to `.tar.bz2` packages.
169+
Install `conda-package-handling` as well to support this.
165170

166171
### Uninstallation
167172
Uninstalling this package will revert the behavior of the conda decorator to the one
@@ -175,6 +180,67 @@ time, there is no method to "convert" previously resolved environment to this ne
175180
implementation so the first time you run Metaflow with this package, your previously
176181
resolved environments will be ignored and re-resolved.
177182

183+
#### Environments that can be resolved
184+
Environments listed below are examples that can be resolved using Metaflow. The environments
185+
given here are either in the `requirements.txt` format or `environment.yml` format and can,
186+
for example, be passed to `metaflow environment resolve` using the `-r` or `-f` option
187+
respectively. They highlight some of the functionalities present. Note that the same
188+
environments can also be specified directly using the `@conda` or `@pip` decorators.
189+
190+
##### Pure "pip" environment with non-python Conda packages
191+
```
192+
--conda-pkg ffmpeg
193+
ffmpeg-python
194+
```
195+
The `requirements.txt` file above will create an environment with the Pip package
196+
`ffmpeg-python` as well as the `ffmpeg` Conda executable. This is useful to have
197+
a pure pip environment (and therefore use the underlying `pip` ecosystem without
198+
`conda-lock` but still have other non Python packages installed.
199+
200+
##### Pure "pip" environment with non wheel files
201+
```
202+
--conda-pkg git-lfs
203+
# Needs LFS to build
204+
transnetv2 @ git+https://github.com/soCzech/TransNetV2.git#main
205+
# GIT repo
206+
clip @ git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1
207+
# Source only distribution
208+
outlier-detector==0.0.3
209+
# Local package
210+
foo @ file:///tmp/build_foo_pkg
211+
```
212+
The above `requirements.txt` shows that it is possible to specify repositories directly.
213+
Note that this does not work cross platform. Behind the scenes, Metaflow will build wheel
214+
packages and cache them.
215+
216+
##### Pip + Conda packages
217+
```
218+
dependencies:
219+
- pandas = >=1.0.0
220+
- pip:
221+
- tensorflow = 2.7.4
222+
- apache-airflow[aiobotocore]
223+
```
224+
The above `environment.yml` shows that it is possible to mix and match pip and conda
225+
packages. You can specify packages using "extras" but you cannot, in this form,
226+
specify pip packages that come from git repositories or from your local file-system.
227+
Pip packages that are available as wheels or source tar balls are acceptable.
228+
229+
#### General environment restrictions
230+
In general, the following restrictions are applicable:
231+
- while you can specify Conda channels in the package name (like `comet_ml::comet_ml`), you cannot,
232+
at this time, use this environment as a base for other environments. This restriction will
233+
be fixed.
234+
- you cannot specify packages that need to be built from a repository or a directory
235+
in mixed conda+pip mode. This is a restriction of the underlying tool (conda-lock) and will not
236+
be fixed until supported by conda-lock.
237+
- you cannot specify editable packages. This restriction will not be lifted at this time.
238+
- you cannot specify packages that need to be built from a repository or a directory in
239+
pip only mode across platforms (ie: resolving for `osx-arm64` from a `linux-64` machine). This
240+
restriction will not be removed as this would potentially require cross-platform build which
241+
can be tricky and error-prone.
242+
- in specifying packages, environment markers are not supported.
243+
178244
#### Additional decorator options
179245
The `conda` and `conda_base` decorators take the following additional options:
180246
- `name` and `pathspec`: An environment name or a pathspec to a previously executed

0 commit comments

Comments
 (0)