-
Notifications
You must be signed in to change notification settings - Fork 38
/
env.sh
executable file
·103 lines (80 loc) · 2.96 KB
/
env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#! /bin/bash
# Create conda environment to run the notebooks in this directory.
#
# By default, the environment will be located in the directory "env"
# immediately under this one. To override that setting,
# pass the subdirectory name as the first argument to this script, i.e.
#
# $ ./env.sh my_dir_name
PYTHON_VERSION=3.8
############################
# HACK ALERT *** HACK ALERT
# The friendly folks at Anaconda thought it would be a good idea to make the
# "conda" command a shell function.
# See https://github.com/conda/conda/issues/7126
# The following workaround will probably be fragile.
if [ -z "$CONDA_HOME" ]
then
echo "Error: CONDA_HOME not set."
exit
fi
if [ -e "${CONDA_HOME}/etc/profile.d/conda.sh" ]
then
# shellcheck disable=SC1090
. "${CONDA_HOME}/etc/profile.d/conda.sh"
else
echo "Error: CONDA_HOME (${CONDA_HOME}) does not appear to be set up."
exit
fi
# END HACK
############################
# Check whether the user specified an environment name.
if [ "$1" != "" ]; then
ENV_DIR=$1
else
ENV_DIR="env"
fi
echo "Creating an Anaconda environment at ./${ENV_DIR}"
# Remove the detrius of any previous runs of this script
rm -rf ./${ENV_DIR}
conda create -y -p ${ENV_DIR} python=${PYTHON_VERSION} pip
conda activate ./${ENV_DIR}
################################################################################
# Preferred way to install packages: Anaconda main
# We currently can't use Anaconda main for most things because of the need for
# a single requirements.txt spanning all packages.
conda install -y -c conda-forge jupyterlab
conda install -y -c conda-forge/label/main nodejs
################################################################################
# Second-best way to install packages: conda-forge
# We currently can't use conda-forge because of the need for a single
# requirements.txt.
# conda install -y -c conda-forge ...
################################################################################
# Third-best way to install packages: pip
# We currently install nearly everything with pip due to the need for a
# single requirements.txt that works outside an Anaconda environment.
pip install -r requirements.txt
################################################################################
# Least-preferred install method: Custom
# Plotly for JupyterLab
jupyter labextension install jupyterlab-plotly --no-build
# Elyra
pip install --upgrade --use-deprecated=legacy-resolver elyra
jupyter lab build
elyra-metadata install runtime-images --replace=true \
--schema_name=runtime-image \
--name=covid-anaconda \
--display_name="COVID with Anaconda Python 3" \
--image_name="codait/covid-notebooks-anaconda-py3:latest"
elyra-metadata list runtimes
elyra-metadata list runtime-images
jupyter --version
echo " "
jupyter serverextension list
echo " "
jupyter labextension list
echo " "
conda deactivate
echo "Anaconda environment at ./${ENV_DIR} successfully created."
echo "To use, type 'conda activate ./${ENV_DIR}'."