Skip to content

Commit 9935c7a

Browse files
authored
Try to fix the data collection group tag again (#472)
Drop leading / and add Images-Disc* to path. This uses the most recent Images-Disc directory which is not ideal but I couldn't think of a better way to get something working quickly
1 parent ab15836 commit 9935c7a

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/murfey/client/contexts/spa_metadata.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,16 @@ def post_transfer(
150150
atlas=Path(partial_path), sample=sample
151151
)
152152
url = f"{str(environment.url.geturl())}/visits/{environment.visit}/{environment.murfey_session}/register_data_collection_group"
153-
dcg_tag = "/".join(
154-
p for p in transferred_file.parent.parts if p != environment.visit
153+
dcg_search_dir = "/".join(
154+
p
155+
for p in transferred_file.parent.parts[1:]
156+
if p != environment.visit
157+
)
158+
dcg_tag = str(
159+
sorted(
160+
Path(dcg_search_dir).glob("Images-Disc*"),
161+
key=lambda x: x.stat().st_ctime,
162+
)[-1]
155163
)
156164
dcg_data = {
157165
"experiment_type": "single particle",
@@ -195,7 +203,15 @@ def post_transfer(
195203
)
196204
fh_positions = _foil_hole_positions(transferred_file, int(gs_name))
197205
source = _get_source(transferred_file, environment=environment)
198-
visitless_source = str(source).replace(f"/{environment.visit}", "")
206+
visitless_source_search_dir = str(source).replace(
207+
f"/{environment.visit}", ""
208+
)
209+
visitless_source = str(
210+
sorted(
211+
Path(visitless_source_search_dir).glob("Images-Disc*"),
212+
key=lambda x: x.stat().st_ctime,
213+
)[-1]
214+
)
199215
for fh, fh_data in fh_positions.items():
200216
capture_post(
201217
f"{str(environment.url.geturl())}/sessions/{environment.murfey_session}/grid_square/{gs_name}/foil_hole",

0 commit comments

Comments
 (0)