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

Support --prune flag in 'mamba install' #688

Closed
LunarLanding opened this issue Feb 9, 2021 · 6 comments · Fixed by #1343
Closed

Support --prune flag in 'mamba install' #688

LunarLanding opened this issue Feb 9, 2021 · 6 comments · Fixed by #1343
Labels

Comments

@LunarLanding
Copy link

Matching changes done to channel/package specs to an environment could be done efficiently by supporting the prune flag properly; however conda env --prune [...] takes in account the history of conda install commands, and while a fix is in the works, it is taking a very long time (the issue was first reported in 2018 : conda/conda#7279 ).
The current workaround is deleting and recreating the environment. Given how fast mamba is at solving plus caching, this works for now. In fact the only package I recall ever taking a long time to setup is jupyter, with its build step.
Either way, I wonder if it would be possible to support --prune directly in mamba install. Perhaps with a different name to not cause confusion ('-sync'?).

@adriendelsalle adriendelsalle added the type::feature-request New feature proposal label Jun 4, 2021
@ahgraber
Copy link

Does #327 enable the --prune flag?

@wolfv
Copy link
Member

wolfv commented Jun 30, 2021

@LunarLanding you're mentioning mamba install but are you actually referring to mamba env update? Because I cannot really see how we'd prune with a regular install.

For mamba env update we could implement a prune flag which would basically just re-solve the environment from scratch, removing all packages that are there.

@wolfv wolfv mentioned this issue Jun 30, 2021
17 tasks
@LunarLanding
Copy link
Author

LunarLanding commented Jul 1, 2021

@ahgraber sorry haven't had the time to test it yet.
@wolfv either needs a source of truth, yes.

I mentioned mamba install because at some point I was using it for its different behavior regarding respecting channels in specs; I fed it the environment spec via arguments; but that's a different unrelated issue.
For mamba env the source of truth would come from --file environment.yml.

The process would be as you say: solve directly from source of truth (=environment file) to get a package spec (fast), leave already installed packages as is, remove those not in the spec, install the ones that are not present in the installation.

@LunarLanding
Copy link
Author

@ahgraber I just tested. Removing a package with no dependencies from the environment file and then running mamba env update --prefix $PREFIX --file environment.yml --prune does not uninstall it.

@wolfv
Copy link
Member

wolfv commented Jul 21, 2021

@LunarLanding we haven't worked on this yet.

You're welcome to give this a hand! I think it shouldn't be too hard to add that flag to mamba_env.py -- just resolve the entire environment.

@LunarLanding
Copy link
Author

@wolfv thanks for the clarification, it's understandable; and thanks for the pointer, I initally thought I would have to touch the C implementation, but if it's doable via python then I'll try it.

adament added a commit to adament/mamba that referenced this issue Dec 10, 2021
This fixes mamba-org#688 and the similar issue for conda conda/conda#7279.

The prune flag is implemented by running the solver as if it was given
an empty prefix and then computing the diff between the current prefix
and the newly solved target and executing those resulting links and
unlinks.

This assumes that it is always possible to transform a given prefix to
any other consistent set of packages, since the solver never sees the
list of currently installed packages.

Furthermore a small fix for leaking temporary files is included.
adament added a commit to adament/mamba that referenced this issue Dec 10, 2021
This fixes mamba-org#688 and the similar issue for conda conda/conda#7279.

The prune flag is implemented by running the solver as if it was given
an empty prefix and then computing the diff between the current prefix
and the newly solved target and executing those resulting links and
unlinks.

This assumes that it is always possible to transform a given prefix to
any other consistent set of packages, since the solver never sees the
list of currently installed packages.

Furthermore a small fix for leaking temporary files is included.
adament added a commit to adament/mamba that referenced this issue Dec 10, 2021
This fixes mamba-org#688 and the similar issue for conda conda/conda#7279.

The prune flag is implemented by running the solver as if it was given
an empty prefix and then computing the diff between the current prefix
and the newly solved target and executing those resulting links and
unlinks.

This assumes that it is always possible to transform a given prefix to
any other consistent set of packages, since the solver never sees the
list of currently installed packages.

Furthermore a small fix for leaking temporary files is included.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants