1+ """
2+ Contains functions for analysing the various types of files hauled by Murfey, and
3+ assigning to them the correct contexts (CLEM, SPA, tomography, etc.) for processing
4+ on the server side.
5+
6+ Individual contexts can be found in murfey.client.contexts.
7+ """
8+
19from __future__ import annotations
210
311import logging
@@ -108,13 +116,15 @@ def _find_context(self, file_path: Path) -> bool:
108116 assigns the necessary context class to it for subsequent stages of processing
109117 """
110118
111- # CLEM workflow check
112- # Look for LIF files
119+ # CLEM workflow checks
120+ # Look for LIF and XLIF files
113121 if file_path .suffix in (".lif" , ".xlif" ):
114122 self ._role = "detector"
115123 self ._context = CLEMContext ("leica" , self ._basepath )
116124 return True
117-
125+ # Look for TIFF files associated with CLEM workflow
126+ # Leica's autosave mode seems to name the TIFFs in the format
127+ # PostionXX--ZXX-CXX.tif
118128 if (
119129 "--" in file_path .name
120130 and file_path .suffix in (".tiff" , ".tif" )
@@ -131,6 +141,7 @@ def _find_context(self, file_path: Path) -> bool:
131141 self ._context = CLEMContext ("leica" , self ._basepath )
132142 return True
133143
144+ # Checks for tomography and SPA workflows
134145 split_file_name = file_path .name .split ("_" )
135146 if split_file_name :
136147 # Files starting with "FoilHole" belong to the SPA workflow
@@ -226,7 +237,9 @@ def post_transfer(self, transferred_file: Path):
226237 transferred_file , role = self ._role , environment = self ._environment
227238 )
228239 except Exception as e :
229- logger .error (f"An exception was encountered post transfer: { e } " )
240+ logger .error (
241+ f"An exception was encountered posting the file for transfer: { e } "
242+ )
230243
231244 def _analyse (self ):
232245 logger .info ("Analyser thread started" )
@@ -328,6 +341,7 @@ def _analyse(self):
328341 ),
329342 }
330343 )
344+ # If a file with a CLEM context is identified, immediately post it
331345 elif isinstance (self ._context , CLEMContext ):
332346 self .post_transfer (transferred_file )
333347 elif not self ._extension or self ._unseen_xml :
0 commit comments