Getting started¶
This getting started guide walks you through using Anaconda Project for the first time.
After completing this guide, you will be able to:
- Create a new reproducible project.
- Run the project with a single command.
- Package and share the project.
If you have not yet installed and started Project, follow the Installation instructions.
Create a new project¶
The following steps will create a project called “demo_app”:
Open a Command Prompt or terminal window.
Initialize the project in a new directory:
$ anaconda-project init -y --directory demo_app
Navigate into your project directory:
$ cd demo_app
Add the package dependencies:
$ anaconda-project add-packages python=3.8 notebook hvplot=0.7.3 panel=0.12.6 xarray=0.20 pooch=1.4 netCDF4
Create an example notebook-based Panel app¶
In this section, we will create a new notebook called
Interactive.ipynb
via either of the following methods:
Download this quickstart example:
- Right-click the link and “Save As”, naming the file
Interactive.ipynb
and saving it into your new demo_app folder, or - Use the
curl
command below. This can be used on a unix-like platform.
$ curl https://raw.githubusercontent.com/Anaconda-Platform/anaconda-project/master/examples/quickstart/Interactive.ipynb -o Interactive.ipynb
- Right-click the link and “Save As”, naming the file
Note
This example is taken from a larger, more full-featured hvPlot interactive, one that will work as well, if you would prefer to download that.
Alternatively, you can launch a Jupyter notebook session with:
$ anaconda-project run jupyter notebook
Click the New button and choose the Python3 option. Paste the following contents into a cell and click File|Save as…, naming the file
Interactive
.import xarray as xr, hvplot.xarray, hvplot.pandas, panel as pn, panel.widgets as pnw ds = xr.tutorial.load_dataset('air_temperature') diff = ds.air.interactive.sel(time=pnw.DiscreteSlider) - ds.air.mean('time') kind = pnw.Select(options=['contourf', 'contour', 'image'], value='image') plot = diff.hvplot(cmap='RdBu_r', clim=(-20, 20), kind=kind) hvlogo = pn.panel("https://hvplot.holoviz.org/assets/hvplot-wm.png", width=100) pnlogo = pn.panel("https://panel.holoviz.org/_static/logo_stacked.png", width=100) text = pn.panel("## Select a time and type of plot", width=400) pn.Column( pn.Row(hvlogo, pn.Spacer(width=20), pn.Column(text, plot.widgets()), pnlogo), plot.panel()).servable()You can exit the running Jupyter Notebook program using CTRL+C in your terminal or command line.
Run your project¶
Register a new command to launch the notebook as a Panel app:
$ anaconda-project add-command --type unix dashboard "panel serve Interactive.ipynb"
Note
The
unix
command type may be used for linux & macOS. For Windows, replace--type unix
with--type windows
Run your new project:
$ anaconda-project run dashboard --show
Your application should now be running and available at http://localhost:5006/Interactive. Once you’re finished with it, you can close the running program using CTRL+C in your terminal or command line.
Sharing your project¶
To share this project with a colleague:
Archive the project:
$ anaconda-project archive interactive.zip
Send the archive file to your colleague.
You can also share a project by uploading it to Anaconda Cloud. For more information, see Sharing a project.
Anyone with Project—your colleague or someone who downloads your project from Cloud—can run your project by unzipping the project archive file and then running a single command, without having to do any setup:
$ anaconda-project unarchive interactive.zip
$ cd demo_app
$ anaconda-project run
Note
If your project contains more than one command, the person using your project will need to specify which command to run. For more information, see Running a project.
Project downloads the data, installs the necessary packages and runs the command.
Next steps¶
- Learn more about what you can do in Project, including how to download data with your project and how to configure your project with environment variables.
- Learn more about the anaconda-project.yml format.