@@ 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: |
@@ 135-158 (lines=24) @@ | ||
132 | ||
133 | def submit(script_name, immediate, depends_on=None, |
|
134 | depends_on_always_run=False): |
|
135 | job_id = None |
|
136 | if not immediate: |
|
137 | if depends_on and depends_on_always_run: |
|
138 | with os.popen('qsub -W depend=afterany:%s %s' % (depends_on, script_name)) as f: |
|
139 | output = f.readline() |
|
140 | try: |
|
141 | job_id = output.strip().split('.')[0] |
|
142 | except: |
|
143 | print 'Job submission failed: ' + output |
|
144 | elif depends_on is not None: |
|
145 | with os.popen('qsub -W depend=afterok:%s %s' % (depends_on, script_name)) as f: |
|
146 | output = f.readline() |
|
147 | try: |
|
148 | job_id = output.strip().split('.')[0] |
|
149 | except: |
|
150 | print 'Job submission failed: ' + output |
|
151 | else: |
|
152 | with os.popen('qsub ' + script_name) as f: |
|
153 | output = f.readline() |
|
154 | try: |
|
155 | job_id = output.strip().split('.')[0] |
|
156 | except: |
|
157 | print 'Job submission failed: ' + output |
|
158 | else: |
|
159 | print "immediate not yet implemented for PBS" |
|
160 | return job_id |
|
161 |