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

Use a quicker example for the channel-inversion test #688

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions tests/test-channel-inversion/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ channels:
# In this case we have the channel order as recommended by rapids ai for
# installing cudf, but we want to force getting cuda-python from conda-forge
# instead of from the nvidia channel which would normally have higher priority
- rapidsai
- nvidia
- conda-forge
- defaults
dependencies:
- cudf
- conda-forge::cuda-python
- zlib
- defaults::libgomp
22 changes: 15 additions & 7 deletions tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,22 +1665,30 @@ def test_poetry_version_parsing_constraints(
def test_run_with_channel_inversion(
monkeypatch: "pytest.MonkeyPatch", channel_inversion: Path, mamba_exe: str
):
"""Given that the cuda_python package is available from a few channels
and three of those channels listed
and with conda-forge listed as the lowest priority channel
and with the cuda_python dependency listed as "conda-forge::cuda_python",
ensure that the lock file parse picks up conda-forge as the channel and not one of the higher priority channels
"""Given that the libgomp package is available from a few channels
and two of those channels listed
and with defaults listed as the lowest priority channel
and with the libgomp dependency listed as "defaults::libgomp",
ensure that the lock file parse picks up "defaults" as the channel and not
the higher priority conda-forge channel.
"""
monkeypatch.chdir(channel_inversion.parent)
run_lock([channel_inversion], conda_exe=mamba_exe, platforms=["linux-64"])
lockfile = parse_conda_lock_file(channel_inversion.parent / DEFAULT_LOCKFILE_NAME)
for package in lockfile.package:
if package.name == "cuda-python":
if package.name == "zlib":
ms = MatchSpec(package.url) # pyright: ignore
assert ms.get("channel") == "conda-forge"
break
else:
raise ValueError("cuda-python not found!")
raise ValueError("zlib not found!")
for package in lockfile.package:
if package.name == "libgomp":
ms = MatchSpec(package.url) # pyright: ignore
assert ms.get("channel") == "defaults"
break
else:
raise ValueError("libgomp not found!")


def _make_spec(name: str, constraint: str = "*"):
Expand Down
Loading