Skip to content

Commit 2b290b3

Browse files
committed
Updated comments and documentation after recent fixes
1 parent 927779b commit 2b290b3

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ classifiers = [
3131
]
3232
dependencies = [
3333
"defusedxml", # For safely parsing XML files
34-
"pydantic<2", # Pip hops between installing v2.7 or v1.10 depending on which of the additional dependencies are requested
34+
"pydantic<2", # Locked to <2 by zocalo
3535
"requests",
3636
"rich",
3737
"werkzeug",

src/murfey/client/analyser.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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+
19
from __future__ import annotations
210

311
import 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:

src/murfey/client/contexts/clem.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
"""
2-
Add a CLEM class context (refer to src/murfey/client/contexts/fib.py)
3-
4-
Provide a post transfer function to pass on:
5-
- File path on the DLS file system
6-
- Session ID (src/murfey/client/instance_environment.py)
2+
Provides instructions to the server side on how different file types associated with
3+
the CLEM workflow should be processed.
74
"""
85

96
# import requests
@@ -32,9 +29,12 @@ def _file_transferred_to(
3229
machine_config = get_machine_config(
3330
str(environment.url.geturl()), demo=environment.demo
3431
)
32+
# rsync basepath and modules are set in the microscope's configuration YAML file
3533
return (
3634
Path(machine_config.get("rsync_basepath", ""))
37-
/ (machine_config.get("rsync_module", "data") or "data")
35+
/ (
36+
machine_config.get("rsync_module", "data") or "data"
37+
) # Add "data" if it wasn't set
3838
/ str(datetime.now().year)
3939
/ source.name
4040
/ file_path.relative_to(source)
@@ -171,7 +171,7 @@ def post_transfer(
171171

172172
# Post message if all files for the associated series have been collected
173173
if len(self._tiff_series[series_name]) == self._files_in_series.get(
174-
series_name, 0
174+
series_name, 0 # Return 0 if the key hasn't been generated yet
175175
):
176176

177177
# Construct URL for Murfey server to communicate with

0 commit comments

Comments
 (0)