From 8f923dbb04e9509d6a61aeeb6adc5e6a3fe68605 Mon Sep 17 00:00:00 2001 From: Ollie Copping Date: Wed, 24 Jun 2026 12:37:15 +0000 Subject: [PATCH 1/2] Run beamline service dir check before overwriting with ixx-services --- src/techui_builder/main_app.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/techui_builder/main_app.py b/src/techui_builder/main_app.py index 0da44b30..604f38eb 100644 --- a/src/techui_builder/main_app.py +++ b/src/techui_builder/main_app.py @@ -27,13 +27,6 @@ def find_dirs(file_path: Path, beamline: str) -> tuple: directory = beamline - if not beamline.startswith("i"): - # If not found, try searching for Ixx-services as some - # J/K beamlines are in Ixx-services dir - directory = f"i{beamline[1:]}" - logger_.info( - 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( ( @@ -44,6 +37,25 @@ def find_dirs(file_path: Path, beamline: str) -> tuple: None, ) + if ixx_services_dir is None: + if not beamline.startswith("i"): + # If not found, try searching for Ixx-services as some + # J/K beamlines are in Ixx-services dir + directory = f"i{beamline[1:]}" + logger_.info( + f"{beamline}-services not found." + f" 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"{directory}-services") + ), + None, + ) + if ixx_services_dir is None: logging.critical( f"{beamline}-services not found. Is you file structure correct?" From ee7b158331e53c8af7f0260974908d9599a03fe6 Mon Sep 17 00:00:00 2001 From: Ollie Copping Date: Wed, 24 Jun 2026 14:50:15 +0000 Subject: [PATCH 2/2] Fix test --- tests/test_cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 5f6df75c..56c211b0 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -104,12 +104,12 @@ def test_find_dirs_jxx_services(caplog): mock_path = MagicMock(spec=Path) mock_path.absolute.return_value = mock_absolute - with caplog.at_level(logging.INFO): + with caplog.at_level(logging.DEBUG): services, synoptic = find_dirs(mock_path, "jxx") assert synoptic == mock_absolute.parent assert services == Path("mock_rel_path") - assert "jxx-services not found. Searching for Ixx-services..." in caplog.text + assert "ixx-services relative path:" in caplog.text def test_find_bob(caplog):