DAQ: added ingest scan to rotation and screening. And fucntionality in aaredb

This commit is contained in:
appleb_m
2025-12-12 14:35:58 +01:00
parent 9f85c07965
commit ee74cdc92a
2 changed files with 44 additions and 1 deletions
+42 -1
View File
@@ -29,7 +29,7 @@ from aaredaqlib.models import (
PuckLoadedInfo,
DewarAddress,
SampleShortInfoList,
DAQStatusModel, SessionStatus,
DAQStatusModel, SessionStatus, ScanResultPayloadModel,
)
from aaredaqlib.beamline import MXBeamline
@@ -420,3 +420,44 @@ class AareWrapper:
print(e)
raise e
def ingest_scan(self, sample: Optional[SampleShortInfo], result: ScanResult,
geom: SampleGeometryModel, beam_mark_pxl:tuple[float,float]):
if sample is None:
return
payload = self.format_scan_payload(sample, result, geom, beam_mark_pxl).model_dump()
if payload is None:
return
url = f"{self.__host}/protected_router/scan_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_scan_payload(self, sample: Optional[SampleShortInfo], result:ScanResult,
geom:SampleGeometryModel,
beam_mark_pxl:tuple[float,float]) -> ScanResultPayloadModel|None:
try:
payload = ScanResultPayloadModel(
result = result,
sample_id = sample.db_id,
attach_image = True,
beam_mark_pxl = beam_mark_pxl,
beam_size_mm = geom.beam_size_mm
)
return payload
except Exception as e:
print(e)
raise e
+2
View File
@@ -742,6 +742,8 @@ class AareDAQ:
if self.sample is not None and self.sample.db_id is not None:
self.save_screenshot_db(self.sample.db_id, "after_dc")
self.__aare.ingest_scan(sample=self.sample, result=result,
geom=self.sample_geometry, beam_mark_pxl=self.__cfg.get_beam_mark(self.zoom))
return CompletedRotationScan(request=copy.deepcopy(request), result=result)