8000 resolve #4274 add option to remove an existing environment with 'conda create' by kalefranz · Pull Request #7133 · conda/conda · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

resolve #4274 add option to remove an existing environment with 'conda create' #7133

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

Merged
merged 5 commits into from
Apr 18, 2018

Conversation

kalefranz
Copy link
Contributor
@kalefranz kalefranz commented Apr 6, 2018

resolves #4274

This PR also introduces one new capability. The conda create command has learned a --remove-existing flag, that'll remove an existing conda environment at the target location if one already exists (rather than throwing an error).

@kalefranz kalefranz requested a review from a team as a code owner April 6, 2018 08:56
@kalefranz kalefranz force-pushed the resolve-4274 branch 2 times, most recently from 3b9aeff to d1f6b40 Compare April 9, 2018 12:11
@kalefranz kalefranz changed the title [WIP] add option to remove an existing environment with 'conda create' add option to remove an existing environment with 'conda create' Apr 9, 2018
@kalefranz kalefranz changed the title add option to remove an existing environment with 'conda create' resolve #4274 add option to remove an existing environment with 'conda create' Apr 9, 2018
@@ -4,6 +4,7 @@
import re
import sys

from conda.common.constants import NULL
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: before merge, fix this import

@kalefranz
Copy link
Contributor Author

I'm interested to have feedback on this workflow. In the original commit, I had a command flag and configuration parameter for remove_existing. In the second commit, I removed the extra flag, because it clashed with the apparent meaning of always_yes. If always_yes really does mean "always yes," then we shouldn't have an extra layer of confirmation to get in the way.

if is_conda_environment(context.target_prefix):
if paths_equal(context.target_prefix, context.root_prefix):
raise CondaValueError("The target prefix is the base prefix. Aborting.")
confirm_yn("WARNING: A conda environment already exists at '%s'\n"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: Incorporate conda.common.io.timeout into the confirm_yn() function before this PR is merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@kalefranz kalefranz force-pushed the resolve-4274 branch 2 times, most recently from 03b29be to 318e0fd Compare April 13, 2018 02:05
@kalefranz kalefranz added this to the 4.6.0 milestone Apr 13, 2018
@goanpeca
Copy link
Contributor

The original issue suggested using --force to provide this behavior. Is force not the right "concept" so the additional new flag can be avoided?

@kalefranz
Copy link
Contributor Author

I originally had a --remove-existing flag. You can see it in the first commit. After I worked through it, this workflow felt better.

I'll demo it next Wednesday and see what other people think.

@goanpeca
Copy link
Contributor
goanpeca commented Apr 13, 2018

Ok, now I am confused, so now there is no extra flag, and only forceis used instead? I see "--remove-existing" in the code still

@kalefranz
Copy link
Contributor Author

I see "--remove-existing" in the code still

Oops that's wrong. No wonder you were confused. I'll fix that.

There's no --force flag that applies here. I'm pretty close to getting rid of the --force flag completely (or hiding it in a deep dark corner). The problem is that --force is overloaded and means different things in different contexts, but often those different contexts all apply during a single conda operation. So now in master there are for example --force-reinstall, --force-remove, and --clobber flags.

The flow in this PR is that if you do conda create, and the environment already exists, we prompt to ask you if you want to delete the environment. The default answer is 'no' of course.

Signed-off-by: Kale Franz <kfranz@continuum.io>
from ..exceptions import DryRunExit
raise DryRunExit()
if context.always_yes:
return True
try:
choice = confirm(message=message, choices=('yes', 'no'),
choice = timeout(30, confirm, message=message, choices=('yes', 'no'),
Copy link
Member

Choose a reason for hiding this comment

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

The timeout should be configurable and, I guess, infinite on default for now.
It could be helpful to prevent complete stalling in unattended execution. But other times it could be annoying:
Even though conda >=4.4 has a considerably faster solving phase, there still might be situations where a user isn't actively waiting and the "grab-a-coffee-time" might exceed 30 seconds 😉.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm starting to become sensitive to configuration parameter fatigue. This is trivial enough that I'd rather not even use the timeout wrapper here then if we think it's something that needs to be configurable.

Copy link
Member

Choose a reason for hiding this comment

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

I'm starting to become sensitive to configuration parameter fatigue.

Understandable. At some point this becomes nightmare fuel 😨

Signed-off-by: Kale Franz <kfranz@continuum.io>
Copy link
Contributor
@goanpeca goanpeca left a comment

Choose a reason for hiding this comment

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

Ok, looks better now :-)

@github-actions
Copy link
github-actions bot commented Sep 3, 2021

Hi there, thank you for your contribution to Conda!

This pull request has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue or pull request if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Sep 3, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: add --force option to conda env create
3 participants
0