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

feat: add import yml flag #792

Merged
merged 12 commits into from
Feb 22, 2024

Conversation

Wackyator
Copy link
Contributor

Adds the functionality to import environment.yml during pixi init.
Closes #131

src/cli/init.rs Outdated Show resolved Hide resolved
@wolfv
Copy link
Member

wolfv commented Feb 8, 2024

What does the usage look like? Maybe we can already add a little bit to the docs? :) Awesome feature!

@Wackyator
Copy link
Contributor Author

What does the usage look like? Maybe we can already add a little bit to the docs? :) Awesome feature!

$ pixi init -i /path/to/environment.yml

Co-authored-by: Bas Zalmstra <[email protected]>
src/cli/init.rs Outdated Show resolved Hide resolved
docs/cli.md Show resolved Hide resolved
src/cli/init.rs Outdated Show resolved Hide resolved
src/cli/init.rs Outdated Show resolved Hide resolved
src/cli/init.rs Outdated Show resolved Hide resolved
src/cli/init.rs Outdated Show resolved Hide resolved
src/cli/init.rs Outdated
@@ -131,6 +225,18 @@ pub async fn execute(args: Args) -> miette::Result<()> {
);
}

if args.env_file.is_some() {
// Install prefix if coming from an environment file
let project = Project::load_or_else_discover(Some(&dir.join(consts::PROJECT_MANIFEST)))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems strange to me. We just created the project above!

src/cli/init.rs Outdated Show resolved Hide resolved
@ruben-arts
Copy link
Contributor

ruben-arts commented Feb 20, 2024

Use this feature to benchmark :

Benchmark 1: pixi init -i environment-dev-extra.yml
  Time (mean ± σ):      1.686 s ±  0.022 s    [User: 3.009 s, System: 3.709 s]
  Range (minmax):    1.662 s 1.736 s    10 runs
 
Benchmark 2: micromamba create --file environment-dev-extra.yml -p ./.env --yes
  Time (mean ± σ):      5.688 s ±  0.137 s    [User: 11.266 s, System: 1.676 s]
  Range (minmax):    5.485 s 5.885 s    10 runs
 
Benchmark 3: conda env create -f environment-dev-extra.yml -p ./.env
  Time (mean ± σ):     46.115 s ±  5.999 s    [User: 43.808 s, System: 1.861 s]
  Range (minmax):   39.113 s59.391 s    10 runs
 
Summary
  pixi init -i environment-dev-extra.yml ran
    3.37 ± 0.09 times faster than micromamba create --file environment-dev-extra.yml -p ./.env --yes
   27.35 ± 3.58 times faster than conda env create -f environment-dev-extra.yml -p ./.env
pixi 0.14.0
micromamba 1.5.1
conda 4.13.0

@baszalmstra
Copy link
Contributor

Nice! And thats including generating a lock-file!

Did you have warm or cold caches?

@ruben-arts
Copy link
Contributor

ruben-arts commented Feb 20, 2024

hyperfine --warmup 1 --prepare 'rm pixi.* .pixi -rf' 'pixi init -i environment-dev-extra.yml' --prepare 'rm ./.env -r' 'micromamba create --file environment-dev-extra.yml -p ./.env --yes' --prepare 'rm ./.env -r' 'conda env create -f environment-dev-extra.yml -p ./.env'

This was the command including the warmup command, so the caches are blazingly hot.

That includes generating the environment( and lock for pixi). Pixi also does the translation from env.yml to pixi.toml. But that is too fast to measure in this scale.

@ruben-arts
Copy link
Contributor

ruben-arts commented Feb 20, 2024

That was with conda 4.13, latest is conda 24.1.1 So I reran it:

Benchmark 1: pixi init -i environment-dev-extra.yml
  Time (mean ± σ):      1.747 s ±  0.046 s    [User: 3.033 s, System: 3.713 s]
  Range (minmax):    1.670 s 1.787 s    5 runs                            
                      
Benchmark 2: micromamba create --file environment-dev-extra.yml -p ./.env --yes
  Time (mean ± σ):      6.516 s ±  0.338 s    [User: 12.660 s, System: 1.949 s]
  Range (minmax):    6.198 s 6.900 s    5 runs
 
Benchmark 3: conda env create -f environment-dev-extra.yml -p ./.env
  Time (mean ± σ):     17.895 s ±  0.212 s    [User: 16.057 s, System: 1.725 s]
  Range (minmax):   17.743 s18.266 s    5 runs
 
Summary
  pixi init -i environment-dev-extra.yml ran
    3.73 ± 0.22 times faster than micromamba create --file environment-dev-extra.yml -p ./.env --yes
   10.24 ± 0.30 times faster than conda env create -f environment-dev-extra.yml -p ./.env

Command:

hyperfine --warmup 1 --runs 5 --prepare 'rm pixi.* .pixi -rf' 'pixi init -i environment-dev-extra.yml' --prepare 'rm ./.env -r' 'micromamba create --file environment-dev-extra.yml -p ./.env --yes' --prepare 'rm ./.env -r' 'conda env create -f environment-dev-extra.yml -p ./.env' 

Versions:

pixi 0.14.0
micromamba 1.5.1
conda 24.1.1

Copy link
Contributor

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

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

I think it would be good to crawl github a little for environment.yml files and seeing if we can actually import them.

@ruben-arts ruben-arts merged commit c30640e into prefix-dev:main Feb 22, 2024
15 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.

Support bootstrapping a pixi config from environment.yml
4 participants