Package: atomic-hpc
atomic-hpcProject:https://github.com/chrisjsewell/atomic-hpcA package for running multiple executable scripts on both local and remote hosts,
configured using a modern standardYAMLfile.
This package was designed, in particular, for job submission to High Performance Computing (HPC) clusters, such as theImperial HPC facility.
Working examples can be foundhere.InstallationIt is recommended to setup anAnacondaenvironment.
For the Imperial HPC, run the following (as outlined on thewiki):>> module load anaconda3/personal
>> anaconda-setupThen install atomic-hpc simply by:>> pip install atomic-hpcMinimal ExampleWrite a yaml configuration file; each run must have a name and a unique id,
then attributes can be set in the (global)defaultssection or per run (run attributes will overwrite defaults):config.yaml:defaults:environment:unixprocess:unix:run:-echo "hallo world" > hallo.txtoutput:path:outputruns:-id:1name:test_local-id:2name:test_otherSubmit it with the command line app (use -h to see all options):>> run_config config.yamlThe results will be available in the output path, with one folder per run:>> ls -R output
 output/1_test_local:
 config_1.yaml     hallo.txt
 output/2_test_other:
 config_2.yaml     hallo.txtMinimal Example (Remote and PBS)Jobs can be submitted to remote hosts and, optionally,PBStype systems.config_remote.yamlruns:-id:1name:test_qsubenvironment:qsuboutput:remote:hostname:login.cx1.hpc.imperial.ac.ukusername:cjs14path:/work/cjs14/yaml_testprocess:qsub:cores_per_node:16nnodes:1walltime:1:00:00queue:queue_namemodules:-quantum-espresso-intel-suite-mpirun:-mpiexec pw.x -i script2.in > main.qe.scf.outTo retrieve outputs from a remote host, once all processes have run:>> retrieve_config config_remote.yaml -o path/to/local/outputsInputsInput files and scripts can be local or remote and will be copied to the output folder before the runs.
