Skip to content

Commit

Permalink
Merge pull request #688 from maresb/faster-channel-inversion-test
Browse files Browse the repository at this point in the history
Use a quicker example for the channel-inversion test
  • Loading branch information
maresb authored Sep 10, 2024
2 parents 57f1906 + b272ad5 commit 886b474
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
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

0 comments on commit 886b474

Please sign in to comment.