DAQ: ingest script for screening - WIP

This commit is contained in:
appleb_m committed 2025-12-02 13:31:18 +01:00
1 parent 12bb65e1bd
commit 6633aa5680
1 file changed
+29 -1
+29 -1
View File
@@ -33,7 +33,7 @@ from aaredaqlib.models import (
)
from aaredaqlib.beamline import MXBeamline
from aaredaqlib.raster_grid import RasterGridRequest, CompletedRasterGrid, RasterPayloadModel, CenterOfMassModel
from aaredaqlib.raster_grid import RasterGridRequest, RasterPayloadModel, CenterOfMassModel, ScreeningPayloadModel
from aaredaqlib.rotation_scan import RotationScanRequest
from aaredaqlib.sample_geometry import SampleGeometryModel
@@ -420,4 +420,32 @@ class AareWrapper:
print(e)
raise e
def ingest_screening(self, sample: Optional[SampleShortInfo], screening_result:ScanResult):
if sample is None:
return
payload = self.format_screening_payload(sample, screening_result=screening_result).model_dump()
if payload is None:
return
url = f"{self.__host}/protected_router/gridscan_runner/ingest"
headers = {
"accept": "application/json",
"X-Shared-Password": os.getenv("AAREDB_SHARED_PASSWORD")
}
response = requests.post(url,
auth=(os.getenv("AAREDB_USERNAME"), os.getenv("AAREDB_PASSWORD")),
headers=headers, data=json.dumps(payload), timeout=30, verify=False)
response.raise_for_status()
print(f"Response status code: {response.status_code}")
def format_screening_payload(self, sample: Optional[SampleShortInfo], screening_result:ScanResult):
return ScreeningPayloadModel(
sample_id=sample.db_id,
result=screening_result,
attach_image=True
)