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

Import env from yaml file #49

Closed
AlbertDeFusco opened this issue Mar 30, 2017 · 7 comments
Closed

Import env from yaml file #49

AlbertDeFusco opened this issue Mar 30, 2017 · 7 comments
Milestone

Comments

@AlbertDeFusco
Copy link
Collaborator

I'd like to convert an environment.yml file into a blank anaconda project. Is there a command like anaconda-project add-env-file to import the conda environment specification? Here's an example environment.

name: my_env
channels:
  - conda-forge
dependencies:
  - python=3
  - jupyter
  - nbformat
  - pandoc
  - bokeh
  - pygithub
  - pip:
    - pypandoc
@goanpeca
Copy link
Contributor

goanpeca commented Mar 30, 2017

@AlbertDeFusco I think that if you have an environment.yml file inside a directory/folder and then do anaconda-project init (or the right command, can't remember now) should search for that and use it.

Is not this the case @havocp ?

@havocp
Copy link
Contributor

havocp commented Mar 30, 2017

Yes, if you put environment.yml in a folder and anaconda-project init that folder it should import it. You can also cut-and-paste into an anaconda-project.yml that you have (rename dependencies to packages I think is the only format difference).

@havocp
Copy link
Contributor

havocp commented Apr 4, 2017

Are things working for you, can this issue be closed?

@AlbertDeFusco
Copy link
Collaborator Author

AlbertDeFusco commented Apr 4, 2017

Perhaps not. I created a new project in Navigator

# This is an Anaconda project file.
#
# Here you can describe your project and how to run it.
# Use `anaconda-project run` to run the project.
# The file is in YAML format, please see http://www.yaml.org/start.html for more.
#

#
# Set the 'name' key to name your project
#
name: new_proj
#
# Set the 'icon' key to give your project an icon
#
icon:
#
# In the commands section, list your runnable scripts, notebooks, and other code.
# Use `anaconda-project add-command` to add commands.
#
commands: {}
#
# In the variables section, list any environment variables your code depends on.
# Use `anaconda-project add-variable` to add variables.
#
variables: {}
#
# In the services section, list any services that should be
# available before your code runs.
# Use `anaconda-project add-service` to add services.
#
services: {}
#
# In the downloads section, list any URLs to download to local files
# before your code runs.
# Use `anaconda-project add-download` to add downloads.
#
downloads: {}
#
# In the packages section, list any packages that must be installed
# before your code runs.
# Use `anaconda-project add-packages` to add packages.
#
packages: []
#
# In the channels section, list any Conda channel URLs to be searched
# for packages.
#
# For example,
#
# channels:
#    - https://conda.anaconda.org/asmeurer
#
channels: []
#
# You can define multiple, named environment specs.
# Each inherits any global packages or channels,
# but can have its own unique ones also.
# Use `anaconda-project add-env-spec` to add environment specs.
#
env_specs: {default: {packages: [anaconda], channels: []}}

I then copy the environment.yml to the project directory.

>anaconda-project init
Environment spec 'my_env' from environment.yml is not in anaconda-project.yml.
Unable to load the project.

Is there something I have to do to register the environment name?

@havocp
Copy link
Contributor

havocp commented Apr 4, 2017

Ah, the issue is that you already have a project here when you init. I opened #53 on that, it should say "project is already initialized" or something maybe.

If you do anaconda-project anything-except-init it may ask you whether you want to import that environment. However, you'll then have default and my_env env specs, and you'll have to delete the extra one.

What should also work is if you had not initialized already, i.e. you had environment.yml and NOT anaconda-project.yml, then anaconda-project init would use the environment.yml to create the default environment in the new anaconda-project.yml.

Maybe it's simpler to just have a command like anaconda-project import environment.yml, opened #54 to think about that.

@AlbertDeFusco
Copy link
Collaborator Author

Thanks! That's what I needed. I removed the anaconda-project.yml and ran anaconda-project init. That correctly imported the env into the new project file as

env_specs: {my_env: {packages: [python=3, jupyter, nbformat, pandoc, bokeh, pygithub,
      {pip: [pypandoc]}], channels: [conda-forge]}}

@goanpeca goanpeca added this to the v0.8.2 milestone Oct 3, 2017
@goanpeca goanpeca modified the milestones: v0.8.2, v0.8.3 Oct 19, 2017
@AlbertDeFusco
Copy link
Collaborator Author

Still works

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

No branches or pull requests

3 participants