|
8 | 8 | import shutil |
9 | 9 | import sys |
10 | 10 | import time |
| 11 | +import warnings |
11 | 12 |
|
12 | 13 | from ample import ensembler |
13 | 14 | from ample.ensembler.constants import UNMODIFIED |
|
24 | 25 | from ample.util import process_models |
25 | 26 | from ample.util import pyrvapi_results |
26 | 27 | from ample.util import reference_manager |
27 | | -from ample.util import workers_util |
28 | 28 | from ample.util import version |
29 | 29 |
|
| 30 | +from pyjob.factory import TaskFactory |
| 31 | + |
30 | 32 | __author__ = "Jens Thomas, Felix Simkovic, Adam Simpkin, Ronan Keegan, and Jaclyn Bibby" |
31 | 33 | __credits__ = "Daniel Rigden, Martyn Winn, and Olga Mayans" |
32 | 34 | __email__ = "drigden@liverpool.ac.uk" |
@@ -79,6 +81,17 @@ def monitor(): |
79 | 81 | else: |
80 | 82 | monitor = None |
81 | 83 |
|
| 84 | + # Highlight deprecated command line arguments |
| 85 | + if amopt.d['submit_cluster']: |
| 86 | + message = "-%s has been deprecated and will be removed in version %s!" % ('submit_cluster', 1.6) |
| 87 | + warnings.warn(message, DeprecationWarning) |
| 88 | + if amopt.d["submit_pe_lsf"]: |
| 89 | + message = "-%s has been deprecated and will be removed in version %s! Use -submit_pe instead" % ('submit_pe_lsf', 1.6) |
| 90 | + warnings.warn(message, DeprecationWarning) |
| 91 | + if amopt.d["submit_pe_sge"]: |
| 92 | + message = "-%s has been deprecated and will be removed in version %s! Use -submit_pe instead" % ('submit_pe_sge', 1.6) |
| 93 | + warnings.warn(message, DeprecationWarning) |
| 94 | + |
82 | 95 | # Process any files we may have been given |
83 | 96 | model_results = process_models.extract_and_validate_models(amopt.d) |
84 | 97 | if model_results: |
@@ -147,24 +160,25 @@ def monitor(): |
147 | 160 | return |
148 | 161 |
|
149 | 162 | def benchmarking(self, optd): |
150 | | - if optd['submit_cluster']: |
| 163 | + if optd['submit_qtype'] != 'local': |
151 | 164 | # Pickle dictionary so it can be opened by the job to get the parameters |
152 | 165 | ample_util.save_amoptd(optd) |
153 | 166 | script = benchmark_util.cluster_script(optd) |
154 | | - workers_util.run_scripts( |
155 | | - job_scripts=[script], |
156 | | - monitor=monitor, |
157 | | - nproc=optd['nproc'], |
158 | | - job_time=43200, |
159 | | - job_name='benchmark', |
160 | | - submit_cluster=optd['submit_cluster'], |
161 | | - submit_qtype=optd['submit_qtype'], |
162 | | - submit_queue=optd['submit_queue'], |
163 | | - submit_pe_lsf=optd['submit_pe_lsf'], |
164 | | - submit_pe_sge=optd['submit_pe_sge'], |
165 | | - submit_array=optd['submit_array'], |
166 | | - submit_max_array=optd['submit_max_array'], |
167 | | - ) |
| 167 | + with TaskFactory( |
| 168 | + optd['submit_qtype'], |
| 169 | + script, |
| 170 | + cwd=optd['work_dir'], |
| 171 | + environment=optd['submit_pe'], |
| 172 | + run_time=43200, |
| 173 | + name='benchmark', |
| 174 | + nprocesses=optd['nproc'], |
| 175 | + max_array_size=optd['submit_max_array'], |
| 176 | + queue=optd['submit_queue'], |
| 177 | + shell="/bin/bash", |
| 178 | + ) as task: |
| 179 | + task.run() |
| 180 | + task.wait(interval=5, monitor_f=monitor) |
| 181 | + |
168 | 182 | # queue finished so unpickle results |
169 | 183 | optd.update(ample_util.read_amoptd(optd['results_path'])) |
170 | 184 | else: |
@@ -255,25 +269,25 @@ def ensembling(self, optd): |
255 | 269 | msg = "ERROR! Cannot find any pdb files in: {0}".format(optd['models_dir']) |
256 | 270 | exit_util.exit_error(msg) |
257 | 271 | optd['ensemble_ok'] = os.path.join(optd['work_dir'], 'ensemble.ok') |
258 | | - if optd['submit_cluster']: |
| 272 | + if optd['submit_qtype'] != 'local': |
259 | 273 | # Pickle dictionary so it can be opened by the job to get the parameters |
260 | 274 | ample_util.save_amoptd(optd) |
261 | 275 | script = ensembler.cluster_script(optd) |
262 | 276 | ensembler_timeout = ensembler.get_ensembler_timeout(optd) |
263 | | - workers_util.run_scripts( |
264 | | - job_scripts=[script], |
265 | | - monitor=monitor, |
266 | | - nproc=optd['nproc'], |
267 | | - job_time=ensembler_timeout, |
268 | | - job_name='ensemble', |
269 | | - submit_cluster=optd['submit_cluster'], |
270 | | - submit_qtype=optd['submit_qtype'], |
271 | | - submit_queue=optd['submit_queue'], |
272 | | - submit_pe_lsf=optd['submit_pe_lsf'], |
273 | | - submit_pe_sge=optd['submit_pe_sge'], |
274 | | - submit_array=optd['submit_array'], |
275 | | - submit_max_array=optd['submit_max_array'], |
276 | | - ) |
| 277 | + with TaskFactory( |
| 278 | + optd['submit_qtype'], |
| 279 | + script, |
| 280 | + cwd=optd['work_dir'], |
| 281 | + environment=optd['submit_pe'], |
| 282 | + run_time=ensembler_timeout, |
| 283 | + name='benchmark', |
| 284 | + nprocesses=optd['nproc'], |
| 285 | + max_array_size=optd['submit_max_array'], |
| 286 | + queue=optd['submit_queue'], |
| 287 | + shell="/bin/bash", |
| 288 | + ) as task: |
| 289 | + task.run() |
| 290 | + task.wait(interval=5, monitor_f=monitor) |
277 | 291 | # queue finished so unpickle results |
278 | 292 | optd.update(ample_util.read_amoptd(optd['results_path'])) |
279 | 293 | else: |
@@ -402,24 +416,27 @@ def monitor(): |
402 | 416 |
|
403 | 417 | # Change to mrbump directory before running |
404 | 418 | os.chdir(optd['mrbump_dir']) |
405 | | - ok = workers_util.run_scripts( |
406 | | - job_scripts=optd['mrbump_scripts'], |
407 | | - monitor=monitor, |
408 | | - check_success=mrbump_util.checkSuccess, |
409 | | - early_terminate=optd['early_terminate'], |
410 | | - nproc=optd['nproc'], |
411 | | - job_time=mrbump_util.MRBUMP_RUNTIME, |
412 | | - job_name='mrbump', |
413 | | - submit_cluster=optd['submit_cluster'], |
414 | | - submit_qtype=optd['submit_qtype'], |
415 | | - submit_queue=optd['submit_queue'], |
416 | | - submit_pe_lsf=optd['submit_pe_lsf'], |
417 | | - submit_pe_sge=optd['submit_pe_sge'], |
418 | | - submit_array=optd['submit_array'], |
419 | | - submit_max_array=optd['submit_max_array'], |
420 | | - ) |
421 | | - |
422 | | - if not ok: |
| 419 | + |
| 420 | + with TaskFactory( |
| 421 | + optd['submit_qtype'], |
| 422 | + optd['mrbump_scripts'], |
| 423 | + cwd=bump_dir, |
| 424 | + environment=optd['submit_pe'], |
| 425 | + run_time=mrbump_util.MRBUMP_RUNTIME, |
| 426 | + name="mrbump", |
| 427 | + nprocesses=optd['nproc'], |
| 428 | + max_array_size=optd['submit_max_array'], |
| 429 | + queue=optd['submit_queue'], |
| 430 | + shell="/bin/bash", |
| 431 | + ) as task: |
| 432 | + task.run() |
| 433 | + |
| 434 | + if optd['early_terminate']: |
| 435 | + task.wait(interval=5, monitor_f=monitor, success_f=mrbump_util.checkSuccess) |
| 436 | + else: |
| 437 | + task.wait(interval=5, monitor_f=monitor) |
| 438 | + |
| 439 | + if not task.completed: |
423 | 440 | msg = ( |
424 | 441 | "An error code was returned after running MRBUMP on the ensembles!\n" |
425 | 442 | + "For further information check the logs in directory: {0}".format(optd['mrbump_dir']) |
|
0 commit comments