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

Respect subdir in match spec #2300

Merged
merged 4 commits into from
Jul 26, 2023
Merged

Conversation

ThomasBlauthQC
Copy link
Contributor

This PR addresses #2041 and #2226.

If a package can't be found in the specified subdir, the output now looks like this.

micromamba create -n xxx 'conda-forge/noarch::git'
...
critical libmamba Selected channel specific (or force-reinstall) job, but package is not available from channel.
...

I'm not too proficient in C++, so any feedback is highly appreciated! 🙂

cc @jonashaag

Copy link
Collaborator

@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.

So many tests 😍😍😍

Comment on lines 231 to 234
// This assumes, that explicitly specified subdirectories
// (e.g. conda-forge/linux-64::mamba) result in the platform member of needle
// only containing one entry. When the subdirectory is omitted, the paltfom
// member instead contains implicit <platform> and noarch entries.
Copy link
Collaborator

@jonashaag jonashaag Feb 16, 2023

Choose a reason for hiding this comment

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

What's a "paltfom"? 😛

Also I find this a little easier to parse:

Suggested change
// This assumes, that explicitly specified subdirectories
// (e.g. conda-forge/linux-64::mamba) result in the platform member of needle
// only containing one entry. When the subdirectory is omitted, the paltfom
// member instead contains implicit <platform> and noarch entries.
// This assumes that explicitly specified subdirectories
// (e.g. conda-forge/linux-64::mamba) result in needle.platforms.size() == 1 (e.g. needle.platforms() == {"linux-64"}). If the subdirectory is omitted from the spec, needle.platforms() is {"noarch", "<platform>"}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also like this! Not sure how useful the comment is in general, or if that is "common knowledge". I just wanted to make the == 1 comparison come a little less out of the blue.

Copy link
Member

@AntoinePrv AntoinePrv left a comment

Choose a reason for hiding this comment

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

Thanks for the PR

Comment on lines 641 to 647

template <typename PkgRange>
auto create_mrepo_with_repo_meta(PkgRange const& packages,
std::string channel_name,
std::string subdir)
{
auto const tmp_dir = dir_guard(fs::temp_directory_path() / "mamba/tests"
Copy link
Member

Choose a reason for hiding this comment

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

test_satisfiability is not meant for testing this. Would you mind movinf these new tests to a test_solver.cpp, possibly moving test utility code to a common header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, that makes a lot of sense!

@AntoinePrv AntoinePrv self-assigned this Jun 30, 2023
@jonashaag
Copy link
Collaborator

@ThomasBlauthQC do you plan on following up on this?

@ThomasBlauthQC
Copy link
Contributor Author

@AntoinePrv, @jonashaag, I'm very sorry for the delay; this fell through the cracks way too many times! I adapted the pr, the string parsing feels very hacky though... Let me know what you think!

libmamba/src/core/pool.cpp Show resolved Hide resolved
libmamba/src/core/pool.cpp Show resolved Hide resolved
libmamba/src/core/pool.cpp Outdated Show resolved Hide resolved
if (candidate_subdir == needle_subdir){
return true;
}
throw std::runtime_error(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if this is the right way to handle this case here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure myself, open for any suggestions!

@jonashaag
Copy link
Collaborator

Thanks for updating @ThomasBlauthQC!

@AntoinePrv
Copy link
Member

I adapted the pr, the string parsing feels very hacky though... Let me know what you think!

@ThomasBlauthQC thanks for working on this, however I am currently doing significant rework of the repo/pool/solver/transcaction and I would prefer a different solution that will only be possible later on.

Is this feature blocking for you? Or can it wait a couple more months?

@jonashaag
Copy link
Collaborator

Would be nice to have this earlier than in a couple of months.

@ThomasBlauthQC
Copy link
Contributor Author

I am currently doing significant rework of the repo/pool/solver/transcaction and I would prefer a different solution that will only be possible later on.

Nice! I was wondering if this could ultimately end up in libsolv but I don't understand libsolv well enough to judge if that is possible. Looking forward to the restructuring 🙂

@jonashaag
Copy link
Collaborator

@AntoinePrv if it's fine with you I'd like to merge this next week.

@jonashaag jonashaag merged commit a7cd3b6 into mamba-org:main Jul 26, 2023
20 checks passed
@ThomasBlauthQC ThomasBlauthQC deleted the subdir branch July 28, 2023 07:42
cvanelteren pushed a commit to cvanelteren/mamba that referenced this pull request Jul 31, 2023
// Subdir not specified, so any subdir is fine
return true;
}
std::string needle_subdir = rsplit(needle_channel, "/", 1)[1];
Copy link
Contributor

Choose a reason for hiding this comment

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

@jonashaag, concerning #2431, I think this is the problematic part. It assumes that if the channel name contains a slash it's because it is specifying a subdir, but pkgs/main is a valid channel name (whether we like it or not 😬). So I'd say that we add some logic after this to check whether needle_subdir is indeed a known subdir, and ignore it otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds correct. That's really unfortunate :/

Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there any known channels with / other than the official Anaconda ones? I wonder if we could get away with hardcoding them if the subdir lookup thing is too complicated to implement.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jaimergp I did some investigation. This part of the code is never run, I think because this PR collided with some other refactorings that were done. So while incorrect, it's not the cause of the bug.

Copy link
Collaborator

Choose a reason for hiding this comment

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

TIL KNOWN_PLATFORMS in channel.cpp

@@ -613,6 +613,17 @@ def test_spec_with_channel(tmp_home, tmp_root_prefix, tmp_path):
assert link["version"].startswith("0.22.")


def test_spec_with_channel_and_subdir():
Copy link
Contributor

Choose a reason for hiding this comment

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

We should extend this test to make sure pkgs/main::package_name works correctly.

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.

4 participants