From 849101f320cfb81c1ce9db7b41e2c5584a2efd24 Mon Sep 17 00:00:00 2001 From: "Sode, Adedamola (DLSLtd,RAL,LSCI)" Date: Wed, 29 Apr 2026 13:21:41 +0000 Subject: [PATCH 1/3] Added conditions for branched services --- src/techui_builder/__main__.py | 24 ++++++++++++++++++++++-- src/techui_builder/builder.py | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/techui_builder/__main__.py b/src/techui_builder/__main__.py index 08b6f04..21e8f6b 100644 --- a/src/techui_builder/__main__.py +++ b/src/techui_builder/__main__.py @@ -75,13 +75,33 @@ def find_dirs(file_path: Path, beamline: str) -> tuple: ), None, ) + + if ixx_services_dir is None and ( + beamline.startswith("j") or beamline.startswith("k") + ): + # If not found, try searching for Ixx-services as some + # J/K beamlines are in Ixx-services dir + logger_.debug( + f"{beamline}-services not found. Searching for I{beamline[1:]}-services..." + ) + ixx_services_dir = next( + ( + ixx_services.relative_to(cwd, walk_up=True) + for parent in abs_path.parents + for ixx_services in parent.glob(f"i{beamline[1:]}-services") + ), + None, + ) + if ixx_services_dir is None: - logging.critical("ixx-services not found. Is you file structure correct?") + logging.critical( + f"{beamline}-services not found. Is you file structure correct?" + ) exit() logger_.debug(f"ixx-services relative path: {ixx_services_dir}") # Get the synoptic dir relative to the parent dir - synoptic_dir = ixx_services_dir.joinpath("synoptic") + synoptic_dir = abs_path.parent logger_.debug(f"synoptic relative path: {synoptic_dir}") return ixx_services_dir, synoptic_dir diff --git a/src/techui_builder/builder.py b/src/techui_builder/builder.py index 1336afb..0af22ff 100644 --- a/src/techui_builder/builder.py +++ b/src/techui_builder/builder.py @@ -85,7 +85,7 @@ def clean_files(self): logger_.info("Preserving edited screens for validation.") logger_.debug(f"Screens to validate: {list(self.validator.validate.keys())}") - logger_.info("Cleaning synoptic/ of generated screens.") + logger_.info("Cleaning synoptic directory of generated screens.") try: # Find the JsonMap file From d2e3c3d777c8ef0d8ba4320d7ba5cf5a4234c147 Mon Sep 17 00:00:00 2001 From: "Sode, Adedamola (DLSLtd,RAL,LSCI)" Date: Wed, 29 Apr 2026 14:31:11 +0000 Subject: [PATCH 2/3] modified test_find_dirs --- tests/test_cli.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 1986be7..b4faeb3 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -53,14 +53,16 @@ def test_find_dirs(caplog): mock_services.relative_to.return_value = Path("mock_rel_path") mock_parent = MagicMock(spec=Path) mock_parent.glob.return_value = [mock_services] - mock_absolute = MagicMock() + mock_absolute = MagicMock(spec=Path) mock_absolute.parents = [mock_parent] + mock_absolute.parent = mock_parent mock_path = MagicMock(spec=Path) mock_path.absolute.return_value = mock_absolute services, synoptic = find_dirs(mock_path, "ixx") - assert synoptic == Path("mock_rel_path/synoptic") + assert synoptic == mock_absolute.parent + assert services == Path("mock_rel_path") def test_find_dirs_no_ixx_services_dir(caplog): From 274a7e9d71bd5c0a2398b78a877dadbd0c900946 Mon Sep 17 00:00:00 2001 From: "Sode, Adedamola (DLSLtd,RAL,LSCI)" Date: Thu, 30 Apr 2026 09:45:08 +0000 Subject: [PATCH 3/3] removed duplication --- src/techui_builder/__main__.py | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/techui_builder/__main__.py b/src/techui_builder/__main__.py index 21e8f6b..c4f1fb0 100644 --- a/src/techui_builder/__main__.py +++ b/src/techui_builder/__main__.py @@ -66,33 +66,25 @@ def find_dirs(file_path: Path, beamline: str) -> tuple: cwd = Path.cwd() logger_.debug(f"Working directory: {cwd}") + directory = beamline + + if beamline.startswith("j") or beamline.startswith("k"): + # If not found, try searching for Ixx-services as some + # J/K beamlines are in Ixx-services dir + directory = f"i{beamline[1:]}" + logger_.debug( + f"{beamline}-services not found. Searching for I{beamline[1:]}-services..." + ) # Get the relative path of ixx-services to techui.yaml ixx_services_dir = next( ( ixx_services.relative_to(cwd, walk_up=True) for parent in abs_path.parents - for ixx_services in parent.glob(f"{beamline}-services") + for ixx_services in parent.glob(f"{directory}-services") ), None, ) - if ixx_services_dir is None and ( - beamline.startswith("j") or beamline.startswith("k") - ): - # If not found, try searching for Ixx-services as some - # J/K beamlines are in Ixx-services dir - logger_.debug( - f"{beamline}-services not found. Searching for I{beamline[1:]}-services..." - ) - ixx_services_dir = next( - ( - ixx_services.relative_to(cwd, walk_up=True) - for parent in abs_path.parents - for ixx_services in parent.glob(f"i{beamline[1:]}-services") - ), - None, - ) - if ixx_services_dir is None: logging.critical( f"{beamline}-services not found. Is you file structure correct?"