fix: general fixes
CI / lint (push) Skipped
CI / test (3.12) (push) Skipped
CI / test (3.13) (push) Skipped
CI / test-with-beamline-plugins (pxi_bec) (push) Skipped
CI / test-with-beamline-plugins (pxii_bec) (push) Skipped
CI / test-with-beamline-plugins (pxiii_bec) (push) Skipped
CI / lint (pull_request) Failing after 52s
CI / test (3.12) (pull_request) Successful in 1m2s
CI / test (3.14) (pull_request) Successful in 1m11s
CI / test-with-beamline-plugins (pxi_bec) (pull_request) Successful in 1m9s
CI / test (3.13) (pull_request) Successful in 1m15s
CI / test-with-beamline-plugins (pxii_bec) (pull_request) Successful in 1m13s
CI / test-with-beamline-plugins (pxiii_bec) (pull_request) Successful in 1m23s
CI / test-with-coverage (pull_request) Successful in 1m39s
CI / coverage-analysis (pull_request) Failing after 3s
CI / lint (push) Skipped
CI / test (3.12) (push) Skipped
CI / test (3.13) (push) Skipped
CI / test-with-beamline-plugins (pxi_bec) (push) Skipped
CI / test-with-beamline-plugins (pxii_bec) (push) Skipped
CI / test-with-beamline-plugins (pxiii_bec) (push) Skipped
CI / lint (pull_request) Failing after 52s
CI / test (3.12) (pull_request) Successful in 1m2s
CI / test (3.14) (pull_request) Successful in 1m11s
CI / test-with-beamline-plugins (pxi_bec) (pull_request) Successful in 1m9s
CI / test (3.13) (pull_request) Successful in 1m15s
CI / test-with-beamline-plugins (pxii_bec) (pull_request) Successful in 1m13s
CI / test-with-beamline-plugins (pxiii_bec) (pull_request) Successful in 1m23s
CI / test-with-coverage (pull_request) Successful in 1m39s
CI / coverage-analysis (pull_request) Failing after 3s
This commit is contained in:
+8
-13
@@ -426,17 +426,12 @@ class AareWrapper:
|
||||
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,
|
||||
)
|
||||
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:
|
||||
logger.error(e)
|
||||
raise
|
||||
return payload
|
||||
|
||||
@@ -610,12 +610,12 @@ class BeamlineConfig:
|
||||
|
||||
@property
|
||||
def gridscan_analysis_mode(self) -> GridscanAnalysisMode:
|
||||
data = self._client.get(f"{self._bl}:gridscan_analysis_mode")
|
||||
data = self.redis.get(f"{self._bl}:gridscan_analysis_mode")
|
||||
return GridscanAnalysisMode(data) if data is not None else GridscanAnalysisMode.FindXtal
|
||||
|
||||
@gridscan_analysis_mode.setter
|
||||
def gridscan_analysis_mode(self, val: GridscanAnalysisMode) -> GridscanAnalysisMode:
|
||||
return self._client.set(f"{self._bl}:gridscan_analysis_mode", str(val))
|
||||
def gridscan_analysis_mode(self, val: GridscanAnalysisMode) -> None:
|
||||
self.redis.set(f"{self._bl}:gridscan_analysis_mode", str(val))
|
||||
|
||||
def _get_settings(self) -> BeamlineSettingsModel:
|
||||
tmp = self.redis.get(f"{self._bl}:settings")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import copy
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
from math import ceil, floor
|
||||
|
||||
from aarecommon.config.config_models import GridscanAnalysisMode
|
||||
@@ -22,6 +23,7 @@ from aarecommon.math.find_xtal import (
|
||||
)
|
||||
from aarecommon.math.jfjoch_gridscan_union import GridScanResult, Thresholds, analyse
|
||||
from aarecommon.math.raster_grid import grid_to_image_id
|
||||
from aarecommon.models.gridscan_decision import GridScanDecision
|
||||
from aarecommon.models.models import BeamlineStateEnum
|
||||
from aarecommon.models.raster_grid import (
|
||||
CenterOfMassModel,
|
||||
@@ -30,7 +32,6 @@ from aarecommon.models.raster_grid import (
|
||||
RasterGridRequest,
|
||||
)
|
||||
from aareDB import SampleEventType
|
||||
from bec_lib.redis_connector.streams import dataclass
|
||||
from jfjoch_client import ScanResult
|
||||
from jfjoch_client.exceptions import NotFoundException
|
||||
from jfjoch_client.models.grid_scan import GridScan
|
||||
@@ -86,8 +87,8 @@ class RasterService:
|
||||
smargon_coord = self._smargon_offset_from_scan_result(scan_result, request, com)
|
||||
v2_results = None
|
||||
else:
|
||||
step_x_um = (request.grid_size_mm.x / request.n_x) * 1000
|
||||
step_y_um = (request.grid_size_mm.y / request.n_y) * 1000
|
||||
step_x_um = request.grid_size_mm.x * 1000
|
||||
step_y_um = request.grid_size_mm.y * 1000
|
||||
grid_scan = GridScan(
|
||||
n_fast=request.n_x, step_x_um=step_x_um, step_y_um=step_y_um, snake=True
|
||||
)
|
||||
@@ -455,6 +456,7 @@ class RasterService:
|
||||
self,
|
||||
request: RasterGridRequest,
|
||||
scan_result: ScanResult,
|
||||
analysis_result: _AnalysisResults,
|
||||
wait_for_screenshot_s: float,
|
||||
sample_id: int,
|
||||
):
|
||||
@@ -468,42 +470,40 @@ class RasterService:
|
||||
self.ctx.services.screenshots.save_to_db(
|
||||
sample_id, f"{sample_id}_post_raster_{int(request.omega_deg)}deg"
|
||||
)
|
||||
|
||||
if analysis_result.v2_results is not None:
|
||||
decision = GridScanDecision(algorithm="unknown", result=analysis_result.v2_results)
|
||||
else:
|
||||
decision = None
|
||||
self.ingestor.ingest_gridscan(
|
||||
sample=self.ctx.sample,
|
||||
raster_result=scan_result,
|
||||
raster_request=request,
|
||||
analysis_image_scores=analysis_result.scores,
|
||||
geom=self.ctx.sample_geometry,
|
||||
com=None,
|
||||
com=analysis_result.com,
|
||||
beam_mark_pxl=self.ctx.deps.cfg.get_beam_mark(self.ctx.deps.devs.zoom),
|
||||
decision=decision,
|
||||
)
|
||||
|
||||
def _additional_analysis_data_ingestion(self, results: GridScanResult): ...
|
||||
def execute(
|
||||
self, request: RasterGridRequest, wait_for_screenshot: float | None = None
|
||||
) -> CompletedRasterGridElem:
|
||||
total_time, wait_for_screenshot = self._check_setup(request, wait_for_screenshot)
|
||||
status = self.ctx.status
|
||||
|
||||
smargon_top_left = request.smargon_top_left
|
||||
self.ctx.deps.devs.set_smargon_pos(
|
||||
SmargonCoordinate(
|
||||
sh_mm=smargon_top_left.sh_mm,
|
||||
phi_deg=smargon_top_left.phi_deg,
|
||||
chi_deg=smargon_top_left.chi_deg,
|
||||
)
|
||||
)
|
||||
|
||||
self.logger.info(
|
||||
"Starting raster acquisition",
|
||||
extra=merge_log_context(
|
||||
sample_log_context(self.ctx.sample),
|
||||
raster_request_log_context(request),
|
||||
{"state": getattr(status, "state", None)},
|
||||
),
|
||||
)
|
||||
|
||||
try:
|
||||
total_time, wait_for_screenshot = self._check_setup(request, wait_for_screenshot)
|
||||
status = self.ctx.status
|
||||
|
||||
if request.smargon_top_left is not None:
|
||||
self.ctx.deps.devs.set_smargon_pos(request.smargon_top_left)
|
||||
|
||||
self.logger.info(
|
||||
"Starting raster acquisition",
|
||||
extra=merge_log_context(
|
||||
sample_log_context(self.ctx.sample),
|
||||
raster_request_log_context(request),
|
||||
{"state": getattr(status, "state", None)},
|
||||
),
|
||||
)
|
||||
|
||||
if self.ctx.sample is not None and self.ctx.sample.db_id is not None:
|
||||
self.ctx.deps.aare.create_gridscan_run(self.ctx.sample, request, status)
|
||||
|
||||
@@ -545,11 +545,8 @@ class RasterService:
|
||||
)
|
||||
if sample_id:
|
||||
self._initial_gridscan_ingestion(
|
||||
request, scan_result, wait_for_screenshot, sample_id
|
||||
request, scan_result, analysis_results, wait_for_screenshot, sample_id
|
||||
)
|
||||
if analysis_results.v2_results is not None:
|
||||
self._additional_analysis_data_ingestion(analysis_results.v2_results)
|
||||
|
||||
diffraction_image_id = analysis_results.com.max_image
|
||||
diffraction_image_filename = (
|
||||
f"{sample_id}_best_diffraction_from_raster_image_{diffraction_image_id}"
|
||||
|
||||
@@ -612,9 +612,9 @@ class LocalContactPanel(QFrame):
|
||||
|
||||
analysis_settings = QGroupBox("Analysis settings", tab)
|
||||
analysis_settings_layout = QGridLayout(analysis_settings)
|
||||
form_layout.setContentsMargins(10, 12, 10, 10)
|
||||
form_layout.setHorizontalSpacing(8)
|
||||
form_layout.setVerticalSpacing(8)
|
||||
analysis_settings_layout.setContentsMargins(10, 12, 10, 10)
|
||||
analysis_settings_layout.setHorizontalSpacing(8)
|
||||
analysis_settings_layout.setVerticalSpacing(8)
|
||||
analysis_choice_label = QLabel("Gridscan analysis mode:", analysis_settings)
|
||||
find_xtal_button = QPushButton('classic "find_xtal.py"', analysis_settings)
|
||||
jfj_gs_u_button = QPushButton('Meitian\'s "jfjoch_gridscan_union.py"', analysis_settings)
|
||||
|
||||
@@ -370,21 +370,3 @@ def test_format_gridscan_payload_with_top_left(mock_api, mock_bl, sample_info, g
|
||||
GridScanDecision(algorithm="none", result=GridScanResult(found=False)),
|
||||
)
|
||||
assert payload.sample_id == sample_info.db_id
|
||||
|
||||
|
||||
@patch("aareDB.ApiClient")
|
||||
def test_format_gridscan_payload_error(mock_api, mock_bl, sample_info, caplog):
|
||||
wrapper = AareWrapper(bl=mock_bl)
|
||||
# Passing None for geom_model should trigger an error in smargon_to_picture
|
||||
with pytest.raises(AttributeError):
|
||||
wrapper.format_gridscan_payload(sample_info, None, None, None, None, None, (0, 0), None) # type: ignore # intended
|
||||
assert "NoneType" in caplog.text
|
||||
|
||||
|
||||
@patch("aareDB.ApiClient")
|
||||
def test_format_scan_payload_error(mock_api, mock_bl, sample_info, caplog):
|
||||
wrapper = AareWrapper(bl=mock_bl)
|
||||
with pytest.raises(AttributeError):
|
||||
# Passing None for geom should trigger error when accessing geom.beam_size_mm
|
||||
wrapper.format_scan_payload(sample_info, None, None, (0, 0)) # type: ignore # intended
|
||||
assert "NoneType" in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user