Variables can also be set that will be replaced in the cmnd lines and script files if a corresponding@v{var_id}regex is found. Similarly entire file contents can be parsed to the script with the@f{file_id}regex:>> cat path/to/script1.in
@v{var1}
@f{file1}
>> cat path/to/file1
This is file 1config.yaml:defaults:description:quantum-espresso runenvironment:unixinput:remote:hostname:login.cx1.hpc.imperial.ac.ukusername:cjs14variables:var1:nprocs:2files:file1:path/to/input.txtscripts:-path/to/script1.inprocess:unix:run:-mpirun -np @v{nprocs} pw.x -i script1.in > main.qe.scf.outruns:-id:1name:run1input:variables:var1:value1-id:2name:run2input:variables:var1:value2Run:>> run_config config.yaml>> ls -R outputoutput/1_run1:config_1.yaml  input.txt  main.qe.scf.out  script.inoutput/2_run2:config_2.yaml  input.txt  main.qe.scf.out  script.in>> cat output/1_run1/script.invalue1This is file 1Note1: all relative paths are resolved relative to the execution directory, unless set withrun_config -b base/path/.Note2: For the above example, if a script or cmndline has@v{file1}in it (rather than@f{file1}),
then this would be replaced with the file name (rather than its content), i.e. input.txtNote3: Withinqsub: run:, the keyword@{wrkpath}will be replaced with the working folder path.
This is handy, for instance, to maintain a dynamic log file in the work path, while the program is running in a temporary folder, e,g,process:qsub:start_in_temp:truerun:-my_program > @{wrkpath}/output.logOutputsAs well as specifying the output path, post-process file removal and renaming can be configured:runs:-id:1name:run1output:path:path/to/outputremove:-tmp/rename:.other.out:.other.qe.jsonFull Configuration Optionsruns:description:quantum-espresso runenvironment:qsubinput:path:scripts:-path/to/script1.in-path/to/script2.infiles:file1:path/to/file1binaries:file2:path/to/file2variables:var1:overridevaluevar2:valuenprocs:2remote:hostname:login.cx1.hpc.imperial.ac.ukport:22username:cjs14password:pkey:key_filename:timeout:output:remote:hostname:login.cx1.hpc.imperial.ac.ukport:22username:cjs14password:pkey:key_filename:timeout:path:path/to/top/level/outputremove:# can also use wildcard characters *, ? and []-tmp/rename:# renames any segment of file names, i.e. file.other.out.txt -> file.other.qe.txt# searches for files (recursively) in all folders.other.out:.other.qeprocess:unix:run:-mpirun -np @v{nprocs} pw.x -i script1.in > main.qe.scf.outwindows:run:-mpirun -np @v{nprocs} pw.x -i script1.in > main.qe.scf.outqsub:jobname:cores_per_node:16nnodes:1memory_per_node:1gbtmpspace:500gb# minimum free space required on the temporary directorywalltime:1:00:00queue:queue_nameemail:bob@hotmail.com# send email on job start/end# NB: the emailling feature has recently been disabled on the Imperial HPCmodules:-module1-module2start_in_temp:true# if true cd to $TMPDIR and copy all files before running executablesrun:-mpiexec pw.x -i script2.in > main.qe.scf.outid:1name:run1Setting up an SSH Public and Private KeysRather than directly using a password to access the remote host, it is reccommended that a public key authentication
be used, as a more secure authentication method. There are numerous explanations on the internet
(includinghere) and below follows a short setup guide
(taken fromhere):First open a shell on the computer you want to connect from. Enter cd ~/.ssh.
If anlsshows to files called 'id_rsa' and 'id_rsa.pub' you already have a key pair.
If not, enterssh-keygenHere is what the result should look like:heiko@clove:~/.ssh$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/heiko/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
f0:da:dc:77:cf:71:12:c8:50:dc:18:a9:8d:66:38:ae heiko@clove.ch.ic.ac.uk
The key's randomart image is:
+--[ RSA 2048]----+
|           .o=   |
|           .+ .  |
|      .  ..+     |
|       oo =o..   |
|       .S+  o .  |
|       +..     . |
|      ..o . . o..|
|      E    . . +o|
|                o|
+-----------------+You should keep the standard directory and choose a suitably difficult passphrase.The two file you just created are key and keyhole. The first file 'id_rsa' is the key.
You should not ever ever ever give it to anybody else or allow anyone to copy it.
The second file 'id_rsa.pub' the keyhole. It is public and you could give it to anyone.
In this case, give it to the hpc.If you open 'id_rsa.pub' it should contain one line of, similar to:ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwRDgM+iQg7OaX/CFq1sZ9jl206nYIhW9SMBqsOIRvGM68/6o6uxZo/D4IlmQI9sAcU5FVNEt9dvDanRqUlC7ZtcOGOCqZsj1HTGD3LcOiPNHYPvi1auEwrXv1hDh4pmJwdgZCRnpewNl+I6RNBiZUyzLzp0/2eIyf4TqG1rpHRNjmtS9turANIv1GK1ONIO7RfVmmIk/jjTQJU9iJqje9ZSXTSm7rUG4W8q+mWcnACReVChc+9mVZDOb3gUZV1Vs8e7G36nj6XfHw51y1B1lrlnPQJ7U3JdqPz6AG3Je39cR1vnfALxBSpF5QbTHTJOX5ke+sNKo//kDyWWlfzz3rQ== heiko@clove.ch.ic.ac.ukNow log in to the HPC and open (or create) the file '~/.ssh/authorized_keys'.
In a new line at the end of this file, you should add a comment (starting with #) about where that keypair comes from
and then in a second line you should copy and paste the complete contents of your 'id_rsa.pub' file.#MAC in the office
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwRDgM+iQg7OaX/CFq1sZ9jl206nYIhW9SMBqsOIRvGM68/6o6uxZo/D4IlmQI9sAcU5FVNEt9dvDanRqUlC7ZtcOGOCqZsj1HTGD3LcOiPNHYPvi1auEwrXv1hDh4pmJwdgZCRnpewNl+I6RNBiZUyzLzp0/2eIyf4TqG1rpHRNjmtS9turANIv1GK1ONIO7RfVmmIk/jjTQJU9iJqje9ZSXTSm7rUG4W8q+mWcnACReVChc+9mVZDOb3gUZV1Vs8e7G36nj6XfHw51y1B1lrlnPQJ7U3JdqPz6AG3Je39cR1vnfALxBSpF5QbTHTJOX5ke+sNKo//kDyWWlfzz3rQ== heiko@clove.ch.ic.ac.ukClose the 'authorized_keys' file and your connection to the HPC. Now connect again.
You will be asked for the passphrase for your keyfile. Enter it.
You should now be logged in to the HPC. If you are not asked for the passphrase but for the password of your account,
the Server does not accept your key pair.So far, we have replaced entering the password for your account with entering the passphrase for your keypair.
This is where a so called SSH-agent comes handy. The agent will store your passphrases for you so you do not have
to enter them anymore. Luckily MacOS has one build in, that should have popped up and asked you, whether you want the
agent to take care of your passphrases. If you said 'YES', that was the very last time you ever heard or saw anything of
it or your passphrase. Similar agents exist for more or less every OS. From now on you just have to
enter hostname and username and you are logged in.NotesIf using special characters in strings (like *) be sure to wrap them in "" or use the > or | yaml components
(seehttps://en.wikipedia.org/wiki/YAML#Basic_components)