|
47 | 47 |
|
48 | 48 |
|
49 | 49 | EXCEPTION_MSG = {
|
50 |
| - -1: "Unknown", |
51 | 50 | 0: "OK",
|
52 | 51 | 1: "No level 0 data",
|
53 | 52 | 2: "No telemetry data",
|
54 | 53 | 3: "Mismatch in telemetry between aca_l0 and cheta",
|
55 | 54 | 4: "Time mismatch between cheta and level0",
|
56 | 55 | 5: "Failed job",
|
57 | 56 | 6: "Suspect observation",
|
| 57 | + 1000: "Unknown", |
58 | 58 | }
|
59 |
| -EXCEPTION_CODES = collections.defaultdict(lambda: -1) |
| 59 | +EXCEPTION_CODES = collections.defaultdict(lambda: 1000) |
60 | 60 | EXCEPTION_CODES.update({msg: code for code, msg in EXCEPTION_MSG.items() if code > 0})
|
61 | 61 |
|
62 | 62 |
|
@@ -92,6 +92,16 @@ def __init__(
|
92 | 92 | "traceback": "\n".join(stack_trace),
|
93 | 93 | }
|
94 | 94 |
|
| 95 | + def _failed_(self): |
| 96 | + """ |
| 97 | + Check if the exception is a failure. |
| 98 | +
|
| 99 | + :return: bool |
| 100 | + """ |
| 101 | + return self.error_code > 1 |
| 102 | + |
| 103 | + failed = property(_failed_) |
| 104 | + |
95 | 105 | def __str__(self):
|
96 | 106 | return (
|
97 | 107 | f"MagStatsException: {self.msg} (agasc_id: {self.agasc_id}, "
|
@@ -1310,12 +1320,12 @@ def get_agasc_id_stats(agasc_id, obs_status_override=None, tstop=None):
|
1310 | 1320 | {
|
1311 | 1321 | "obs_ok": False,
|
1312 | 1322 | "obs_suspect": False,
|
1313 |
| - "obs_fail": True, |
| 1323 | + "obs_fail": e.failed, |
1314 | 1324 | "comments": comment if excluded_obs[i] else f"Error: {e.msg}.",
|
1315 | 1325 | }
|
1316 | 1326 | )
|
1317 | 1327 | stats.append(obs_stat)
|
1318 |
| - if not excluded_obs[i]: |
| 1328 | + if e.failed and not excluded_obs[i]: |
1319 | 1329 | logger.debug(
|
1320 | 1330 | f" Error in get_agasc_id_stats({agasc_id=},"
|
1321 | 1331 | f" obsid={obs['obsid']}): {e}"
|
@@ -1351,9 +1361,7 @@ def get_agasc_id_stats(agasc_id, obs_status_override=None, tstop=None):
|
1351 | 1361 |
|
1352 | 1362 | if len(all_telem) - len(failures) <= 0:
|
1353 | 1363 | # and we reach here if some observations were not flagged as bad, but all failed.
|
1354 |
| - logger.debug( |
1355 |
| - f" Error in get_agasc_id_stats({agasc_id=}): There is no OK observation." |
1356 |
| - ) |
| 1364 | + logger.debug(f" get_agasc_id_stats({agasc_id=}): There is no OK observation.") |
1357 | 1365 | return result, stats, failures
|
1358 | 1366 |
|
1359 | 1367 | excluded_obs += np.array([t is None for t in all_telem])
|
|
0 commit comments