@@ 185-208 (lines=24) @@ | ||
182 | depends_on_always_run=False): |
|
183 | job_id = None |
|
184 | ||
185 | if depends_on and depends_on_always_run: |
|
186 | with os.popen('bsub -w "ended(%s)" < %s ' % (depends_on, script_name)) as f: |
|
187 | output = f.readline() |
|
188 | try: |
|
189 | job_id = int(output.split(' ')[1].replace( |
|
190 | '<', '').replace('>', '')) |
|
191 | except: |
|
192 | print 'Job submission failed: ' + output |
|
193 | elif depends_on is not None: |
|
194 | with os.popen('bsub -w "done(%s)" < %s ' % (depends_on, script_name)) as f: |
|
195 | output = f.readline() |
|
196 | try: |
|
197 | job_id = int(output.split(' ')[1].replace( |
|
198 | '<', '').replace('>', '')) |
|
199 | except: |
|
200 | print 'Job submission failed: ' + output |
|
201 | else: |
|
202 | with os.popen('bsub <' + script_name) as f: |
|
203 | output = f.readline() |
|
204 | try: |
|
205 | job_id = int(output.split(' ')[1].replace( |
|
206 | '<', '').replace('>', '')) |
|
207 | except: |
|
208 | print 'Job submission failed: ' + output |
|
209 | return job_id |
|
210 | ||
211 |
@@ 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 |