Skip to content
Draft
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
18 changes: 15 additions & 3 deletions src/techui_builder/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,34 @@ 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:
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
Expand Down
2 changes: 1 addition & 1 deletion src/techui_builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down