conda-incubator / conda-store

Data science environments, for collaboration. ✨
https://conda.store
BSD 3-Clause "New" or "Revised" License
144 stars 46 forks source link

[BUG] - channel priority should be set to strict #737

Closed kcpevey closed 8 months ago

kcpevey commented 8 months ago

Describe the bug

In the output logs from Nebari, the channel priority is set to flexible. I also see that the channel list only includes defaults for an env where I asked for a specific channel (see sample env below). This makes me think that the config displayed is not the one that conda-store is using. If that is the case, then this can be closed and the issue becomes displaying the correct config info.

Expected behavior

I expect the channel priority to be set to strict on conda-store.

How to Reproduce the problem?

Create test env:

channels:
  - conda-forge
  - Microsoft
dependencies:
  - playwright
  - ipykernel

Note that playwright is not available on defaults or conda-forge. This environment builds successfully.

Output

Contents of conda log file on Nebari:

add_anaconda_token: True
add_pip_as_python_dependency: True
aggressive_update_packages:
  - ca-certificates
  - certifi
  - openssl
allow_conda_downgrades: False
allow_cycles: True
allow_non_channel_urls: False
allow_softlinks: False
allowlist_channels: []
always_copy: False
always_softlink: False
always_yes: None
anaconda_upload: None
auto_activate_base: True
auto_stack: 0
auto_update_conda: True
bld_path: 
changeps1: True
channel_alias: https://conda.anaconda.org
channel_priority: flexible
channel_settings: []
channels:
  - defaults
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
conda_build: {}
create_default_packages: []
croot: /opt/conda/conda-bld
custom_channels:
  pkgs/main: https://repo.anaconda.com
  pkgs/r: https://repo.anaconda.com
  pkgs/pro: https://repo.anaconda.com
custom_multichannels:
  defaults: 
    - https://repo.anaconda.com/pkgs/main
    - https://repo.anaconda.com/pkgs/r
  local: 
debug: False
default_channels:
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
default_python: 3.10
default_threads: None
deps_modifier: not_set
dev: False
disallowed_packages: []
download_only: False
dry_run: False
enable_private_envs: False
env_prompt: ({default_env}) 
envs_dirs:
  - /opt/conda/envs
  - /root/.conda/envs
error_upload_url: https://conda.io/conda-post/unexpected-error
execute_threads: 1
experimental: []
extra_safety_checks: False
fetch_threads: 5
force: False
force_32bit: False
force_reinstall: False
force_remove: False
ignore_pinned: False
json: False
local_repodata_ttl: 1
migrated_channel_aliases: []
migrated_custom_channels: {}
non_admin_enabled: True
notify_outdated_conda: True
number_channel_notices: 5
offline: False
override_channels_enabled: True
path_conflict: clobber
pinned_packages: []
pip_interop_enabled: False
pkgs_dirs:
  - /opt/conda/pkgs
  - /root/.conda/pkgs
proxy_servers: {}
quiet: False
remote_backoff_factor: 1
remote_connect_timeout_secs: 9.15
remote_max_retries: 3
remote_read_timeout_secs: 60.0
repodata_fns:
  - current_repodata.json
  - repodata.json
repodata_threads: None
report_errors: None
restore_free_channel: False
rollback_enabled: True
root_prefix: /opt/conda
safety_checks: warn
sat_solver: pycosat
separate_format_cache: False
shortcuts: True
show_channel_urls: None
signing_metadata_url_base: None
solver: classic
solver_ignore_timestamps: False
ssl_verify: True
subdir: linux-64
subdirs:
  - linux-64
  - noarch
target_prefix_override: 
track_features: []
unsatisfiable_hints: True
unsatisfiable_hints_check_depth: 2
update_modifier: update_specs
use_index_cache: False
use_local: False
use_only_tar_bz2: False
verbosity: 0
verify_threads: 1

Versions and dependencies used.

conda-store-server:2024.1.1-rc1

Anything else?

No response

nkaretnikov commented 8 months ago

@kcpevey

Thanks for your report! The relevant commit is de5c7b4, PR #693. It's also part of 2024.1.1-rc1.

Note that playwright is not available on defaults or conda-forge. This environment builds successfully.

This is because it's part of the Microsoft channel, see:

https://anaconda.org/search?q=playwright

Contents of conda log file on Nebari: [...]

It's not the full log. There should be more relevant information after the conda config commands.

I've just built your environment locally with conda-store on the same tag, it prints the following:

CONDA_FLAGS=--strict-channel-priority

This is the same as setting strict via the config. It's used in action_solve_lockfile, which uses conda-lock.

The reason we do it this way is because conda-store needs to work in standalone mode. We don't modify global configuration options because it might interfere with user settings.

Also, there might be some confusion with what "strict" actually means. From the docs:

With strict channel priority, packages in lower priority channels are not considered if a package with the same name appears in a higher priority channel.

Note the "appears" part. This doesn't say anything about packages that are missing from the high priority channel. So it just uses the first channel where the package is available, which is Microsoft in this case.

To be sure, I've also successfully built the same environment locally directly with conda, using strict:

cat env.yaml:

channels:
- conda-forge
- Microsoft
dependencies:
- playwright
- ipykernel
- pip:
  - nothing
description: ''
name: test1
prefix: null
% conda config --get channel_priority
--set channel_priority strict

% conda env create -f env.yaml

If you remove Microsoft from the channels list, the environment will fail to solve.

This command can be used to check the channel that was used to install the package:

% conda list --explicit | grep playwright
https://conda.anaconda.org/Microsoft/linux-64/playwright-1.41.1-py312_0.tar.bz2

So it seems to me this is working as intended. I'm going to close this issue. Please feel free to reopen if you think that more work is needed here.