Skip to content

Commit

Permalink
Only use config server if GDA didn't supply params
Browse files Browse the repository at this point in the history
  • Loading branch information
olliesilvester committed Sep 16, 2024
1 parent 470361a commit 33b1666
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/mx_bluesky/hyperion/external_interaction/config_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def config_server() -> ConfigServer:
class FeatureFlags(BaseModel):
# The default value will be used as the fallback when doing a best-effort fetch
# from the service
use_panda_for_gridscan: bool = False
use_gpu_for_gridscan: bool = False
set_stub_offsets: bool = False
use_panda_for_gridscan: bool = CONST.I03.USE_PANDA_FOR_GRIDSCAN
use_gpu_for_gridscan: bool = CONST.I03.USE_PANDA_FOR_GRIDSCAN
set_stub_offsets: bool = CONST.I03.SET_STUB_OFFSETS

@classmethod
def _get_flags(cls):
Expand Down
1 change: 1 addition & 0 deletions src/mx_bluesky/hyperion/parameters/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class I03Constants:
USE_PANDA_FOR_GRIDSCAN = False
USE_GPU_FOR_GRIDSCAN_ANALYSIS = False
THAWING_TIME = 20
SET_STUB_OFFSETS = False


@dataclass(frozen=True)
Expand Down
27 changes: 24 additions & 3 deletions src/mx_bluesky/hyperion/parameters/gridscan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import os
from typing import Any

from dodal.devices.aperturescatterguard import ApertureValue
from dodal.devices.detector import (
Expand All @@ -10,10 +11,11 @@
PandAGridScanParams,
ZebraGridScanParams,
)
from pydantic import Field, PrivateAttr
from pydantic import Field, PrivateAttr, model_validator
from scanspec.core import Path as ScanPath
from scanspec.specs import Line, Static

from mx_bluesky.hyperion.external_interaction.config_server import FeatureFlags
from mx_bluesky.hyperion.parameters.components import (
DiffractionExperimentWithSample,
IspybExperimentType,
Expand All @@ -29,19 +31,38 @@
class GridCommon(
DiffractionExperimentWithSample, OptionalGonioAngleStarts, WithOavCentring
):
use_panda: bool
use_gpu: bool
grid_width_um: float = Field(default=CONST.PARAM.GRIDSCAN.WIDTH_UM)
exposure_time_s: float = Field(default=CONST.PARAM.GRIDSCAN.EXPOSURE_TIME_S)
use_roi_mode: bool = Field(default=CONST.PARAM.GRIDSCAN.USE_ROI)
panda_runup_distance_mm: float = Field(
default=CONST.HARDWARE.PANDA_FGS_RUN_UP_DEFAULT
)
use_panda: bool = Field(default=CONST.I03.USE_PANDA_FOR_GRIDSCAN)
use_gpu: bool = Field(default=CONST.I03.USE_GPU_FOR_GRIDSCAN_ANALYSIS)
ispyb_experiment_type: IspybExperimentType = Field(
default=IspybExperimentType.GRIDSCAN_3D
)
selected_aperture: ApertureValue | None = Field(default=ApertureValue.SMALL)

# @model_validator(mode="wrap")
# @classmethod
# def set_default_feature_flags(cls, values, handler) -> Any:
# if "use_panda" not in values:
# values["use_panda"] = cls.features.best_effort().use_panda_for_gridscan
# if "use_gpu" not in values:
# values["use_gpu"] = cls.features.best_effort().use_gpu_for_gridscan
# return values

@model_validator(mode="before")
@classmethod
def set_default_feature_flags(cls, values) -> Any:
cls.features = FeatureFlags()
if "use_panda" not in values:
values["use_panda"] = cls.features.best_effort().use_panda_for_gridscan
if "use_gpu" not in values:
values["use_gpu"] = cls.features.best_effort().use_gpu_for_gridscan
return values

@property
def detector_params(self):
self.det_dist_to_beam_converter_path = (
Expand Down

0 comments on commit 33b1666

Please sign in to comment.