Skip to content

Commit a0229f4

Browse files
committed
stability fixes
- make runner script not fail if graphviz or psutils not found - fix some typos
1 parent 63ef988 commit a0229f4

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

MC/bin/o2_dpg_workflow_runner.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
#!/usr/bin/env python3
2+
3+
# started February 2021, sandro.wenzel@cern.ch
4+
25
import re
36
import subprocess
47
import shlex
58
import time
69
import json
710
import logging
811
import os
9-
from graphviz import Digraph
12+
try:
13+
from graphviz import Digraph
14+
havegraphviz=True
15+
except ImportError:
16+
havegraphviz=False
17+
1018

1119
#
1220
# Code section to find all topological orderings
@@ -130,6 +138,10 @@ def analyseGraph(edges, nodes):
130138

131139

132140
def draw_workflow(workflowspec):
141+
if not havegraphviz:
142+
print('graphviz not installed, cannot draw workflow')
143+
return
144+
133145
dot = Digraph(comment='MC workflow')
134146
nametoindex={}
135147
index=0
@@ -360,15 +372,21 @@ def execute(self):
360372
break
361373

362374
import argparse
363-
from psutil import virtual_memory
364-
365-
parser = argparse.ArgumentParser(description='Parellel execute of a DAG data pipeline under resource contraints.')
375+
try:
376+
from psutil import virtual_memory
377+
max_system_mem=virtual_memory().total
378+
except ImportError:
379+
# let's assume 16GB
380+
max_system_mem=16*1024*1024*1024
381+
382+
parser = argparse.ArgumentParser(description='Parellel execution of a (O2-DPG) DAG data pipeline under resource contraints.')
366383
parser.add_argument('-f','--workflowfile', help='Input workflow file name', required=True)
367384
parser.add_argument('-jmax','--maxjobs', help='number of maximal parallel tasks', default=100)
368385
parser.add_argument('--dry-run', action='store_true', help='show what you would do')
369386
parser.add_argument('--visualize-workflow', action='store_true', help='saves a graph visualization of workflow')
370387
parser.add_argument('--target-stages', help='Runs the pipeline by target labels (example "TPC" or "digi")')
371-
parser.add_argument('--mem-limit', help='set memory limit as scheduling constraint', default=virtual_memory().total)
388+
389+
parser.add_argument('--mem-limit', help='set memory limit as scheduling constraint', default=max_system_mem)
372390
args = parser.parse_args()
373391
print (args)
374392
print (args.workflowfile)

0 commit comments

Comments
 (0)