@@ -50,7 +50,11 @@ def create_symlinks(ref):
5050 # NOTE: shortcut for the workflow before data security; to be removed later
5151 logger .info ("Skipping the creation of the link because 'experiment_project' is set." )
5252 return
53- detectors = doc .get ("detectors" , [])
53+ if detectors := doc .get ("detectors" ):
54+ pass
55+ else :
56+ logger .info ("Not a measurement scan" )
57+ return
5458 if filename := doc .get ("filename" ):
5559 pass
5660 else :
@@ -84,16 +88,28 @@ def create_symlinks(ref):
8488 path_data .mkdir (exist_ok = True , parents = True )
8589 chmod_and_chown (path_data , uid = stats .st_uid , gid = stats .st_gid )
8690 logger .info (f"Created analysis and data folders for { det } " )
91+
92+ if 'TIFF' in doc ['spec' ]:
93+ prefix = str (Path (doc ["root" ]) / doc ["resource_path" ] / doc ["resource_kwargs" ]["filename" ])
94+ ext = doc ["resource_kwargs" ]["template" ].split ('.' )[- 1 ]
95+ elif 'HDF5' in doc ['spec' ]:
96+ prefix = str (Path (doc ["root" ]) / doc ["resource_path" ])
97+ ext = doc ["resource_path" ].split ('.' )[- 1 ]
98+ else :
99+ logger .info (f"The output for this spec has not been implemented yet. { doc ['spec' ]} " )
100+ return
87101
88- prefix = str (Path (doc ["root" ]) / doc ["resource_path" ] / doc ["resource_kwargs" ]["filename" ])
89102 for file_path in glob .glob (prefix + "*" ):
90103 source_name = os .path .splitext (os .path .basename (file_path ))[0 ] # only file name w/o extension
91104 name , indx = source_name .split ("_" ) # filename and index of the image
92- link_path = Path (path_expr_alias ) / subdir_raw / f"{ filename or name } _{ indx } _{ detname } .tiff"
93- link_path .parent .mkdir (exist_ok = True , parents = True )
94- chmod_and_chown (link_path .parent , uid = stats .st_uid , gid = stats .st_gid )
95- os .symlink (file_path , link_path )
96- logger .info (f"Linked: { file_path } to { link_path } " )
105+ link_path = Path (path_expr_alias ) / subdir_raw / f"{ filename or name } _{ indx } _{ detname } .{ ext } "
106+ if link_path .exists ():
107+ logger .info ("Scan was run already" )
108+ else :
109+ link_path .parent .mkdir (exist_ok = True , parents = True )
110+ chmod_and_chown (link_path .parent , uid = stats .st_uid , gid = stats .st_gid )
111+ os .symlink (file_path , link_path )
112+ logger .info (f"Linked: { file_path } to { link_path } " )
97113 break
98114 else :
99115 logger .error (f"Resource document referencing unknown detector { det } ." )
0 commit comments