Skip to content

Commit d0a75bf

Browse files
committed
include renaming utility
1 parent 97511c9 commit d0a75bf

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

_includes/snippets_library/README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# HPC Carpentriy Snippets Library
2+
3+
This directory contains snippets of code and output that are specific
4+
to a particular site. For example, when the lesson shows the status
5+
of the cluster and its nodes, it is preferable to show *your* cluster
6+
and *your* nodes. If you replace the contents of the relevant snippet,
7+
the website gets built with your cluster details, instead of generic
8+
values (or, more precisely, values taken from ComputeCanada).
9+
10+
The snippets have been named so that the lessons use them in roughly
11+
alphabetical order, while still reflecting something of the contents
12+
of each file. So, if you're reading (or teaching) a lesson and notice
13+
something amiss about half-way through, look to the files about
14+
half-way through the directory. If it's the first or last snippet,
15+
you're in particularly good luck.
16+
17+
This alphabetical ordering was not always the case. To reduce the
18+
headache of keeping forks, branches, and derivative works up-to-date,
19+
we have included a utility to rename snippets from the older scheme.
20+
To use it, run the following command, rebuild and test your site, and
21+
commit the changes.
22+
23+
```bash
24+
$ ./rename-snippets.sh <your_snippet_directory>
25+
```
26+
27+
If the naming seems counter-intuitive, please feel free to make
28+
changes locally, and file an issue of submit a pull request to fix it
29+
upstream. None of this is set in stone, and improvements are always
30+
welcome.
31+
32+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
3+
# This script renames snippets from the argument directory in an effort
4+
# to make the names more meaningful, thereby simplifying the process of
5+
# porting to a new site.
6+
7+
if [[ $# != 1 ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
8+
echo "Please supply a folder name containing snippets for your site. This"
9+
echo "script will rename those snippets based on the script activity. E.g.,"
10+
echo " $0 ComputeCanada_Graham_slurm"
11+
exit 1
12+
fi
13+
14+
if [[ $(which git) == "" ]]; then
15+
echo "Error: This script requires git. Please install it and try again."
16+
exit 1
17+
fi
18+
19+
PREFIX=$1
20+
21+
function rename_snip {
22+
git mv $1 $2
23+
}
24+
25+
## Episode 12: Working on a remote HPC system
26+
27+
#$ {{ site.sched.info }}
28+
rename_snip ${PREFIX}/12/info.snip ${PREFIX}/12/queue-info.snip
29+
#$ sinfo -n {{ site.remote.node }} -o "%n %c %m"
30+
rename_snip ${PREFIX}/12/explore.snip ${PREFIX}/12/specific-node-info.snip
31+
32+
## Episode 13: Scheduling jobs
33+
34+
# {{ site.sched.submit.name }} {{ site.sched.submit.options }} example-job.sh
35+
rename_snip ${PREFIX}/13/submit_output.snip ${PREFIX}/13/basic-job-script.snip
36+
#$ {{ site.sched.status }} {{ site.sched.flag.user }}
37+
rename_snip ${PREFIX}/13/statu_output.snip ${PREFIX}/13/basic-job-status.snip
38+
#$ {{ site.sched.status }} {{ site.sched.flag.user }}
39+
rename_snip ${PREFIX}/13/statu_name_output.snip ${PREFIX}/13/job-with-name-status.snip
40+
## The following are several key resource requests:
41+
rename_snip ${PREFIX}/13/stat_options.snip ${PREFIX}/13/option-flags-list.snip
42+
## Print SLURM_CPUS_PER_TASK, PBS_O_WORKDIR, or similar
43+
rename_snip ${PREFIX}/13/env_challenge.snip ${PREFIX}/13/print-sched-variables.snip
44+
#$ {{ site.sched.submit.name }} {{ site.sched.submit.options }} example-job.sh
45+
rename_snip ${PREFIX}/13/long_job_cat.snip ${PREFIX}/13/runtime-exceeded-job.snip
46+
#$ {{ site.sched.status }} {{ site.sched.flag.user }}
47+
rename_snip ${PREFIX}/13/long_job_err.snip ${PREFIX}/13/runtime-exceeded-output.snip
48+
#$ {{ site.sched.submit.name }} {{ site.sched.submit.options }} example-job.sh
49+
#$ {{ site.sched.status }} {{ site.sched.flag.user }}
50+
rename_snip ${PREFIX}/13/del_job_output1.snip ${PREFIX}/13/terminate-job-begin.snip
51+
#$ {{site.sched.del }} 38759
52+
rename_snip ${PREFIX}/13/del_job_output2.snip ${PREFIX}/13/terminate-job-cancel.snip
53+
#$ {{site.sched.del }} {{ site.sched.flag.user }}
54+
rename_snip ${PREFIX}/13/del_multiple_challenge.snip ${PREFIX}/13/terminate-multiple-jobs.snip
55+
## use the compute node resources interactively
56+
rename_snip ${PREFIX}/13/interactive_example.snip ${PREFIX}/13/using-nodes-interactively.snip
57+
58+
## Episode 14: Accessing software
59+
60+
#$ module avail
61+
rename_snip ${PREFIX}/14/module_avail.snip ${PREFIX}/14/available-modules.snip
62+
#$ which python
63+
rename_snip ${PREFIX}/14/which_missing.snip ${PREFIX}/14/missing-python.snip
64+
#$ module load python[3]
65+
rename_snip ${PREFIX}/14/load_python.snip ${PREFIX}/14/module-load-python.snip
66+
#$ which python
67+
rename_snip ${PREFIX}/14/which_python.snip ${PREFIX}/14/python-executable-dir.snip
68+
#$ echo $PATH
69+
rename_snip ${PREFIX}/14/path.snip ${PREFIX}/14/python-module-path.snip
70+
#$ ls $(dirname $(which python))
71+
rename_snip ${PREFIX}/14/ls_dir.snip ${PREFIX}/14/python-ls-dir-command.snip
72+
rename_snip ${PREFIX}/14/ls_dir_output.snip ${PREFIX}/14/python-ls-dir-output.snip
73+
## Loading & unloading software and dependencies
74+
rename_snip ${PREFIX}/14/depend_demo.snip ${PREFIX}/14/software-dependencies.snip
75+
## gcc example
76+
rename_snip ${PREFIX}/14/gcc_example.snip ${PREFIX}/14/wrong-gcc-version.snip
77+
78+
## Episode 15: Transferring files
79+
80+
## Episode 16: Using resources effectively
81+
82+
#$ {{ site.sched.hist }}
83+
rename_snip ${PREFIX}/16/stat_output.snip ${PREFIX}/16/account-history.snip
84+
#$ top
85+
rename_snip ${PREFIX}/16/top_output.snip ${PREFIX}/16/monitor-processes-top.snip
86+
#$ free -h
87+
rename_snip ${PREFIX}/16/free_output.snip ${PREFIX}/16/system-memory-free.snip
88+
89+
## Episode 17: Using shared resources responsibly

0 commit comments

Comments
 (0)