|
14 | 14 | from werkzeug.utils import secure_filename |
15 | 15 |
|
16 | 16 | try: |
| 17 | + from smartem_backend.api_client import EntityConverter |
17 | 18 | from smartem_common.schemas import AcquisitionData |
18 | 19 |
|
19 | 20 | SMARTEM_ACTIVE = True |
@@ -157,13 +158,23 @@ async def setup_multigrid_watcher( |
157 | 158 | async with aiohttp.ClientSession() as clientsession: |
158 | 159 | acquisition_uuid = None |
159 | 160 | if SMARTEM_ACTIVE and machine_config.smartem_api_url: |
160 | | - acquisition_data = AcquisitionData(name=visit) |
161 | | - async with clientsession.post( |
162 | | - f"{machine_config.smartem_api_url}/acquisitions", |
163 | | - acquisition_data.model_json_schema(), |
164 | | - ) as response: |
165 | | - acquisition_response_data = await response.json() |
166 | | - acquisition_uuid = acquisition_response_data.uuid |
| 161 | + log.info("registering an acquisition with smartem") |
| 162 | + try: |
| 163 | + acquisition_data = EntityConverter.acquisition_to_request( |
| 164 | + AcquisitionData(name=visit) |
| 165 | + ) |
| 166 | + async with clientsession.post( |
| 167 | + f"{machine_config.smartem_api_url}/acquisitions", |
| 168 | + json=acquisition_data.model_dump(), |
| 169 | + ) as response: |
| 170 | + acquisition_response_data = await response.json() |
| 171 | + acquisition_uuid = acquisition_response_data["uuid"] |
| 172 | + except Exception: |
| 173 | + log.warning( |
| 174 | + "failed to register acquisition with smartem", exc_info=True |
| 175 | + ) |
| 176 | + else: |
| 177 | + log.info("smartem not configured") |
167 | 178 | async with clientsession.post( |
168 | 179 | f"{machine_config.instrument_server_url}{url_path_for('api.router', 'setup_multigrid_watcher', session_id=session_id)}", |
169 | 180 | json={ |
|
0 commit comments