|
7 | 7 | import subprocess |
8 | 8 | import time |
9 | 9 | from datetime import datetime |
10 | | -from functools import partial, singledispatch, wraps |
| 10 | +from functools import partial, singledispatch |
11 | 11 | from pathlib import Path |
12 | 12 | from threading import Thread |
13 | | -from typing import Any, Callable, Dict, List, NamedTuple, Tuple |
| 13 | +from typing import Any, Dict, List, NamedTuple, Tuple |
14 | 14 |
|
15 | 15 | import mrcfile |
16 | 16 | import numpy as np |
@@ -96,47 +96,6 @@ class JobIDs(NamedTuple): |
96 | 96 | client_id: int |
97 | 97 |
|
98 | 98 |
|
99 | | -def record_failure( |
100 | | - f: Callable, record_queue: str = "", is_callback: bool = True |
101 | | -) -> Callable: |
102 | | - @wraps(f) |
103 | | - def wrapper( |
104 | | - *args, |
105 | | - record_queue: str = record_queue, |
106 | | - is_callback: bool = is_callback, |
107 | | - **kwargs, |
108 | | - ): |
109 | | - try: |
110 | | - message = args[0] |
111 | | - session_id = message["session_id"] |
112 | | - instrument_name = ( |
113 | | - murfey_db.exec(select(db.Session).where(db.Session.id == session_id)) |
114 | | - .one() |
115 | | - .instrument_name |
116 | | - ) |
117 | | - except Exception: |
118 | | - logger.warning( |
119 | | - "Could not record message failure as the instrument name could not be determined" |
120 | | - ) |
121 | | - try: |
122 | | - return f(*args, **kwargs) |
123 | | - except Exception: |
124 | | - logger.warning(f"Call to {f} failed", exc_info=True) |
125 | | - if _transport_object and is_callback: |
126 | | - machine_config = get_machine_config().get(instrument_name) |
127 | | - if not machine_config: |
128 | | - return None |
129 | | - if not record_queue: |
130 | | - record_queue = ( |
131 | | - machine_config.failure_queue |
132 | | - or f"dlq.{_transport_object.feedback_queue}" |
133 | | - ) |
134 | | - _transport_object.send(record_queue, args[0], new_connection=True) |
135 | | - return None |
136 | | - |
137 | | - return wrapper |
138 | | - |
139 | | - |
140 | 99 | def sanitise(in_string: str) -> str: |
141 | 100 | return in_string.replace("\r\n", "").replace("\n", "") |
142 | 101 |
|
@@ -1954,7 +1913,6 @@ def _register_initial_model(message: dict, _db=murfey_db, demo: bool = False): |
1954 | 1913 | _db.close() |
1955 | 1914 |
|
1956 | 1915 |
|
1957 | | -@record_failure |
1958 | 1916 | def _flush_spa_preprocessing(message: dict): |
1959 | 1917 | session_id = message["session_id"] |
1960 | 1918 | stashed_files = murfey_db.exec( |
@@ -2064,7 +2022,6 @@ def _flush_spa_preprocessing(message: dict): |
2064 | 2022 | return None |
2065 | 2023 |
|
2066 | 2024 |
|
2067 | | -@record_failure |
2068 | 2025 | def _flush_tomography_preprocessing(message: dict): |
2069 | 2026 | session_id = message["session_id"] |
2070 | 2027 | instrument_name = ( |
|
0 commit comments