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

Extract environment list code into the common module to allow reuse #658

Merged
merged 9 commits into from
Oct 22, 2014

Conversation

tswicegood
Copy link
Contributor

Was curious more than anything about what it would take to extract this code and create a conda envs command in place of conda info -e. This maintains the old behavior, but adds a new envs sub-command.

@ilanschnell
Copy link
Contributor

I don't see a strong argument for adding (yet another) sub command to conda.

@tswicegood
Copy link
Contributor Author

It was just a different approach to the existing way. My first instinct to see a list of environments in conda was to type conda envs. I had to ask how to get a list to realize it was a parameter on conda info.

That's not a strong argument, but its the best I've got right now. Depending on how much you guys plan on doing with environments, this could serve as the jumping off point for interacting with them (conda envs destroy, conda envs clones, and so on).

@asmeurer
Copy link
Contributor

There are ways to do those things, but they are also buried in subcommands. It would probably be cleaner this way.

@tswicegood
Copy link
Contributor Author

As someone coming to conda from virtualenv+virtualenvwrapper, having a subcommand that's a first class way to interact with envs would make the most sense to me.

@asmeurer
Copy link
Contributor

"How do I list all envs?" seems to be a pretty common question. That to me indicates that maybe this should be a little more publicly exposed.

@ilanschnell
Copy link
Contributor

So basically conda envs would be a shortcut for invoking other existing commands.

@joelhullcio
Copy link
Contributor

+1 for this direction. I have brought this up before also. It makes sense.
conda env list - list all envs from all known env locations
conda env clone - copy an env to a new env
conda env create - create a new env
conda env remove - remove an env
conda env update - update all packages in an env
conda env zip - create a bz2 zip file of the env package meta data so the env info can be shared or archived. The create and clone commands should take the output from this command as input.

@asmeurer
Copy link
Contributor

Just so we're clear, all of these features already exist. They are just buried in subcommands (except for conda create).

@joelhullcio
Copy link
Contributor

I understand. It just seems like a cleaner interface it we group them together. Easy to adopt, understand, use, sell and document.

FWIW, I prefer "conda env" over "conda envs" but that may be a minor thing.

@tswicegood
Copy link
Contributor Author

@joelhullcio ya know, I think I do to having typed out envs a couple of times. Let me change it.

@asmeurer
Copy link
Contributor

envs only makes sense if it's the one command to list. If it's a higher level command it should be env.

@tswicegood
Copy link
Contributor Author

@asmeurer I didn't know that all of those commands already existed. I'm gonna add a subcommand parser to this and add env list and make it the default to provide the skeleton for providing a second (new?) home for those other commands.

Again, I think it just comes back to what you're coming from. In venv it's all about the environment, so working explicitly with that via a separate command it what makes sense to me.

@asmeurer
Copy link
Contributor

conda env list - list all envs from all known env locations

conda info -e

conda env clone - copy an env to a new env

conda create --clone

conda env create - create a new env

conda create

conda env remove - remove an env

conda remove --all

conda env update - update all packages in an env

conda update --all

conda env zip - create a bz2 zip file of the env package meta data so the env info can be shared or

I'm not sure about this one, but I think it might exist.

(those all require -n or -p as well)

@tswicegood
Copy link
Contributor Author

Talked with @ilanschnell a bit about this. What I'm going to do is pull the new conda env command out of this PR but leave in the refactoring of conda info, then create a conda-env package similar to conda-build. Anyone who's interested can help there, and once we've got a few more features we'll revisit the conversation about merging the command into the default install.

@tswicegood
Copy link
Contributor Author

FYI, I've created a conda-env package. It relies on the extraction of handle_envs_list in this branch to work.

This now simply extracts some code to make it more reusable.

@tswicegood tswicegood changed the title Add a conda envs command Extract environment list code into the common module to allow reuse Apr 15, 2014
From the outside, this function only needs to know whether it should be
displaying output or not.  This allows other code to use this to create
list of environments without mocking out an args object.
@tswicegood
Copy link
Contributor Author

@ilanschnell @asmeurer -- going through some older code I had written around environments. I'd really like to get this code merged in. It provides the same behavior (conda info -e works as it currently does), but it provides an API for creating a list of environments.

FWIW, this could be further refactored to break apart creating the list of environments and displaying, but that's another step. This works as an incremental step toward a more usable external API.

if prefix != config.root_dir:
acc.append(prefix)

print()
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be run if output=False.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doh -- good catch.

@asmeurer
Copy link
Contributor

Sure. This is a pretty innocuous change.

@tswicegood
Copy link
Contributor Author

Output issue with the stray print() has been fixed. This is ready to merge.

asmeurer added a commit that referenced this pull request Oct 22, 2014
Extract environment list code into the common module to allow reuse
@asmeurer asmeurer merged commit 4b05976 into conda:master Oct 22, 2014
@tswicegood
Copy link
Contributor Author

Thanks!

@tswicegood tswicegood deleted the feature/add-envs-cmd branch October 22, 2014 18:14
@github-actions
Copy link

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 Oct 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 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.

4 participants