Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ GitHub = "https://github.com/DiamondLightSource/python-murfey"
"murfey_machine" = "murfey.util.config:get_extended_machine_config"
[project.entry-points."murfey.workflows"]
"atlas_update" = "murfey.workflows.register_atlas_update:run"
"clem.align_and_merge" = "murfey.workflows.clem.align_and_merge:submit_cluster_request"
"clem.process_raw_lifs" = "murfey.workflows.clem.process_raw_lifs:zocalo_cluster_request"
"clem.process_raw_tiffs" = "murfey.workflows.clem.process_raw_tiffs:zocalo_cluster_request"
"clem.register_align_and_merge_result" = "murfey.workflows.clem.register_align_and_merge_results:register_align_and_merge_result"
"clem.align_and_merge" = "murfey.workflows.clem.align_and_merge:run"
"clem.process_raw_lifs" = "murfey.workflows.clem.process_raw_lifs:run"
"clem.process_raw_tiffs" = "murfey.workflows.clem.process_raw_tiffs:run"
"clem.register_align_and_merge_result" = "murfey.workflows.clem.register_align_and_merge_results:run"
"clem.register_preprocessing_result" = "murfey.workflows.clem.register_preprocessing_results:run"
"data_collection" = "murfey.workflows.register_data_collection:run"
"data_collection_group" = "murfey.workflows.register_data_collection_group:run"
Expand Down
80 changes: 8 additions & 72 deletions src/murfey/client/contexts/clem.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import logging
from pathlib import Path
from typing import Dict, Generator, List, Optional
from typing import Generator
from xml.etree import ElementTree as ET

from defusedxml.ElementTree import parse
Expand All @@ -23,7 +23,7 @@ def _file_transferred_to(
source: Path,
file_path: Path,
rsync_basepath: Path,
) -> Optional[Path]:
):
"""
Returns the Path of the transferred file on the DLS file system.
"""
Expand All @@ -36,9 +36,7 @@ def _file_transferred_to(
return destination


def _get_source(
file_path: Path, environment: MurfeyInstanceEnvironment
) -> Optional[Path]:
def _get_source(file_path: Path, environment: MurfeyInstanceEnvironment):
"""
Returns the Path of the file on the client PC.
"""
Expand All @@ -48,7 +46,7 @@ def _get_source(
return None


def _get_image_elements(root: ET.Element) -> List[ET.Element]:
def _get_image_elements(root: ET.Element) -> list[ET.Element]:
"""
Searches the XML metadata recursively to find the nodes tagged as "Element" that
have image-related tags. Some LIF datasets have layers of nested elements, so a
Expand Down Expand Up @@ -93,14 +91,14 @@ def __init__(
self._basepath = basepath
self._machine_config = machine_config
# CLEM contexts for "auto-save" acquisition mode
self._tiff_series: Dict[str, List[str]] = {} # {Series name : TIFF path list}
self._series_metadata: Dict[str, str] = {} # {Series name : Metadata file path}
self._files_in_series: Dict[str, int] = {} # {Series name : Total TIFFs}
self._tiff_series: dict[str, list[str]] = {} # {Series name : TIFF path list}
self._series_metadata: dict[str, str] = {} # {Series name : Metadata file path}
self._files_in_series: dict[str, int] = {} # {Series name : Total TIFFs}

def post_transfer(
self,
transferred_file: Path,
environment: Optional[MurfeyInstanceEnvironment] = None,
environment: MurfeyInstanceEnvironment | None = None,
**kwargs,
) -> bool:
super().post_transfer(transferred_file, environment=environment, **kwargs)
Expand Down Expand Up @@ -180,11 +178,6 @@ def post_transfer(
f"File {transferred_file.name!r} added to series {series_name!r}"
)

# Register the TIFF file in the database
post_result = self.register_tiff_file(destination_file, environment)
if post_result is False:
return False

# Process XLIF files
if transferred_file.suffix == ".xlif":
# Skip processing of "_histo" histogram XLIF files
Expand Down Expand Up @@ -311,12 +304,6 @@ def post_transfer(
)
return False

# Post URL to register LIF file in database
post_result = self.register_lif_file(destination_file, environment)
if post_result is False:
return False
logger.info(f"Registered {destination_file.name!r} in the database")

# Post URL to trigger job and convert LIF file into image stacks
post_result = self.process_lif_file(destination_file, environment)
if post_result is False:
Expand All @@ -326,31 +313,6 @@ def post_transfer(
# Function has completed as expected
return True

def register_lif_file(
self,
lif_file: Path,
environment: MurfeyInstanceEnvironment,
):
"""
Constructs the URL and dictionary to be posted to the server, which will then
register the LIF file in the database correctly as part of the CLEM workflow.
"""
try:
capture_post(
base_url=str(environment.url.geturl()),
router_name="clem.router",
function_name="register_lif_file",
token=self._token,
session_id=environment.murfey_session,
data={"lif_file": str(lif_file)},
)
return True
except Exception as e:
logger.error(
f"Error encountered when registering the LIF file in the database: {e}"
)
return False

def process_lif_file(
self,
lif_file: Path,
Expand All @@ -375,32 +337,6 @@ def process_lif_file(
logger.error(f"Error encountered processing LIF file: {e}")
return False

def register_tiff_file(
self,
tiff_file: Path,
environment: MurfeyInstanceEnvironment,
):
"""
Constructs the URL and dictionary to be posted to the server, which will then
register the TIFF file in the database correctly as part of the CLEM workflow.
"""

try:
capture_post(
base_url=str(environment.url.geturl()),
router_name="clem.router",
function_name="register_tiff_file",
token=self._token,
session_id=environment.murfey_session,
data={"tiff_file": str(tiff_file)},
)
return True
except Exception as e:
logger.error(
f"Error encountered when registering the TIFF file in the database: {e}"
)
return False

def process_tiff_series(
self,
tiff_dataset: dict,
Expand Down
Loading
Loading