-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathspider_container_deploy.sh
65 lines (46 loc) · 2.37 KB
/
spider_container_deploy.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
#!/bin/bash
echo "Current working directory is $PWD"
if [[ ! ./ -ef ~ ]] ; then
echo "changing directory to $HOME"
cd $HOME
fi
#clone the hpc-container-wrapper repository
git clone https://github.com/CSCfi/hpc-container-wrapper.git
#change directory to the hpc-container-wrapper dir
cd hpc-container-wrapper
echo "Current working directory is $PWD"
#copy spider config to hpc-container-wrapper configs
cp ../JupyterDaskOnSLURM/config/container/spider.yaml ./configs/
#run container wrapper installation
source install.sh spider
echo 'completed hpc-container-wrapper install.sh for spider'
echo 'copying environment.yaml from JupyterDaskOnSlurm'
cp ../JupyterDaskOnSLURM/environment.yaml .
echo 'creating new containerized environment'
#the hardcoded bash structure of hpc-container-wrapper makes sourced calls to the containerization
#unfeasible, at least while adhereing to the overall program flow. Similarly the bash scripts also preclude a
#more direct call of the relevant routines. The solution below is a interm fix until we decide whether to fork and fix
#or create and issue and submit a PR upstream.
#
containerize_source_file='./frontends/containerize'
containerize_match="calling_name=\$(basename \$0)"
containerize_insert="calling_name=\$(basename \${BASH_SOURCE\[0\]})"
sed -i "s@$containerize_match@$containerize_insert@" $containerize_source_file
mkdir -p ./jupyter_dask
source bin/conda-containerize new --prefix ./jupyter_dask ./environment.yaml
echo 'complete'
echo 'updating JupyterDaskOnSLurm configuration'
cd ..
mkdir -p ~/.config/dask
cp JupyterDaskOnSLURM/config/dask/config_spider.yml ~/.config/dask/config.yml
#insert path export statements into configuration files
#this makes use of `sed`. Note that the comamnd behaviour of `sed` for inline replacement differs between Linux and MacOs
#this is handled below
dask_config_file="$HOME/.config/dask/config.yml"
dask_config_match="walltime: '10:00:00'"
dask_config_insert=" job_script_prologue:\n - 'export PATH=\"$_inst_path/bin:\$PATH\" ' \n python: python\n "
sed -i "s@$dask_config_match@$dask_config_match\n$dask_config_insert@" $dask_config_file
slurm_file="$HOME/JupyterDaskOnSLURM/scripts/jupyter_dask_spider_container.bsh"
slurm_match="export PATH=\"/absolute/path/to/the/container/bin:\$PATH\""
slurm_insert="export PATH=\"$_inst_path/bin:\$PATH\""
sed -i "s@$slurm_match@$slurm_insert@" $slurm_file