From ee27aeaaf88fbbfd177a76df2415b6549bc210a0 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Wed, 11 Jul 2018 10:59:14 -0500 Subject: [PATCH] Fixing bug where multiple dependencies would overwrite each other, thus causing only one dependency to be active. --- batch4py/config.yml | 2 +- batch4py/job.py | 26 ++++++++++++++++++++++++-- setup.py | 4 ++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/batch4py/config.yml b/batch4py/config.yml index f8628ef..1df9de1 100644 --- a/batch4py/config.yml +++ b/batch4py/config.yml @@ -7,7 +7,7 @@ torque: ppn: 'ppn={}' node_type: '{}' account: '-A' - depend: '-W depend={}' + attribute: '-W' walltime: '-l walltime={}' delimit: ':' job_name: '-N' diff --git a/batch4py/job.py b/batch4py/job.py index 7b82b2c..83dd51d 100644 --- a/batch4py/job.py +++ b/batch4py/job.py @@ -266,9 +266,31 @@ def submit( self, dry_run = False, stdout=None, stderr=None ): # Add extra commands args = args + self._extra_cmd + deptype = {} # Add PBS dependencies - for dep in self.dependents: - args.append( self.config['depend'].format( dep[1] + self.config['delimit'] + dep[0].get_sched_id() ) ) + if self.dependents: + args.append( self.config['attribute'] ) + for dep in self.dependents: + + # Add list to this key if we haven't seen it before + if dep[1] not in deptype: + deptype[dep[1]] = [] + + # Append to the list + deptype[ dep[1] ].append( dep[0] ) + + dep_str = "" + for type in deptype: + if dep_str: + dep_str = dep_str + "," + else: + dep_str = "depend=" + + dep_str = dep_str + type + for dep in deptype[type]: + dep_str = "{}{}{}".format( dep_str, self.config['delimit'], dep.get_sched_id()) + + args.append( dep_str ) # Add node requirements if self.nodes: diff --git a/setup.py b/setup.py index 577037a..25591be 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name='batch4py', - version='0.2.3', + version='0.2.4', author='Landon T. Clipp', author_email='clipp2@illinois.edu', packages=['batch4py'], @@ -13,7 +13,7 @@ qsub and allows for users to define complex job chains.', install_requires=[ 'pyyaml' ], url = 'https://github.com/TerraFusion/batch4py', - download_url='https://github.com/TerraFusion/batch4py/archive/0.2.2.tar.gz', + download_url='https://github.com/TerraFusion/batch4py/archive/0.2.4.tar.gz', keywords = ['batch', 'torque', 'pbs', 'pbs-torque', 'hpc', 'python', 'python3', 'cluster', 'scheduler', 'schedule' ], package_data = {'batch4py': [ os.path.join( '.', 'batch4py', 'config.yml') ] },