Skip to content

Parse and use explicit platform specifications.#1033

Merged
wolfv merged 12 commits intomamba-org:masterfrom
afranchuk:explicit-platforms
Jul 6, 2021
Merged

Parse and use explicit platform specifications.#1033
wolfv merged 12 commits intomamba-org:masterfrom
afranchuk:explicit-platforms

Conversation

@afranchuk
Copy link
Copy Markdown
Contributor

Rather than trying to figure out whether a channel string/url contains a platform, we instead make platform specification explicit with CHANNEL[PLATFORM1,PLATFORM2,...].

There is a refactor of the channel class here to hide implementation details/functions which are only relevant for testing.

This is a rework related to discussion at #934, and will close #794.

Note that this introduces breaking CLI changes as well as breaking Python API changes (the Channel class is improved), so these should be noted in the changelog.

@afranchuk
Copy link
Copy Markdown
Contributor Author

The clang-format linting failed, but it's all on files that I never touched? I automatically clang-format any files I change.

Comment thread src/mamba/py_interface.cpp Outdated
@afranchuk
Copy link
Copy Markdown
Contributor Author

The other failing tests seem to be using an installed version of mamba rather than one built from source? That's why the python tests are failing (they work if I run pytest myself).

create_args.append("--allow-softlinks", no_dry_run=True)
create_args.append("--allow-softlinks")
if always_copy:
create_args.append("--always-copy", no_dry_run=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should keep the no_dry_run=True here because we check if we're linking the packages correctly by looking at inode etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Uh, that fails when I run the test, saying you can't have keyword args in list.append? no_dry_run=True is there just below in the call to create.

@afranchuk
Copy link
Copy Markdown
Contributor Author

afranchuk commented Jun 29, 2021

@wolfv Any comment on the failing tests? Do I need to rebase on master again?

@wolfv
Copy link
Copy Markdown
Member

wolfv commented Jun 29, 2021

@afranchuk I am currently pushing a lot to get this released: openSUSE/libsolv#457

Will have to take a deep dive into this PR after.

I think some issues should be easily fixable, though (e.g. AttributeError: 'Channel' object has no attribute 'platform_urls' ...

I think there are legitimate failures.

@afranchuk afranchuk force-pushed the explicit-platforms branch from bd1430a to 14914ac Compare June 30, 2021 13:59
@afranchuk
Copy link
Copy Markdown
Contributor Author

I was able to reproduce the pytest errors (I didn't realize I had accidentally excluded them before), and I think I fixed all of them (by changing how some parts of the python code work).

@afranchuk
Copy link
Copy Markdown
Contributor Author

afranchuk commented Jun 30, 2021

I can run clang-format on everything, but it's still a bit odd that the linting for that is failing on files I never changed. Though maybe the explanation is simple: I'm using a newer version of clang-format than the CI, which differs a bit with the older versions. This explains the CI saying files change and my local clang-formatting changing many files as well. I'm not sure what the correct approach for such differences is (is there some way to make it more strictly interpret the .clang-format file?).

@afranchuk
Copy link
Copy Markdown
Contributor Author

Looks like there's still one test failing, let me see if I can track down why.

@wolfv
Copy link
Copy Markdown
Member

wolfv commented Jun 30, 2021

The CI mentions:

platform_url(): incompatible function arguments. The following argument types are supported:\\n    1. (self: mamba.mamba_api.Channel, platform: str, with_credentials: bool = True) -> str\\n\\nInvoked with: [linux-64,noarch], 'linux-64'; kwargs: with_credential=False\

@afranchuk
Copy link
Copy Markdown
Contributor Author

Bah, simple typo.

@afranchuk
Copy link
Copy Markdown
Contributor Author

Weird though, I ran the tests myself and it didn't have that error.

@wolfv
Copy link
Copy Markdown
Member

wolfv commented Jun 30, 2021

alright, looks like one remaining issue with windows for mamba: stdout = b'{\r\n "command": "C:\\Miniconda\\Scripts\\mamba create -p C:\\Users\\runneradmin\\AppData\\Local\\T...ict[split_anaconda_token(remove_auth(c))[0]]\nKeyError: 'file://d/a/mamba/mamba/test/channel_b/win-64'\n"\r\n}\r\n'

Maybe it's the trailing slash? or the // vs\\...?

@afranchuk
Copy link
Copy Markdown
Contributor Author

Yeah, unfortunately at the moment I don't have a windows machine to fix the windows errors more rapidly, but I'll try a few things.

@wolfv
Copy link
Copy Markdown
Member

wolfv commented Jun 30, 2021

I can debug it on windows on the next days if this doesn't work out :)

@afranchuk
Copy link
Copy Markdown
Contributor Author

I added some context to the exception, it looks like it's being queried with file://d/... but the actual paths are file://D:/.... I guess I'm missing some sanitization step?

@afranchuk
Copy link
Copy Markdown
Contributor Author

It's not immediately obvious what is altering the file path to d rather than D:; based on existing tests I think D: is the desired/correct path component.

@afranchuk
Copy link
Copy Markdown
Contributor Author

I think the issue is the remove_auth conda function being called, which calls parse_urls which has this: https://github.com/conda/conda/blob/33a142c16530fcdada6c377486f1c1a385738a96/conda/_vendor/urllib3/util/url.py#L186. I assume the difference is that now we use api.Channel to parse urls rather than conda's Channel, which results in a mismatch.

@afranchuk
Copy link
Copy Markdown
Contributor Author

Basically their implementation is wrong for windows file:// uris.

afranchuk added 9 commits July 1, 2021 14:55
Rather than trying to figure out whether a channel string/url contains a platform, we
instead make platform specification explicit with
`CHANNEL[PLATFORM1,PLATFORM2,...]`.

There is a refactor of the channel class here to hide implementation
details/functions which are only relevant for testing.
The python tests will probably still need some more changes.
Some of these fixes have nothing to do with the changes in this branch.
This removes the call to conda's prioritize_channels, it's not clear
whether this is actually necessary.
@afranchuk afranchuk force-pushed the explicit-platforms branch from 897c2e3 to feec101 Compare July 1, 2021 18:55
@afranchuk
Copy link
Copy Markdown
Contributor Author

Okay, looks like all that's wrong is the linting (though I can't fix that myself apparently since my clang-format disagrees with a lot). If you're okay with the workaround I did for that windows issue it should be in a good state.

@wolfv
Copy link
Copy Markdown
Member

wolfv commented Jul 1, 2021

Great work! Fixing the linting is easy for me (just run pre-commit run —all)

I’ll need to have a deep dive into this refactor. I saw that you’re using std::optional which is one thing I’m not sure about (since we need to support pretty old macOS versions) but we could quite easily refactor that to pointers or similar

@wolfv
Copy link
Copy Markdown
Member

wolfv commented Jul 2, 2021

I just ran the linter, let's see if it passes now :)

@afranchuk
Copy link
Copy Markdown
Contributor Author

Awesome! Yeah I have clang-format 12, beware of differences in the future!

Comment thread src/api/install.cpp
//
// The full license is in the file LICENSE, distributed with this software.

#include <set>
Copy link
Copy Markdown
Contributor Author

@afranchuk afranchuk Jul 2, 2021

Choose a reason for hiding this comment

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

No longer needed.

  • Remove

@wolfv
Copy link
Copy Markdown
Member

wolfv commented Jul 5, 2021

I am testing this PR right now, gonna write down observations as I go:

When using micromamba, and I have channels: [conda-forge] configured in my condarc file, I get this download:

(base) ➜  cbuild git:(explicit-platforms) ✗ micromamba create ninja -n tlinx -c "conda-forge[linux-64, noarch]"

                                           __
          __  ______ ___  ____ _____ ___  / /_  ____ _
         / / / / __ `__ \/ __ `/ __ `__ \/ __ \/ __ `/
        / /_/ / / / / / / /_/ / / / / / / /_/ / /_/ /
       / .___/_/ /_/ /_/\__,_/_/ /_/ /_/_.___/\__,_/
      /_/

Found conda-prefix at '/Users/wolfvollprecht/micromamba/envs/tlinx'. Overwrite?: [y/N] y
conda-forge/osx-arm64    [====================] (00m:00s) Done
conda-forge/noarch       [====================] (00m:02s) Done
conda-forge/noarch       [====================] (00m:02s) Done
conda-forge/linux-64     [====================] (00m:06s) Done

IMO the command line here should overwrite the other configured conda-forge config, shouldn't it?

@wolfv
Copy link
Copy Markdown
Member

wolfv commented Jul 5, 2021

  • there is currently no implicit noarch (when explicitly selecting channels).

This means this fails now like this:

(base) ➜  cbuild git:(explicit-platforms) ✗ micromamba create ninja -n tlinx -c "conda-forge33[linux-64, osx-arm64]" --override-channels

                                           __
          __  ______ ___  ____ _____ ___  / /_  ____ _
         / / / / __ `__ \/ __ `/ __ `__ \/ __ \/ __ `/
        / /_/ / / / / / / /_/ / / / / / / /_/ / /_/ /
       / .___/_/ /_/ /_/\__,_/_/ /_/ /_/_.___/\__,_/
      /_/

conda-forge33/osx-arm64  [====================] (00m:00s) 404 Failed
conda-forge33/linux-64   [====================] (00m:00s) 404 Failed
Encountered problems while solving:
  - nothing provides requested ninja

ERROR   Could not solve for environment specs

I think it would be better in this case to fail with a donwload error of some sort (which we did otherwise with the existence of the noarch channel). If we explicitly request some platforms, we coudl require that all of them resolve to something on the server..?

@wolfv
Copy link
Copy Markdown
Member

wolfv commented Jul 6, 2021

Let's fix the remaining issues on master :)

@wolfv wolfv merged commit c5f9a15 into mamba-org:master Jul 6, 2021
@afranchuk
Copy link
Copy Markdown
Contributor Author

Sounds good! As to your comments:

IMO the command line here should overwrite the other configured conda-forge config, shouldn't it?

I'm not so sure. You could certainly make a decision here about how you think it should behave, but I think the behavior you saw is okay/expected, same as if you had specified -c conda-forge[linux-64,noarch] -c conda-forge. I understand why you might want to have the behavior that you expected, but that's kind of what --override-channels is for. You could certainly make that other case work the way you expect, but I think that's more complicated and not quite as straightforward to understand.

I think it would be better in this case to fail with a donwload error of some sort (which we did otherwise with the existence of the noarch channel). If we explicitly request some platforms, we coudl require that all of them resolve to something on the server..?

This seems like an error priority issue. I'd argue that any 404 received for a configured channel should take precedence as a final user-visible error over an error that a package could not be resolved. Are there any use cases where you'd want a 404 to be ignored?

@wolfv
Copy link
Copy Markdown
Member

wolfv commented Jul 6, 2021

@afranchuk yes, if you request a channel that doesn't implement the default platform the error should be ignored.

e.g. you can use defaults from osx-arm64 but you'll only get the noarch platform. When mixing channels + platforms it's likely that it might sometimes fail

@wolfv
Copy link
Copy Markdown
Member

wolfv commented Jul 7, 2021

@afranchuk it seems that the load_channels implementation also changed slightly, correct? Would you mind detailing what I'll have to adjust in boa to make it work?

https://github.com/mamba-org/boa/blob/5482bd4a8eea22c93d7f2d87692e93f0264f9876/boa/core/solver.py#L110-L112

Currently it doesn't seem to load the noarch platform.

Maybe we could actually revert this behavior in a way that keeps boa working?

@afranchuk
Copy link
Copy Markdown
Contributor Author

afranchuk commented Jul 8, 2021

@wolfv load_channels should be functionally identical, however the index it returns is different. The index has the same first tuple items (Subdir), however the second tuple items (which used to be conda.Channel) are now a dict with the following entries:

  • channel: the mamba.Channel
  • platform: the platform name (string)
  • url: the channel url (string)

There should probably not be a tuple, opting for a subdir entry in the dict instead. But I didn't make that change because I think in a few places the dict (previously channel) is used on its own.

@wolfv
Copy link
Copy Markdown
Member

wolfv commented Jul 8, 2021

I think one problem is that when giving a platform explicitly now noarch isn't implicitly loaded. That's breaking boa right now but I'll come up with a fix tomorrow :)

@afranchuk
Copy link
Copy Markdown
Contributor Author

Oh yeah you're right, load_channels is the same but the use of mamba.Channel rather than conda.Channel changes that resolution behavior.

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.

Custom platform support

2 participants