Commit 667b0a32 authored by Alex Waite's avatar Alex Waite

Merge branch 'master' into 'master'

add singularity example

See merge request !5
parents ba772802 93612ac3
......@@ -11,3 +11,4 @@ If you see something that is missing or should be improved, please contribute!
| [matlab](matlab/) | A very simple submit file that passes an argument to a Matlab script. |
| [ncal](ncal/) | The [calendar printing example](https://docs.inm7.de/tools/htcondor/#generating-a-submit) used in the docs. A script is used to generate the submit file. |
| [python](python/) | A very simple submit file that passes an argument to a Python script. |
| [singularity](singularity/) | A simple example on how to build a singularity container. |
# Singularity
This template demonstrates how to build a singularity container using HTCondor.
The `singularity.submit` file runs a simple shell script `singularity.sh` that collects the singularity recipe file `sl.def`, builds a singularity image `sl.simg` and pushes it back to your directory.
To run:
```
condor_submit singularity.submit
```
If you want to build your container in an interactive session, you can use the `singularity-interactive.submit` instead:
```
condor_submit --interactive singularity-interactive.submit
```
If successful, you should be able to run your container like so:
```
singularity run sl.simg
```
## Things to Note
- Please note that in this example the singularity container is built on a compute node. This is convenient, because it allows for the job to be completed faster. More on this can be found in the **Further reading** section below.
- Using a `.submit` file allows you use the `rank = IOPS` option, that is to request for machines with faster local disks (it'll prefer, but not require these machines to be used).
## Further reading
Juseless is a collection of systems. The most important ones are the head node (the one you log into), the data node (which hosts `/home` and `/data`), and the compute nodes.
`/home` and `/data` are shared to all nodes using the Network File System (NFS). This is convenient, because they all can see the same data. But it's obviously slower because everything has to go over the network.
Each compute node has a dedicated [*scratch disk*](https://docs.inm7.de/htcondor/job_concepts/#scratch-disk) for local temporary files. This is useful because it saves the data node from unneccesary data and traffic, but also benefits jobs which need to read and write a lot. Local disk are faster than the network, so it's a win all around.
Compute jobs see this *scratch disk* as `/tmp` (the reality is more complex than that).
## Prerequisites
This example assumes that it is located in `~/htcondor-templates/singularity`. If you have cloned it elsewhere, adjust the submit file as necessary.
Otherwise, this example is entirely self contained.
# The environment
universe = vanilla
getenv = True
request_cpus = 1
request_memory = 5G
request_disk = 100G
rank = IOPS
# Execution
initialdir = $ENV(HOME)/htcondor-templates/singularity/
log = logs/interactive.$(Cluster).$(Process).log
output = logs/interactive.$(Cluster).$(Process).out
error = logs/interactive.$(Cluster).$(Process).err
Queue
#!/bin/bash
# use a dedicated "scratch disk"
cd /tmp
chmod 1777 /tmp
# download the singularity recipe file
git clone https://jugit.fz-juelich.de/inm7/tools/htcondor-templates.git
cd htcondor-templates/singularity
# build the singularity image file
sudo singularity build sl.simg sl.def
# push the image file back to your directory
scp sl.simg ~/htcondor-templates/singularity/
# The environment
universe = vanilla
getenv = True
request_cpus = 1
request_memory = 5G
request_disk = 100G
rank = IOPS
# Execution
initialdir = $ENV(HOME)/htcondor-templates/singularity/
executable = $(initialdir)/singularity.sh
transfer_executable = False
# Job
log = logs/$(Cluster).$(Process).log
output = logs/$(Cluster).$(Process).out
error = logs/$(Cluster).$(Process).err
Queue
Bootstrap: docker
From: debian:buster-slim
%post
apt-get update
apt-get -y install sl
apt-get clean
apt-get autoremove
%environment
export PATH="/usr/games:$PATH"
%runscript
exec sl
%labels
Author Malgorzata Wierzba (m.wierzba@fz-juelich.de)
Version 1.0.0
%help
This container allows you to run the most wonderful shell command ever created.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment