Open jlstevens opened 3 years ago
It looks like there is some room for improvement here, but I would say it's not recommended to use both packages
and dependencies
. I would recommend that you must match the package spec key between global and env-spec. Note that dependencies
is preferred as of version 0.9.1 and will ignore packages
if both are found.
I have enumerated three working scenarios.
name: lock-deps
dependencies:
- python=3.7.6
platforms:
- linux-64
- osx-64
- win-64
env_specs:
default: {}
test:
dependencies:
- pytest
> anaconda-project lock
> grep pytest anaconda-project-lock.yml
- pytest=6.2.3=py37h06a4308_2
- pytest=6.2.3=py37hecd8cb5_2
- pytest=6.2.3=py37haa95532_2
name: lock-deps
packages:
- python=3.7.6
platforms:
- linux-64
- osx-64
- win-64
env_specs:
default: {}
test:
packages:
- pytest
> anaconda-project lock
> grep pytest anaconda-project-lock.yml
- pytest=6.2.3=py37h06a4308_2
- pytest=6.2.3=py37hecd8cb5_2
- pytest=6.2.3=py37haa95532_2
Here is a backwards compatible anaconda-project.yml
file that can also serve as a valid environment.yml
file. If dependencies
is left off of the env_spec: test
key you will get the failure specified.
name: lock-deps
packages: &pkgs
- python=3.7.6
dependencies: *pkgs
platforms:
- linux-64
- osx-64
- win-64
env_specs:
default: {}
test:
packages: &testpkgs
- pytest
dependencies: *testpkgs
> anaconda-project lock
> grep pytest anaconda-project-lock.yml
- pytest=6.2.3=py37h06a4308_2
- pytest=6.2.3=py37hecd8cb5_2
- pytest=6.2.3=py37haa95532_2
Thanks. I don't know why anaconda-project ever used a different name for the package list than conda did, but because of that and because we work with clients who are tied to older anaconda-project versions due to the commercial software involved, we try to support any anaconda-project and conda version where possible. It looks like your last recipe there will let us do that. Ideally a-p would warn if packages
and dependencies
differ when both are present, to detect a problem like that.
I would be in favor of a warning as Jim suggests (when there is a conflict) but otherwise I am happy with Albert's recommendations.
While working on https://github.com/pyviz-topics/examples/pull/145 I found that the output of
anaconda-project lock
has changed since version 0.8.2 given the sameanaconda-project.yml
.If you use 0.8.2 the
test
environment in theenv_spec
is locked and re-created properly. But in 0.9.0 and 0.9.1 thepytest
package no longer appears anywhere in the lock file.