|
4 | 4 | import os
|
5 | 5 | import sys
|
6 | 6 | import uuid
|
| 7 | +import time |
7 | 8 | from warnings import warn
|
8 | 9 |
|
9 | 10 | from .base import (GraphPluginBase, logger)
|
@@ -34,6 +35,8 @@ class CondorDAGManPlugin(GraphPluginBase):
|
34 | 35 | - wrapper_args : optional additional arguments to a wrapper command
|
35 | 36 | - dagman_args : arguments to be prepended to the job execution script in the
|
36 | 37 | dagman call
|
| 38 | + - block : if True the plugin call will block until Condor has finished |
| 39 | + prcoessing the entire workflow |
37 | 40 | """
|
38 | 41 |
|
39 | 42 | default_submit_template = """
|
@@ -69,12 +72,15 @@ def __init__(self, **kwargs):
|
69 | 72 | ('_override_specs', 'override_specs', ''),
|
70 | 73 | ('_wrapper_cmd', 'wrapper_cmd', None),
|
71 | 74 | ('_wrapper_args', 'wrapper_args', ''),
|
| 75 | + ('_block', 'block', False), |
72 | 76 | ('_dagman_args', 'dagman_args', '')):
|
73 | 77 | if 'plugin_args' in kwargs \
|
74 | 78 | and not kwargs['plugin_args'] is None \
|
75 | 79 | and id_ in kwargs['plugin_args']:
|
76 | 80 | if id_ == 'wrapper_cmd':
|
77 | 81 | val = os.path.abspath(kwargs['plugin_args'][id_])
|
| 82 | + elif id_ == 'block': |
| 83 | + val = kwargs['plugin_args'][id_] |
78 | 84 | else:
|
79 | 85 | val = self._get_str_or_file(kwargs['plugin_args'][id_])
|
80 | 86 | setattr(self, var, val)
|
@@ -150,3 +156,13 @@ def _submit_graph(self, pyfiles, dependencies, nodes):
|
150 | 156 | self._dagman_args)
|
151 | 157 | cmd.run()
|
152 | 158 | logger.info('submitted all jobs to Condor DAGMan')
|
| 159 | + if self._block: |
| 160 | + # wait for DAGMan to settle down, no time wasted it is already running |
| 161 | + time.sleep(10) |
| 162 | + if not os.path.exists('%s.condor.sub' % dagfilename): |
| 163 | + raise EnvironmentError("DAGMan did not create its submit file, please check the logs") |
| 164 | + # wait for completion |
| 165 | + logger.info('waiting for DAGMan to finish') |
| 166 | + lockfilename = '%s.lock' % dagfilename |
| 167 | + while os.path.exists(lockfilename): |
| 168 | + time.sleep(5) |
0 commit comments