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

fix: --import env_file potentially breaks channel priority #2113

Merged
merged 4 commits into from
Sep 23, 2024

Conversation

fecet
Copy link
Contributor

@fecet fecet commented Sep 23, 2024

The current implementation updates the extra_channels read from dependencies using the channels read from envfile, which introduces an unnecessary assumption that the entries in dependencies need to be arranged in the expected order of priority.

This may not happen in many cases. Generally speaking, channels in the env_file can be considered sorted, while dependencies are unordered. Additionally, if new channels appear in extra_channels, placing them at the end of the priority list should be a safer default behavior.

Consider the following example from https://pixi.sh/dev/advanced/channel_priority/#use-case-pytorch-and-nvidia-with-conda-forge, which generates an incorrect pixi.toml:

channels:
  - nvidia/label/cuda-11.8.0
  - nvidia
  - conda-forge
  - pytorch
  - nodefaults
dependencies:
  - pytorch::pytorch 2.0.1.*
  - pytorch::torchvision 0.15.2.*
  - pytorch::pytorch-cuda 11.8.*
  - nvidia/label/cuda-11.8.0::cuda *
  - python 3.10.*

pixi init --import will result in

[project]
authors = ["fecet <[email protected]>"]
channels = ["pytorch", "nvidia/label/cuda-11.8.0", "nvidia", "conda-forge", "nodefaults"]
description = "Add a short description here"
name = "import-bug"
platforms = ["linux-64"]
version = "0.1.0"

[tasks]

[dependencies]
pytorch = { version = "2.0.1.*", channel = "pytorch" }
torchvision = { version = "0.15.2.*", channel = "pytorch" }
pytorch-cuda = { version = "11.8.*", channel = "pytorch" }
cuda = { version = "*", channel = "nvidia/label/cuda-11.8.0" }
python = "3.10.*"

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

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

Thank you this would indeed be a better assumption!

@ruben-arts ruben-arts merged commit cf91da2 into prefix-dev:main Sep 23, 2024
39 checks passed
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.

2 participants