pyiron / actions

A centralized location for our GitHub actions
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Be extra rigorous about using conda-forge #127

Closed liamhuber closed 1 month ago

liamhuber commented 1 month ago

Due to anaconda license terms. pyiron/actions/cached-miniforge uses miniforge and strictly uses the conda-forge channel. I'll anyhow update the defaults for these args so we are explicitly requesting the miniforge-channels and miiniforge-channel-priority from our end rather than relying on the setup-miniconda defaults being favourable (although it seems unlikely they'll change these).

liamhuber commented 1 month ago

This is a non-issue, because we already expose the underlying arguments (in case you want to set them yourself), we already override conda-incubator/setup-miniconda kwargs with our own kwargs in cached-miniconda, and these are exactly the "safe" ones that are both what we want and the current setup-miniconda defaults.

liamhuber commented 1 month ago

Nope, it looks like the mamba update call still eventually falls back to include defaults!

Screen Shot 2024-08-26 at 10 44 31
liamhuber commented 1 month ago

Hmm, except the latest cached-miniforge never explicitly calls mamba update -- now it's always setup-miniconda, so there's a possibility this is actually an upstream issue with setup-miniconda not following through...

liamhuber commented 1 month ago

Indeed, this is a known issue on conda-incubator/setup-miniconda and even a known gotcha on conda/conda.

One solution is to specify nodefaults right in your env-file....

channels:
- conda-forge
- nodefaults
dependencies:
...

But this is still sub-optimal IMO.

jan-janssen commented 1 month ago

An alternative option, is to create your own .condarc using:

echo -e "auto_update_conda: False\nauto_activate_base: True\nnotify_outdated_conda: False\nchangeps1: False\npkgs_dirs:\n  - /home/runner/conda_pkgs_dir\nchannels:\n  - conda-forge\nalways_yes: True\nsolver: libmamba" > .condarc

then you can include it in the action using:

condarc-file: .condarc

I tested this for the notebooks test in https://github.com/pyiron/pyiron_atomistics/pull/1545

liamhuber commented 1 month ago

👍 I find this preferable to having to specify channels: nodefaults in each env file. It's still ugly compared to specifying the channel right in the setup-miniconda action and actually having it read that, so I'm working on a patch for the root action there.

liamhuber commented 1 month ago

The key thing in your solution is channels:\n - conda-forge, as then the channels field is not initially empty and thus conda doesn't pre-populate it with defaults. It's possible you can then trim down the rest of the RC file and have setup-miniconda populate the rest, but I don't know what the interaction is between a provided RC file and the action arguments.

liamhuber commented 1 month ago

I opened a PR to fix it upstream.