Skip to content

Commit e900e73

Browse files
committed
Don't look for Images-Disc as it is sent
1 parent 75da69f commit e900e73

2 files changed

Lines changed: 5 additions & 18 deletions

File tree

src/murfey/client/context.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ def ensure_dcg_exists(
4545
if collection_type == "tomo":
4646
experiment_type_id = 36
4747
session_file = metadata_source / "Session.dm"
48+
source_visit_dir = metadata_source.parent
4849
elif collection_type == "spa":
4950
experiment_type_id = 37
5051
# For SPA the metadata source sent should include the Images-Disc
5152
session_file = metadata_source.parent / "EpuSession.dm"
53+
source_visit_dir = metadata_source.parent.parent
5254
for h in entry_points(group="murfey.hooks"):
5355
try:
5456
if h.name == "get_epu_session_metadata":
@@ -91,7 +93,6 @@ def ensure_dcg_exists(
9193
partial_path = "/".join(windows_path.split("\\")[visit_index + 1 :])
9294
logger.info("Partial Linux path successfully constructed from Windows path")
9395

94-
source_visit_dir = metadata_source.parent
9596
logger.info(
9697
f"Looking for atlas XML file in metadata directory {str((source_visit_dir / partial_path).parent)}"
9798
)
@@ -121,28 +122,14 @@ def ensure_dcg_exists(
121122
atlas=Path(partial_path), sample=sample
122123
)
123124

124-
dcg_search_dir = (
125+
dcg_tag = (
125126
str(metadata_source).replace(f"/{environment.visit}", "").replace("//", "/")
126127
)
127-
if collection_type == "tomo":
128-
dcg_tag = dcg_search_dir
129-
else:
130-
dcg_images_dirs = sorted(
131-
Path(dcg_search_dir).glob("Images-Disc*"),
132-
key=lambda x: x.stat().st_ctime,
133-
)
134-
if not dcg_images_dirs:
135-
logger.warning(
136-
f"Cannot find Images-Disc* in {dcg_search_dir}, falling back to Images-Disc1"
137-
)
138-
dcg_images_dirs = [Path(dcg_search_dir) / "Images-Disc1"]
139-
dcg_tag = str(dcg_images_dirs[-1])
140-
141128
dcg_data = {
142129
"experiment_type_id": experiment_type_id,
143130
"tag": dcg_tag,
144131
"atlas": str(
145-
_atlas_destination(environment, metadata_source, token)
132+
_atlas_destination(environment, session_file.parent, token)
146133
/ environment.samples[metadata_source].atlas.parent
147134
/ atlas_xml_path.with_suffix(".jpg").name
148135
).replace("//", "/"),

tests/client/test_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_ensure_dcg_exists_spa(mock_capture_post, tmp_path):
9999

100100
ensure_dcg_exists(
101101
collection_type="spa",
102-
metadata_source=metadata_source,
102+
metadata_source=metadata_source / "Images-Disc1",
103103
environment=env,
104104
token="token",
105105
)

0 commit comments

Comments
 (0)