Configuring custom environments and sample projects#
When you create a new project in Anaconda Enterprise, you must select a base environment for the project. Anaconda provides several base Anaconda environments, along with Python, R, or Hadoop-Spark environments for you to choose from.
If these environments do not suit your needs, you can create a custom environment, then include it in the list of environments that are available upon project creation.
Preparing to create custom environments#
Caution
Custom environments must be created using a machine with platform architecture identical to your instance of Anaconda Enterprise.
Connect to the machine you are using to create environments.
If necessary, install the
bzip2
utility by running the following command:yum install bzip2
If necessary, install the
wget
utility by running the following command:yum install wget
If necessary, update or install miniconda.
Update miniconda by running the following commands:
conda deactivate conda update -y --all conda update -y -n base -c defaults conda
Create the directory for miniconda by running the following command:
mkdir -p ~/miniconda3
Download the miniconda installer and rename it
miniconda.sh
by running the following command:wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
Verify your checksum by running the following command:
sha256sum ~/miniconda3/miniconda.sh
Install miniconda by running the following command:
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
Remove the miniconda installer by running the following command:
rm -rf ~/miniconda3/miniconda.sh
View your Linux shell by running the following command:
echo $SHELL
Initialize miniconda by running the following command:
# Replace <SHELL> with the return from the previous command ~/miniconda3/bin/conda init <SHELL>
For example:
~/miniconda3/bin/conda init bash
Create or clear your environments directory by running the following commands:
mkdir -p /opt/continuum/envs
rm -rf /opt/continuum/envs/*
Clean the conda install by running the following command:
conda clean -y --all --force-pkgs-dirs
Using your preferred file editor, open your
~/.bash_profile
file.Add these two export commands to the end of the file to instruct conda to create all new environments in the
/opt/continuum/envs/
directory:export CONDA_ENVS_DIRS=/opt/continuum/envs export CONDA_PKGS_DIRS=/opt/continuum/envs/.pkgs
Save your work and close the file.
Apply your changes by running the following command:
source ~/.bash_profile
Creating a custom environment#
Use conda to create or clone your custom environment:
Create a conda environment by running the following command:
# Replace <ENV> with a name for your new environment conda create -y -n <ENV> python=3.8 ipykernel
Tip
python 3.8
andipykernel
are just examples. Create your environment using the packages you need!Clone an existing environment by running the following command:
# Replace <CLONE_ENV> with the name of the environment you want to clone # Replace <ENV> with a name for your new environment conda create -y --clone <CLONE_ENV> --name <ENV>
Verify that your environment was created in the
/opt/continuum/envs
directory by running the following command:conda env list
Create an archive file containing the custom environment by running the following commands:
# Replace <ENV> with the name of your environment cd /opt/continuum/envs tar cfj <ENV>.tar.bz2 .pkgs <ENV>
Note
Your archive file includes the directory that is named after your environment and the
.pkgs
directory.
For more help with creating environments using conda, see the official conda documentation.
Uploading your custom environment#
Open a browser and log in to Anaconda Enterprise as a user with administrator permissions.
Tip
The
anaconda-enterprise
user account has these permissions.Open any existing project by clicking on it to view its settings.
If necessary, change the Default Editor to JupyterLab.
Open a session for the project.
Upload your environment archive file to the project.
Note
You may see a Large File Size warning. This can safely be ignored.
Open a terminal in your project session and unpack your environment archive file by running the following command:
# Replace <ENV> with the name of your environment tarball file tar xfj /opt/continuum/project/<ENV>.tar.bz2 -C /opt/continuum/envs/
Verify your environment archive file unpacked successfully by running the following command:
ls -laF /opt/continuum/envs
Delete the uploaded environment archive file from the project and stop the project session.
Creating a project template archive#
The project template archive file must contain, at a minimum, the anaconda-project.yml
file. For more information and help building projects, see the official Anaconda Project documentation.
Connect to the machine you are using to create environments.
If necessary, create the project directory by running the following command:
# Replace <PROJECT> with the name of your project mkdir -p '/opt/continuum/project/<PROJECT>'
Enter the directory you just created by running the following command:
# Replace <PROJECT> with the name of your project cd /opt/continuum/project/<PROJECT>
Using your preferred file editor, create and populate an
anaconda-project.yml
file in your project directory. Save and close the file when complete.Note
Your project’s
name:
will display on the Sample Projects grid or the Environments dropdown list after the project is created.Example anaconda-project.yml
name: <PROJECT> description: <A_BRIEF_DESCRIPTION> packages: - python=3.8 - ipykernel platforms: - linux-64 env_specs: <ENV>: {}
Create an archive file for the project, then set permissions for it by running the following commands:
# Replace <PROJECT> with your project name cd /opt/continuum/project tar cfj <PROJECT>.tar.bz2 <PROJECT> chmod 644 <PROJECT>.tar.bz2
Note
This archive file is the template that other projects will use as a starting point for their own projects.
Creating a sample project#
You must upload and move the project into the /gallery
directory to display the project on the Sample Projects page.
Open a browser and log in to Anaconda Enterprise as a user with administrator permissions.
Tip
The
anaconda-enterprise
user account has these permissions.Click Create +, then select Upload project.
Upload your
<PROJECT>.tar.bz2
file to create the project.View your project’s settings.
If necessary, change the Default Editor to JupyterLab.
Open a session for the new project.
Upload your project archive file to the new project.
Note
You may see a Large File Size warning. This can safely be ignored.
Open a terminal in your session and move your project archive file to the sample project gallery by running the following command:
# Replace <PROJECT> with your project name mv /opt/continuum/project/<PROJECT>.tar.bz2 /gallery
Enter the sample gallery by running the following command:
cd /gallery
Update the sample projects gallery to include your project by running the following command:
python reindex.py
Verify that you can find and select your sample project on the Sample Projects page.
Creating a project template environment#
Adding a project that is in the /gallery
directory to the TEMPLATE
file will include it as an Environment option when creating a new project.
Note
Including a project from the /gallery
directory in the TEMPLATE
file will remove it from the sample projects page.
Open a browser and log in to Anaconda Enterprise as a user with administrator permissions.
Tip
The anaconda-enterprise
user account has these permissions.
Open any project and view its settings.
If necessary, change the Default Editor to JupyterLab.
Open a session for the project.
Open a terminal in your session, then enter the sample gallery directory by running the following command:
cd /gallery
Using your preferred file editor, add the project archive file name (
<PROJECT>.tar.bz2
) to theTEMPLATE
file.Save and close the file when complete.
Update the project template environment list to include your project by running the following command:
python reindex.py
Create a new project and verify that your project template appears in the Environment dropdown menu.