Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/techui_builder/main_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
(
Expand All @@ -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?"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down