Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple env yaml specs #2993

Merged
merged 11 commits into from
Dec 19, 2023
Merged

Conversation

jchorl
Copy link
Contributor

@jchorl jchorl commented Nov 19, 2023

Tested:

testmultiyml/env1.yml

channels:
  - conda-forge
dependencies:
  - python >=3.12

testmultiyml/env2.yml

channels:
  - conda-forge
dependencies:
  - pandas >=2.1.1
(mamba) mambauser@6eb769d94efc:/work$ ./build/micromamba/micromamba create -n multiymltest -f testmultiyml/env1.yml -f testmultiyml/env2.yml 
(mamba) mambauser@6eb769d94efc:/work$     micromamba activate multiymltest
(multiymltest) mambauser@6eb769d94efc:/work$ python3
Python 3.12.0 | packaged by conda-forge | (main, Oct  3 2023, 08:43:22) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd

Not sure if there's other edge cases worth considering or test cases that would be helpful.

@jonashaag
Copy link
Contributor

Thanks for working on this!

This definitely needs more tests and coverage of edge cases.

Some things that come to mind, not an exhaustive list:

  • conflicting specs
  • conflicting channels (defaults vs nodefaults)
  • conflicting channel priorities
  • missing entries in one of the files
  • passing non env.yml files as one of the files (should probably error)

@jchorl
Copy link
Contributor Author

jchorl commented Dec 7, 2023

Thanks for working on this!

This definitely needs more tests and coverage of edge cases.

Some things that come to mind, not an exhaustive list:

* conflicting specs

* conflicting channels (defaults vs nodefaults)

* conflicting channel priorities

* missing entries in one of the files

* passing non env.yml files as one of the files (should probably error)

Thanks. These are great suggestions. I found a bit more time today to work on this.

General thought: It would be good to understand what new testing you feel is required just for multi-yaml-spec support. Happy to add more if you feel it makes sense. Thanks for the help thus far!

Re specific tests:

First, I modified the multi-spec test to properly handle multiple yamls.

conflicting channels (defaults vs nodefaults)

I did write a test for this (removed after): test_multiple_yaml_specs_conflicting_defaults.

I ran this through micromamba:

micromamba install -n base pandas -c nodefaults -c defaults

This actually works. This makes me think the check for conflicting defaults belongs at a lower layer, not multi-yaml-spec parsing. Thoughts?

conflicting channel priorities

I don't think yaml specs support channel_priority: conda/conda#8675

If you point me at docs or anything, happy to add a test here.

missing entries in one of the files

I wasn't sure what you meant here. I added test_multiple_yaml_specs_only_one_has_channels whereby only one yaml specifies the channels. The result is the union of all channels (so, only the one channel from the one yaml) but all the deps get concatted. This is expected/desirable to me. Did you mean to test for something else?

passing non env.yml files as one of the files (should probably error)

done! added a test too.

for (auto& file : file_specs)
{
// read specs from file :)
if (is_env_lockfile_name(file))
{
if (spec_type != mamba::detail::unknown && spec_type != mamba::detail::env_lockfile) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that we are duplicating the type checks and that we are mixing type checking and type "inference". Maybe it's cleaner to use a separate type check loop

micromamba/tests/test_create.py Outdated Show resolved Hide resolved
micromamba/tests/test_create.py Outdated Show resolved Hide resolved
micromamba/tests/test_create.py Outdated Show resolved Hide resolved
@jonashaag
Copy link
Contributor

Looks pretty good already. What happens if you specify conflicting specs in the files? eg. python=3.11 and python=3.10. Is the error message helpful?

@jchorl
Copy link
Contributor Author

jchorl commented Dec 8, 2023

Looks pretty good already. What happens if you specify conflicting specs in the files? eg. python=3.11 and python=3.10. Is the error message helpful?

Tried:

(mamba) root@068e7d994f42:/work# printf 'dependencies: [pandas==1.5.3]\nchannels: [conda-forge]' > spec1.yml
(mamba) root@068e7d994f42:/work# printf 'dependencies: [pandas==2.1.3]\nchannels: [conda-forge]' > spec2.yml
(mamba) root@068e7d994f42:/work# ./build/micromamba/micromamba create -y -n joshtest -f spec1.yml -f spec2.yml 
conda-forge/linux-64                                        Using cache
conda-forge/noarch                                          Using cache
error    libmamba Could not solve for environment specs
    The following packages are incompatible
    ├─ pandas 1.5.3  is requested and can be installed;
    └─ pandas 2.1.3  is not installable because it conflicts with any installable versions previously reported.
critical libmamba Could not solve for environment specs

It's similar (but not identical!) to just passing cli specs:

(mamba) root@068e7d994f42:/work# ./build/micromamba/micromamba install pandas==1.5.3 pandas==2.1.3 -c conda-forge
conda-forge/linux-64                                        Using cache
conda-forge/noarch                                          Using cache

Pinned packages:
  - python 3.12.*

error    libmamba Could not solve for environment specs
    The following packages are incompatible
    ├─ pandas 1.5.3  is installable with the potential options
    │  ├─ pandas 1.5.3 would require
    │  │  └─ python >=3.10,<3.11.0a0 , which can be installed;
    │  ├─ pandas 1.5.3 would require
    │  │  └─ python >=3.11,<3.12.0a0 , which can be installed;
    │  ├─ pandas 1.5.3 would require
    │  │  └─ python >=3.8,<3.9.0a0 , which can be installed;
    │  └─ pandas 1.5.3 would require
    │     └─ python >=3.9,<3.10.0a0 , which can be installed;
    └─ pin-1 is not installable because it requires
       └─ python 3.12.* , which conflicts with any installable versions previously reported.
critical libmamba Could not solve for environment specs

@jchorl
Copy link
Contributor Author

jchorl commented Dec 8, 2023

I think it should be ready for another look!

Copy link
Contributor

@jonashaag jonashaag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice thank you!

@jonashaag jonashaag added this pull request to the merge queue Dec 9, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 9, 2023
@jonashaag jonashaag added this pull request to the merge queue Dec 9, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 9, 2023
@jonashaag jonashaag added this pull request to the merge queue Dec 10, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Dec 10, 2023
@AntoinePrv AntoinePrv added this pull request to the merge queue Dec 18, 2023
@AntoinePrv
Copy link
Member

Sorry @jonashaag for the fail merge attempts. I was experimenting with this merge queue, but it seems not to be working well. Giving it a last try or I will remove the setting.

@AntoinePrv AntoinePrv removed this pull request from the merge queue due to a manual request Dec 18, 2023
@AntoinePrv AntoinePrv enabled auto-merge December 18, 2023 10:54
@AntoinePrv AntoinePrv closed this Dec 18, 2023
auto-merge was automatically disabled December 18, 2023 13:09

Pull request was closed

@AntoinePrv AntoinePrv reopened this Dec 18, 2023
@AntoinePrv AntoinePrv merged commit 57a6a69 into mamba-org:main Dec 19, 2023
48 of 54 checks passed
@AntoinePrv
Copy link
Member

Thank you for your patience @jchorl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants