| @@ 185-210 (lines=26) @@ | ||
| 182 | depends_on_always_run=False): |
|
| 183 | job_id = None |
|
| 184 | ||
| 185 | if depends_on and depends_on_always_run: |
|
| 186 | cmd = 'bsub -w "ended(%s)" < %s ' % (depends_on, script_name) |
|
| 187 | with os.popen(cmd) as f: |
|
| 188 | output = f.readline() |
|
| 189 | try: |
|
| 190 | job_id = int(output.split(' ')[1].replace( |
|
| 191 | '<', '').replace('>', '')) |
|
| 192 | except: |
|
| 193 | print 'Job submission failed: ' + output |
|
| 194 | elif depends_on is not None: |
|
| 195 | cmd = 'bsub -w "done(%s)" < %s ' % (depends_on, script_name) |
|
| 196 | with os.popen(cmd) as f: |
|
| 197 | output = f.readline() |
|
| 198 | try: |
|
| 199 | job_id = int(output.split(' ')[1].replace( |
|
| 200 | '<', '').replace('>', '')) |
|
| 201 | except: |
|
| 202 | print 'Job submission failed: ' + output |
|
| 203 | else: |
|
| 204 | with os.popen('bsub <' + script_name) as f: |
|
| 205 | output = f.readline() |
|
| 206 | try: |
|
| 207 | job_id = int(output.split(' ')[1].replace( |
|
| 208 | '<', '').replace('>', '')) |
|
| 209 | except: |
|
| 210 | print 'Job submission failed: ' + output |
|
| 211 | return job_id |
|
| 212 | ||
| 213 | ||
| @@ 171-191 (lines=21) @@ | ||
| 168 | depends_on_always_run=False): |
|
| 169 | job_id = None |
|
| 170 | if not immediate: |
|
| 171 | if depends_on and depends_on_always_run: |
|
| 172 | with os.popen('sbatch --kill-on-invalid-dep=yes --dependency=afterany:%s %s' % (depends_on, script_name)) as f: |
|
| 173 | output = f.readline() |
|
| 174 | try: |
|
| 175 | job_id = int(output.split(' ')[-1].strip()) |
|
| 176 | except: |
|
| 177 | print 'Job submission failed: ' + output |
|
| 178 | elif depends_on is not None: |
|
| 179 | with os.popen('sbatch --kill-on-invalid-dep=yes --dependency=afterok:%s %s' % (depends_on, script_name)) as f: |
|
| 180 | output = f.readline() |
|
| 181 | try: |
|
| 182 | job_id = int(output.split(' ')[-1].strip()) |
|
| 183 | except: |
|
| 184 | print 'Job submission failed: ' + output |
|
| 185 | else: |
|
| 186 | with os.popen('sbatch ' + script_name) as f: |
|
| 187 | output = f.readline() |
|
| 188 | try: |
|
| 189 | job_id = int(output.split(' ')[-1].strip()) |
|
| 190 | except: |
|
| 191 | print 'Job submission failed: ' + output |
|
| 192 | # Get job id and record in database |
|
| 193 | else: |
|
| 194 | with os.popen('grep -- "SBATCH -p" ' + script_name + ' | sed \'s/#SBATCH//\'') as f: |
|