pixi icon indicating copy to clipboard operation
pixi copied to clipboard

feat: warn on pypi conda clobbering

Open nichmor opened this issue 1 year ago • 3 comments

pixi will print a warning, if for some reason a conda package was mapped wrong and we reinstall it again but as a pypi package.

Example: using this custom mapping https://gist.githubusercontent.com/nichmor/6e0b8965e948536ed278f03aac31feb0/raw/635b0b849b88530a70889c4ef2f861bcb2ecc88e/wrong_mapping.json

and having both mdurl in dependencies and pypi-dependencies

user will see following warning

Screenshot 2024-05-08 at 15 13 32

benchmarks:

[project]
name = "benchmark_hash"
version = "0.1.0"
description = "Add a short description here"
authors = ["nichmor <[email protected]>"]
channels = ["conda-forge"]
platforms = ["osx-arm64"]
conda-pypi-map = { "conda-forge" = "https://gist.githubusercontent.com/nichmor/9f2d0e5015f84c639394dfbf1c5d8cee/raw/79a2de856b835c81b2f2e78bb30933690bd7ed0b/wrong_jupterlab_mapping.json"}

[tasks]



[dependencies]
jupyterlab = "*"
detectron2 = "*"


[pypi-dependencies]
rich = "*"

with pixi.lock already present and warm cache

for ahash:

(default) graf@Nichitas-MacBook-Pro benchmark_hash % hyperfine '../../target/release/pixi install' --prepare 'rm -rf .pixi'
Benchmark 1: ../../target/release/pixi install
  Time (mean ± σ):     12.035 s ±  3.149 s    [User: 4.990 s, System: 21.933 s]
  Range (min … max):   10.001 s … 20.496 s    10 runs

for std::HashMap


(default) graf@Nichitas-MacBook-Pro benchmark_hash % hyperfine '../../target/release/pixi install' --prepare 'rm -rf .pixi'
Benchmark 1: ../../target/release/pixi install
  Time (mean ± σ):     10.753 s ±  0.611 s    [User: 4.972 s, System: 21.655 s]
  Range (min … max):    9.964 s … 11.517 s    10 runs

for std::HashMap with pre-allocated map:

(default) graf@Nichitas-MacBook-Pro benchmark_hash % hyperfine '../../target/release/pixi install' --prepare 'rm -rf .pixi'
Benchmark 1: ../../target/release/pixi install
  Time (mean ± σ):     11.482 s ±  2.112 s    [User: 4.955 s, System: 21.883 s]
  Range (min … max):    9.945 s … 16.980 s    10 runs

for ahash with pre-allocated map:

(default) graf@Nichitas-MacBook-Pro benchmark_hash % hyperfine '../../target/release/pixi install' --prepare 'rm -rf .pixi'
Benchmark 1: ../../target/release/pixi install
  Time (mean ± σ):     10.909 s ±  0.537 s    [User: 4.978 s, System: 21.892 s]
  Range (min … max):   10.065 s … 11.552 s    10 runs

so by using ahash and preallocating the map we have a win of 5% performance increase! ⬆️

nichmor avatar May 08 '24 10:05 nichmor

it's missing a warning for the usecase when we first install pypi and later conda which don't remove the pypi one and we end up with two .dist-info in site-packages

nichmor avatar May 13 '24 07:05 nichmor

Conflict it seems!

tdejager avatar May 14 '24 09:05 tdejager

Nice that you've included benchmarks! Just wondering what the cost is of doing the check as opposed to not doing it :), for these large environments?

tdejager avatar May 15 '24 17:05 tdejager

Nice that you've included benchmarks! Just wondering what the cost is of doing the check as opposed to not doing it :), for these large environments?

added benchmark in the description! but tl;dr - we add overhead of 0.100 seconds for large env

nichmor avatar May 16 '24 08:05 nichmor