Using Anaconda Project CLI

This tutorial walks you through creating a data science project using Anaconda Enterprise with the Anaconda Project command line interface (CLI).

After completing this tutorial, you will be able to:

Before you start

  • Windows: From the Start Menu, open a new Anaconda Prompt.
  • macOS and Linux: Open a new Terminal window.

Check that you have the right version of the Anaconda Distribution by running the command conda list anaconda.

If the output shows a version older than 4.3.1, update Anaconda by running conda update anaconda.

Downloading and running a sample project

To get a sample project see the page Viewing sample projects.

When you click a sample project’s Download link, an archive file *.tar.bz2 is downloaded to your machine.

From your Anaconda Prompt, navigate to the folder where you download the file. For example on default Windows:

> cd Downloads

Expand the file using anaconda-project:

> anaconda-project unarchive <filename>

You will see a new folder that has the same name as the archive file you downloaded.

Finally, go into that directory, and run the project:

> cd <new_project>  # directory name dependent on sample project downloaded
> anaconda-project run

Creating and initializing a data science project

This procedure creates a data science project definition file named anaconda-project.yml. This file specifies scripts, notebooks, project dependencies and other project-specific information.

The project directory also has a .projectignore file that contains an optional list of files to ignore when the project is uploaded.

To create a data science project:

  1. In a terminal window, create a new directory for all of your data science project files:

    mkdir data-science-project
    
  2. Navigate to your newly created directory:

    cd data-science-project
    
  3. From within this directory, initialize your data science project by running:

    anaconda-project init
    

Customizing a data science project

By default, a data science project specifies anaconda in its runtime environment, but you can also define a customized list of conda packages and specific versions for your project to use.

To customize your data science project: use the anaconda-project command or any text editor to open the anaconda-project.yml file describing your project and edit it directly.

EXAMPLE: To add a Jupyter Notebook to the project that depends on numpy, pandas and bokeh, run the following commands:

anaconda-project add-command --type notebook default data-science-notebook.ipynb
anaconda-project add-packages numpy pandas bokeh

The resulting data science project definition file, anaconda-project.yml, contains the following information:

name: data-science-notebook

commands:
  default:
    notebook: data-science-notebook.ipynb

packages:
  - python=3.5
  - jupyter
  - numpy
  - pandas=0.19.2
  - bokeh=0.12.4

env_specs:
  default:
    channels: []
    packages: []

You can generate similar data science project definition files for projects that include scripts/models with REST APIs, as shown here:

name: quote_api
description: A simple script with an API.

commands:
  default:
    unix: python ${PROJECT_DIR}/quote.py
    windows: python %PROJECT_DIR%\quote.py
    supports_http_options: true

packages:
 - six>=1.4.0
 - gunicorn==19.1.0
 - pip:
   - python-mimeparse
   - falcon==1.0.0

env_specs:
  default:
    packages: []
    channels: []

You can also generate data science project definition files for an interactive Bokeh application, as shown here:

name: stocks_app
description: An example Bokeh application.

commands:
  default:
    bokeh_app: .

downloads:
  QUANTQUOTE: http://quantquote.com/files/quantquote_daily_sp500_83986.zip

packages:
  - bokeh=0.12.4
  - pandas=0.19.2

env_specs:
  default:
    channels: []
    packages: []

Running a data science project on your local machine

To make sure your project is defined correctly, test and run your project locally before uploading it.

To test the project on your local machine, run:

anaconda-project run

Archive and upload a data science project

After testing the project locally, you can create an archive, upload it to Anaconda Enterprise, and continue working on it there.

To create an archive, run:

anaconda-project archive ARCHIVE_FILENAME

NOTE: Replace ARCHIVE_FILENAME with the actual name of the archive file.

Then continue to the page on Uploading a project.