anaconda / anaconda-project

Tool for encapsulating, running, and reproducing data science projects
https://anaconda-project.readthedocs.io/en/latest/
Other
216 stars 88 forks source link

implicit use of "defaults" channel #388

Closed AlbertDeFusco closed 1 year ago

AlbertDeFusco commented 1 year ago

This addresses #387

The "defaults" is always appended to channels: list. This is disabled by adding a dummy channel called nodefaults.

@jbednar and @jlstevens I have dev build of the implementation of nodefaults.

conda install -c defusco/label/dev anaconda-project=0.11.0+2

I am working through the current test suite and will amend it for this case as well. Here is my test:

In version 0.11.0 the following project will not prepare or lock

name: nodefaults

channels:
  - conda-forge

packages:
  - python=3.8
  - conda-token
  - ensureconda

the error from 0.11.0 is

The following packages are not available from current channels:

  - conda-token

Current channels:

  - https://conda.anaconda.org/conda-forge/osx-arm64
  - https://conda.anaconda.org/conda-forge/noarch

Note that Conda's use of nodefaults is not identical to what is done above. In Conda

  1. nodefaults can only be used within an environment.yml file
  2. instead of appending just the defaults channel all channels from users .condarc file are added

Here ONLY defaults is added, any channels provided in condarc are still ignored.

With this dev release the above YAML file will lock and prepare.

To recover the behavior of 0.11.0 add a channel called nodefaults. This will prevent defaults from being added at the end of your channels list

name: nodefaults

channels:
  - conda-forge
  - nodefaults

packages:
  - python=3.8
  - conda-token
  - ensureconda
jlstevens commented 1 year ago

Looks like backwards compatibility is (partially) restored! https://github.com/holoviz/holoviz/pull/314

I say 'partially' as we have been using nodefaults in project yamls even though it was having no effect. Clearly we (mistakenly) thought it was doing something (which is now true with this PR).

In this instance, I am happy to chalk it up to user error and this is not something we should try to maintain backwards compatibility for - having the implicit defaults is the more important fix for backwards compatibility imho than restoring the old behavior of ignoring nodefaults. Do you agree @jbednar ?

jbednar commented 1 year ago

Yep! This sounds perfect! Just need to merge and make a new release ASAP so our projects start working again!

AlbertDeFusco commented 1 year ago

Ok. I'll fix the tests and update docs

AlbertDeFusco commented 1 year ago

This will only add defaults, not all channels listed in condarc.

Also, I will fix this to not adjust channels if defaults is already present

AlbertDeFusco commented 1 year ago

I've made the change to avoid adding defaults if already present so that it won't change your priorities.

If you like please try the dev release with the latest commits

conda install -c defusco/label/dev anaconda-project=0.11.0+11