Workflows with DAGMan¶
Learn more at: https://htcondor.readthedocs.io/en/latest/automated-workflows/index.html
DAGMan (Directed Acyclic Graph Manager) is an HTCondor tool that organizes multiple jobs into workflows. It is particularly useful for submitting jobs automatically in a given order, especially when the same workflow has to be run several times.
DAGMan submits jobs to HTCondor and is responsible for scheduling them, managing dependencies between them, and reporting on them.
Simple workflow example¶
flowchart TD
split[split]:::split
n1[1]:::node
n2[2]:::node
n3[3]:::node
nd["…"]:::dots
nN[N]:::node
combine[combine]:::combine
split --> n1 & n2 & n3 & nd & nN
n1 & n2 & n3 & nd & nN --> combine
classDef split fill:#8e44ad,stroke:#5b2c6f,color:#fff
classDef node fill:#3d7ab8,stroke:#24527a,color:#fff
classDef combine fill:#f08a24,stroke:#b35f0f,color:#fff
classDef dots fill:none,stroke:none
Describing workflows as directed acyclic graphs (DAGs)¶
A workflow is represented by a DAG (Directed Acyclic Graph) made of a set of nodes and their dependencies (as parent-child relations), and described in a DAG input file. “Acyclic” means the graph has a start and an end, with no loops (“cycles”).
A node is a unit of work that contains an HTCondor job and optional PRE and POST scripts that run before and after the job. Dependencies between nodes are described as directional connections; each connection has a parent and a child, where the parent node must finish running before the child starts. Any node can have an unlimited number of parents and children.
Basic DAG input file: JOB nodes, PARENT-CHILD directional connections¶
Users must describe the nodes and directional connections in the DAG input file. The examples start from the simple diamond-shaped DAG shown in the following graph. This DAG contains 4 nodes.
flowchart TD
A((A)) --> B((B))
A --> C((C))
B --> D((D))
C --> D
A very simple DAG input file for this diamond-shaped DAG is:
JOB A A.submit
JOB B B.submit
JOB C C.submit
JOB D D.submit
PARENT A CHILD B C
PARENT B C CHILD D
The files A.submit, B.submit, C.submit, D.submit are simple submit files for the four nodes A, B, C, D.
Alternatively, some or all of the dependencies can be written on separate lines:
Node job submit file contents¶
Each node in a DAG may use its own submit description file. DAGMan cannot handle a submit description file that produces multiple job clusters.
As a first try, you can reproduce the following example, which submits a ‘bag’ of 10 DAGs.
executable=/usr/bin/echo
universe=vanilla
arguments="Test A.$(Process)"
output=outA.$(Process)
error=errA.$(Process)
log=results.log
notification=never
queue 10
executable=test_dag.sh
universe=vanilla
arguments = B outA.$(Process)
output=test_dagB.$(Process)
error=errB.$(Process)
transfer_input_files=outA.$(Process)
log=results.log
request_cpus = 1
request_memory = 1024
notification=never
queue 10
executable=test_dag.sh
universe=vanilla
arguments = C outA.$(Process)
output=test_dagC.$(Process)
error=errC.$(Process)
transfer_input_files=outA.$(Process)
log=results.log
request_cpus = 1
request_memory = 1024
notification=never
queue 10
executable=/usr/bin/cat
universe=vanilla
arguments = test_dagB.$(Process) test_dagC.$(Process)
output=outD.$(Process)
error=errD.$(Process)
transfer_input_files = test_dagB.$(Process) test_dagC.$(Process)
log=results.log
request_cpus = 1
request_memory = 1024
notification=never
queue 10
Submitting and monitoring a DAG¶
Use the condor_submit_dag submission command. A submitted DAG creates a DAGMan job process in the queue.
$ cd /mustfs/LAPP-DATA/calcul/alice/HT-CONDOR/DAG
$ condor_submit_dag test.dag
--------------------------------------------------------------------
File for submitting this DAG to HTCondor : test.dag.condor.sub
Log of DAGMan debugging messages : test.dag.dagman.out
Log of HTCondor library output : test.dag.lib.out
Log of HTCondor library error messages : test.dag.lib.err
Log of the life of condor_dagman itself : test.dag.dagman.log
Submitting job(s).
1 job(s) submitted to cluster 38317.
--------------------------------------------------------------------
DAGMan runs as a job in the queue. A few seconds later, the 10 A nodes appear, idle or running: they were submitted automatically by the DAGMan job. Once A completes, B and C are submitted, then D once B and C have completed.
$ condor_q -nobatch
-- Schedd: host.in2p3.fr : <134.158.x.x:9618?... @ 03/07/22 16:51:05
ID OWNER SUBMITTED RUN_TIME ST PRI SIZE CMD
38317.0 alice 3/7 16:51 0+00:00:02 R 0 0.3 condor_dagman -p 0 -f -l . -Lockfile test.dag.lock -AutoRescue 1 -DoRescueFrom
38320.0 alice 3/7 16:51 0+00:00:00 I 0 0.0 echo Test A.0
38320.1 alice 3/7 16:51 0+00:00:00 R 0 0.0 echo Test A.1
38320.2 alice 3/7 16:51 0+00:00:00 R 0 0.0 echo Test A.2
38320.3 alice 3/7 16:51 0+00:00:00 R 0 0.0 echo Test A.3
38320.4 alice 3/7 16:51 0+00:00:00 R 0 0.0 echo Test A.4
38320.5 alice 3/7 16:51 0+00:00:00 R 0 0.0 echo Test A.5
38320.6 alice 3/7 16:51 0+00:00:00 I 0 0.0 echo Test A.6
38320.7 alice 3/7 16:51 0+00:00:00 I 0 0.0 echo Test A.7
38320.8 alice 3/7 16:51 0+00:00:00 I 0 0.0 echo Test A.8
38320.9 alice 3/7 16:51 0+00:00:00 I 0 0.0 echo Test A.9
Total for alice: 10 jobs; 0 completed, 0 removed, 5 idle, 5 running, 0 held, 0 suspended.
Several status files are created by the condor_dagman job process:
*.condor.suband*.dagman.logdescribe the queued DAGMan job process, as for all queued jobs*.dagman.outhas detailed logging (look there first for errors)*.lib.err/*.lib.outcontain std err/out for the DAGMan job process*.nodes.logis a combined log of all jobs within the DAG
You may therefore need the -f or -update_submit option if these files already exist.
On DAG completion, the following files will be available:
*.metricsis a summary of events and outcomes*.nodes.logwill note the completion of the DAGMan job
Removing a DAG¶
Remove the DAGMan job in order to stop and remove the entire DAG:
Removing a DAG results in a rescue file dag_file.rescue001.
A rescue file is created whenever the user removes a DAG from the queue (condor_rm), or automatically when:
- a node fails, once DAGMan has run all other possible nodes,
- the DAG is aborted,
- the DAG is halted and not unhalted.
Default file organization¶
condor_dagman assumes that all relative paths in a DAG input file and the associated HTCondor submit description files are relative to the current working directory when condor_submit_dag is run. This works well for submitting a single DAG. It presents problems when multiple independent DAGs are submitted with a single invocation of condor_submit_dag. Each of these independent DAGs would logically be in its own directory, so that it can be run or tested independently of the others. In that case, all file references should be relative to the DAG’s own directory.
Warning
There are two ways to specify file locations; do not use both at the same time:
- use the
condor_submit_dagcommand with option-UseDagDir - use the directive
DIRin the DAG input file to specify the location of the submit files
Learn more at: https://htcondor.readthedocs.io/en/latest/automated-workflows/dagman-interaction.html#file-paths-in-dags