2323from murfey .client .rsync import RSyncerUpdate , TransferResult
2424from murfey .client .tui .forms import FormDependency
2525from murfey .util import Observer , get_machine_config_client
26+ from murfey .util .mdoc import get_block
2627from murfey .util .models import PreprocessingParametersTomo , ProcessingParametersSPA
2728
2829logger = logging .getLogger ("murfey.client.analyser" )
@@ -113,6 +114,13 @@ def _find_extension(self, file_path: Path):
113114 ):
114115 logger .info (f"File extension re-evaluated: { file_path .suffix } " )
115116 self ._extension = file_path .suffix
117+ # If we see an .mdoc file first, use that to determine the file extensions
118+ elif file_path .suffix == ".mdoc" :
119+ with open (file_path , "r" ) as md :
120+ md .seek (0 )
121+ mdoc_data_block = get_block (md )
122+ if subframe_path := mdoc_data_block .get ("SubFramePath" ):
123+ self ._extension = Path (subframe_path ).suffix
116124 # Check for LIF files separately
117125 elif file_path .suffix == ".lif" :
118126 self ._extension = file_path .suffix
@@ -124,6 +132,7 @@ def _find_context(self, file_path: Path) -> bool:
124132 stages of processing. Actions to take for individual files will be determined
125133 in the Context classes themselves.
126134 """
135+ logger .debug (f"Finding context using file { str (file_path )!r} " )
127136 if "atlas" in file_path .parts :
128137 self ._context = SPAMetadataContext ("epu" , self ._basepath )
129138 return True
@@ -258,9 +267,9 @@ def _analyse(self):
258267 self ._find_extension (transferred_file )
259268 found = self ._find_context (transferred_file )
260269 if not found :
261- # logger.warning (
262- # f"Context not understood for {transferred_file}, stopping analysis "
263- # )
270+ logger .debug (
271+ f"Couldn't find context for { str ( transferred_file )!r } "
272+ )
264273 self .queue .task_done ()
265274 continue
266275 elif self ._extension :
@@ -383,6 +392,10 @@ def _analyse(self):
383392 SPAMetadataContext ,
384393 ),
385394 ):
395+ context = str (self ._context ).split (" " )[0 ].split ("." )[- 1 ]
396+ logger .debug (
397+ f"Transferring file { str (transferred_file )} with context { context !r} "
398+ )
386399 self .post_transfer (transferred_file )
387400 self .queue .task_done ()
388401
0 commit comments