Skip to content

Commit

Permalink
Fixes for picking up external post transfer hooks (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-riggs authored Oct 14, 2024
1 parent f22cdb7 commit ec4286f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/murfey/client/analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def _find_extension(self, file_path: Path):
"""
Identifies the file extension and stores that information in the class.
"""
if "atlas" in file_path.parts:
self._extension = file_path.suffix
return True

if (
required_substrings := self._murfey_config.get(
"data_required_substrings", {}
Expand Down Expand Up @@ -121,6 +125,10 @@ def _find_context(self, file_path: Path) -> bool:
stages of processing. Actions to take for individual files will be determined
in the Context classes themselves.
"""
if "atlas" in file_path.parts:
self._role = "detector"
self._context = SPAMetadataContext("epu", self._basepath)
return True

# CLEM workflow checks
# Look for LIF and XLIF files
Expand Down Expand Up @@ -310,7 +318,10 @@ def _analyse(self):
)
except Exception as e:
logger.error(f"Exception encountered: {e}")
if self._role == "detector":
if (
self._role == "detector"
and "atlas" not in transferred_file.parts
):
if not dc_metadata:
try:
dc_metadata = self._context.gather_metadata(
Expand Down Expand Up @@ -376,7 +387,10 @@ def _analyse(self):
)
except Exception as e:
logger.error(f"Exception encountered: {e}")
if self._role == "detector":
if (
self._role == "detector"
and "atlas" not in transferred_file.parts
):
if not dc_metadata:
try:
dc_metadata = self._context.gather_metadata(
Expand Down
6 changes: 6 additions & 0 deletions src/murfey/client/contexts/spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,12 @@ def post_transfer(
environment: MurfeyInstanceEnvironment | None = None,
**kwargs,
) -> bool:
super().post_transfer(
transferred_file=transferred_file,
role=role,
environment=environment,
**kwargs,
)
data_suffixes = (".mrc", ".tiff", ".tif", ".eer")
if role == "detector" and "gain" not in transferred_file.name:
if transferred_file.suffix in data_suffixes:
Expand Down
9 changes: 8 additions & 1 deletion src/murfey/client/contexts/spa_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _atlas_destination(

class SPAMetadataContext(Context):
def __init__(self, acquisition_software: str, basepath: Path):
super().__init__("SPA metadata", acquisition_software)
super().__init__("SPA_metadata", acquisition_software)
self._basepath = basepath

def post_transfer(
Expand All @@ -45,6 +45,13 @@ def post_transfer(
environment: Optional[MurfeyInstanceEnvironment] = None,
**kwargs,
):
super().post_transfer(
transferred_file=transferred_file,
role=role,
environment=environment,
**kwargs,
)

if transferred_file.name == "EpuSession.dm" and environment:
logger.info("EPU session metadata found")
with open(transferred_file, "r") as epu_xml:
Expand Down
7 changes: 7 additions & 0 deletions src/murfey/client/contexts/tomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,13 @@ def post_transfer(
environment: MurfeyInstanceEnvironment | None = None,
**kwargs,
) -> List[str]:
super().post_transfer(
transferred_file=transferred_file,
role=role,
environment=environment,
**kwargs,
)

data_suffixes = (".mrc", ".tiff", ".tif", ".eer")
completed_tilts = []
if role == "detector" and "gain" not in transferred_file.name:
Expand Down

0 comments on commit ec4286f

Please sign in to comment.