-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_notebook.sh
More file actions
executable file
·127 lines (112 loc) · 4.46 KB
/
run_notebook.sh
File metadata and controls
executable file
·127 lines (112 loc) · 4.46 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
#
################################ run_notebook.sh ###############################
# Josh Mitchell, Open Force Field Consortium, 2023
#
# Run a notebook in the specified Conda environment, even if Conda/Mamba is not
# installed.
#
# `bash`, `uname`, `dirname`, `tar`, `curl`, and `grep` must be available.
#
# `run_notebook.sh` should work on MacOS and most Linux distros. Windows and
# other OSes are not supported. Architectures other than x86_64/AMD64 should
# use an ISA emulation layer such as Rosetta for MacOS ARM64 (Apple Silicon).
#
# Micromamba, which is used by this script to make notebook dependencies
# available, installs packages by:
#
# 1. Downloading the package TAR archive
# 2. Extracting it to a package cache
# 3. Hard linking to it from the virtual environment (or copying if hard linking
# fails)
#
# This saves storage space and network activity when installing the same package
# in multiple environments. As a result, deleting the generated environment
# will not delete the micromamba package cache, which may be several gigabytes
# in size. To remove unused packages from the cache after deleting an
# environment, run:
#
# ./micromamba clean -a
#
# The location of the cache can be configured by setting the `MAMBA_ROOT_PREFIX`
# environment variable before creating any environments. You may want to keep
# the cache to save download time the next time you run an example, but be
# aware that if a package is updated in the meanwhile it will need to be
# re-updated anyway.
#
# Please report any issues with this script to our GitHub issue tracker:
# https://github.com/openforcefield/openff-docs/issues
#
################################################################################
# Exit on failed commands
# We don't set -u because GMXRC relies on some unset variables, so the
# micromamba activate step will fail if set -u is called and GROMACS is in the
# environment
set -Ee -o pipefail
shopt -s failglob
# Make sure we're in the same directory as this script,
# the environment file, and the notebook
cd "$(dirname "$0")"
################################ CONFIG ################################
# Choose a name for the new environment
# Note that deleting this will not clean up the micromamba cache, which may be
# substantial.
ENVNAME='ccpbiosim-protprep'
# The filename of the Conda environment file to run the notebook in
ENV_FILE='environment.yaml'
# The filename of the Jupyter notebook we want to run
NOTEBOOK="*.ipynb"
ARCH=$(uname -m)
# The next section only applies if you have a dependency on Ambertools
## For now, we always want x64, because Ambertools doesn't support other ISAs
## In the future, we can configure this when we select the OS
ARCH="64"
################################################################################
# Choose the platform we're on
OS=$(uname)
if [[ "$OS" == "Linux" ]]; then
PLATFORM="linux"
elif [[ "$OS" == "Darwin" ]]; then
PLATFORM="osx";
else
echo "OS $OS is not supported by $0"
echo "For detailed install instructions, see"
echo "https://docs.openforcefield.org/en/latest/install.html"
exit 1
fi
# Download the appropriate Micromamba binary if it's missing
if [[ ! -f ./micromamba ]]; then
echo "Downloading micromamba for $PLATFORM-$ARCH"
curl -L https://micro.mamba.pm/api/micromamba/$PLATFORM-$ARCH/latest \
| tar -xvj --strip-components=1 bin/micromamba
fi
# Create an alias for micromamba (rather than put this directory in PATH):
alias micromamba=`pwd`/micromamba
# Hook Micromamba into the script's subshell (this only lasts for as long as the
# script is running)
eval "$(./micromamba shell hook --shell=bash)"
# Create the new environment, or install and update packages from the YAML file
# if it already exists
if micromamba env list | grep "^\s*${ENVNAME}\s*"; then
micromamba install --file "$ENV_FILE" --name "$ENVNAME" --yes
micromamba update --file "$ENV_FILE" --name "$ENVNAME" --yes
else
micromamba create --file "$ENV_FILE" --name "$ENVNAME" --yes
fi
# Unset environment variables that might confuse Python
unset PYTHONPATH
unset PYTHONHOME
# Activate the new environment
micromamba activate "$ENVNAME"
# Install pypi-only packages:
# pip install whatever_you_need
pip install git+https://github.com/CharlieLaughton/Alphafix.git
# any other bootstrapping?
mkdir -p blastp
export BLASTDB=$PWD/blastp
pwd=$PWD
cd $BLASTDB
update_blastdb.pl --decompress swissprot
cd $pwd
#t Open the notebook in the new environment
jupyter lab $NOTEBOOK