|
11 | 11 | import sys |
12 | 12 | from decimal import Decimal |
13 | 13 | import datetime |
14 | | - |
| 14 | +import re |
15 | 15 | from osa import osadb |
16 | 16 | from osa.configs import options |
17 | 17 | from osa.configs.config import cfg |
@@ -210,34 +210,32 @@ def update_sequence_status(seq_list): |
210 | 210 |
|
211 | 211 |
|
212 | 212 | def check_catB_status(seq): |
213 | | - catbstatus = 'None' |
| 213 | + catbstatus = "None" |
| 214 | + |
214 | 215 | if seq.type == "DATA": |
215 | 216 | directory = options.directory |
216 | | - # Buscar archivos "closed" |
| 217 | + |
217 | 218 | closed_files = list(directory.glob(f"catB*{seq.run}*.closed")) |
218 | | - if any(f.exists() for f in closed_files): |
219 | | - catbstatus = 'CLOSED' |
| 219 | + if closed_files: |
| 220 | + catbstatus = "CLOSED" |
220 | 221 | else: |
221 | 222 | log_files = list(options.log_directory.glob(f"catB_calibration_{seq.run}_*.err")) |
| 223 | + if log_files: |
| 224 | + filename = sorted(log_files)[-1].name |
| 225 | + match = re.search(f"catB_calibration_{seq.run}_(\d+).err", filename) |
| 226 | + if match: |
| 227 | + job_id = match.group(1) |
222 | 228 |
|
223 | | - if log_files and any(f.exists() for f in log_files): |
224 | | - status_set = False |
225 | | - for f in log_files: |
226 | | - if f.exists(): |
227 | | - with f.open("r") as fh: |
228 | | - for line in fh: |
229 | | - if "CRITICAL" in line: |
230 | | - seq.catbstatus = 'FAILED' |
231 | | - status_set = True |
| 229 | + sacct_output = run_sacct(job_id) |
| 230 | + sacct_info = get_sacct_output(sacct_output) |
232 | 231 |
|
233 | | - |
234 | | - # Si ningún log tenía CRITICAL/ERROR pero existen archivos |
235 | | - if not status_set and any(f.exists() for f in log_files): |
236 | | - catbstatus = 'RUNNING' |
| 232 | + if not sacct_info.empty: |
| 233 | + catbstatus = sacct_info.iloc[0]["State"] |
237 | 234 |
|
238 | 235 | return catbstatus |
239 | 236 |
|
240 | 237 |
|
| 238 | + |
241 | 239 | def get_status_for_sequence(sequence, data_level) -> int: |
242 | 240 | """ |
243 | 241 | Get number of files produced for a given sequence and data level. |
|
0 commit comments