@@ -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 ("//" , "/" ),
0 commit comments