conda-minify icon indicating copy to clipboard operation
conda-minify copied to clipboard

order within environment.yml changes everytime conda-minify is called

Open noxthot opened this issue 3 years ago • 1 comments
trafficstars

When calling conda run --name base conda-minify -n dummyenv -f environment.yml the order of the output file changes every time. E.g. first call produces

name: example_environment
channels:
- conda-forge
- pytorch
dependencies:
- conda=4.12.0
- ipython=8.2.0
- tensorboard=2.8.0
- torchvision=0.12.0
- torchaudio=0.11.0
- seaborn=0.11.2
- pyyaml=6.0
- openpyxl=3.0.9
- pip=22.0.4
- autopep8=1.6.0

Next call (without any change within the environment) produces

name: example_environment
channels:
- pytorch
- conda-forge
dependencies:
- torchaudio=0.11.0
- ipython=8.2.0
- openpyxl=3.0.9
- pyyaml=6.0
- torchvision=0.12.0
- conda=4.12.0
- autopep8=1.6.0
- tensorboard=2.8.0
- seaborn=0.11.2
- pip=22.0.4

It would be nice to have a fixed order (alphabetical) of the listed dependencies to minimize diffs in version control.

According to [1] (and my experience) this is also the behaviour of conda list --export.

I am not sure about the order of the channels. Afaik the order up to date does not affect the applied channel priority when loading the file. But since the order changes every time conda-minify is called, it also might be a good idea to sort channels too.

[1] https://github.com/conda/conda/issues/7248

noxthot avatar Jun 10 '22 08:06 noxthot

Well, crap. I hadn't checked round-trip requirements. When I get some time to work on this again I will add tests.

jamespreed avatar Jun 28 '23 14:06 jamespreed