From 287ded9011a787737c1bcc8b7aa291fa2d5dad57 Mon Sep 17 00:00:00 2001 From: Ollie Copping Date: Wed, 11 Feb 2026 15:43:50 +0000 Subject: [PATCH 1/2] Change the model naming for short_dom and long_dom This changes them to location and domain respectively to make the naming consistent with other tools. --- src/techui_builder/__main__.py | 10 +++++----- src/techui_builder/builder.py | 2 +- src/techui_builder/models.py | 24 ++++++++++++------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/techui_builder/__main__.py b/src/techui_builder/__main__.py index db92748a..39ef411d 100644 --- a/src/techui_builder/__main__.py +++ b/src/techui_builder/__main__.py @@ -109,7 +109,7 @@ def main( ( ixx_services.relative_to(cwd, walk_up=True) for parent in abs_path.parents - for ixx_services in parent.glob(f"{gui.conf.beamline.short_dom}-services") + for ixx_services in parent.glob(f"{gui.conf.beamline.location}-services") ), None, ) @@ -148,7 +148,7 @@ def main( logger_.debug( f""" -Builder created for {gui.conf.beamline.short_dom}. +Builder created for {gui.conf.beamline.location}. Services directory: {gui._services_dir} Write directory: {gui._write_directory} """, # noqa: SLF001 @@ -158,7 +158,7 @@ def main( gui.create_screens() gui.write_status_pvs() - logger_.info(f"Screens generated for {gui.conf.beamline.short_dom}.") + logger_.info(f"Screens generated for {gui.conf.beamline.location}.") autofiller = Autofiller(bob_file) autofiller.read_bob() @@ -168,11 +168,11 @@ def main( autofiller.write_bob(dest_bob) - logger_.info(f"Screens autofilled for {gui.conf.beamline.short_dom}.") + logger_.info(f"Screens autofilled for {gui.conf.beamline.location}.") gui.write_json_map(synoptic=dest_bob, dest=gui._write_directory) # noqa: SLF001 logger_.info( - f"Json map generated for {gui.conf.beamline.short_dom} (from index.bob)" + f"Json map generated for {gui.conf.beamline.location} (from index.bob)" ) diff --git a/src/techui_builder/builder.py b/src/techui_builder/builder.py index 0c62fefb..0b5c81f4 100644 --- a/src/techui_builder/builder.py +++ b/src/techui_builder/builder.py @@ -155,7 +155,7 @@ def _extract_services(self): """ # Loop over every dir in services, ignoring anything that isn't a service - for service in self._services_dir.glob(f"{self.conf.beamline.long_dom}-*-*-*"): + for service in self._services_dir.glob(f"{self.conf.beamline.domain}-*-*-*"): # If service doesn't exist, file open will fail throwing exception try: self._extract_entities(ioc_yaml=service.joinpath("config/ioc.yaml")) diff --git a/src/techui_builder/models.py b/src/techui_builder/models.py index f42fcfdc..ca97abc8 100644 --- a/src/techui_builder/models.py +++ b/src/techui_builder/models.py @@ -50,38 +50,38 @@ r"(?:PP|NPP)?" + r"(?:[ ]+(?:MS|NMS|MSS|MSI))?$", re.VERBOSE, ) -_LONG_DOM_RE = re.compile(r"^[a-zA-Z]{2}\d{2}[a-zA-Z]$") -_SHORT_DOM_RE = re.compile(r"^[a-zA-Z]{1}\d{2}(-[0-9]{1})?$") +_DOMAIN_RE = re.compile(r"^[a-zA-Z]{2}\d{2}[a-zA-Z]$") +_LOCATION_RE = re.compile(r"^[a-zA-Z]{1}\d{2}(-[0-9]{1})?$") _OPIS_URL_RE = re.compile(r"^(https:\/\/)?([a-z0-9]{3}-(?:[0-9]-)?opis(?:.[a-z0-9]*)*)") class Beamline(BaseModel): - short_dom: str = Field(description="Short BL domain e.g. b23, ixx-1") - long_dom: str = Field(description="Full BL domain e.g. bl23b") + location: str = Field(description="Short BL location e.g. b23, ixx-1") + domain: str = Field(description="Full BL domain e.g. bl23b") desc: str = Field(description="Description") model_config = ConfigDict(extra="forbid") url: str = Field(description="URL of ixx-opis") - @field_validator("short_dom") + @field_validator("location") @classmethod - def normalize_short_dom(cls, v: str) -> str: + def normalize_location(cls, v: str) -> str: v = v.strip().lower() - if _SHORT_DOM_RE.fullmatch(v): + if _LOCATION_RE.fullmatch(v): # e.g. b23 -> bl23b return v - raise ValueError("Invalid short dom.") + raise ValueError("Invalid beamline location.") - @field_validator("long_dom") + @field_validator("domain") @classmethod - def normalize_long_dom(cls, v: str) -> str: + def normalize_domain(cls, v: str) -> str: v = v.strip().lower() - if _LONG_DOM_RE.fullmatch(v): + if _DOMAIN_RE.fullmatch(v): # already long: bl23b return v - raise ValueError("Invalid long dom.") + raise ValueError("Invalid beamline domain.") @field_validator("url") @classmethod From 79923e2d483716312dad8dcfa7be1e48f11db402 Mon Sep 17 00:00:00 2001 From: Ollie Copping Date: Wed, 11 Feb 2026 15:49:00 +0000 Subject: [PATCH 2/2] Fix tests --- example/t01-services/synoptic/techui.yaml | 4 ++-- tests/test_builder.py | 4 ++-- tests/test_models.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/example/t01-services/synoptic/techui.yaml b/example/t01-services/synoptic/techui.yaml index 616bc733..be069098 100644 --- a/example/t01-services/synoptic/techui.yaml +++ b/example/t01-services/synoptic/techui.yaml @@ -1,7 +1,7 @@ # create_gui example for Phoebus GuiBuilder beamline: - short_dom: t01 - long_dom: bl01t + location: t01 + domain: bl01t desc: Test Beamline url: t01-opis.diamond.ac.uk diff --git a/tests/test_builder.py b/tests/test_builder.py index 0e7d5d96..a9b59eda 100644 --- a/tests/test_builder.py +++ b/tests/test_builder.py @@ -19,8 +19,8 @@ @pytest.mark.parametrize( "attr, expected", [ - ("short_dom", "t01"), - ("long_dom", "bl01t"), + ("location", "t01"), + ("domain", "bl01t"), ("desc", "Test Beamline"), ], ) diff --git a/tests/test_models.py b/tests/test_models.py index 3a626338..e6a8cd55 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -11,8 +11,8 @@ @pytest.fixture def beamline() -> Beamline: return Beamline( - short_dom="t01", - long_dom="bl01t", + location="t01", + domain="bl01t", desc="Test Beamline", url="t01-opis.diamond.ac.uk", ) @@ -34,8 +34,8 @@ def gui_components() -> GuiComponentEntry: # @pytest.mark.parametrize("beamline,expected",[]) def test_beamline_object(beamline: Beamline): - assert beamline.short_dom == "t01" - assert beamline.long_dom == "bl01t" + assert beamline.location == "t01" + assert beamline.domain == "bl01t" assert beamline.desc == "Test Beamline" assert beamline.url == "https://t01-opis.diamond.ac.uk"