Skip to content
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
10b61ca
Add a way of reading tomo metadata files
stephen-riggs Jun 24, 2025
8acd7f3
Initial code to insert searchmaps into murfey and ispyb databases
stephen-riggs Jun 26, 2025
658f21d
Correct db propagation
stephen-riggs Jun 26, 2025
20e74de
Camera setup
stephen-riggs Jun 26, 2025
405d259
Register positions of tomograms on search maps
stephen-riggs Jun 26, 2025
1167df7
Method to enter tomo metadata context
stephen-riggs Jun 27, 2025
277eb8c
Database will only allow simple types
stephen-riggs Jun 27, 2025
fe44f9a
Clearer naming
stephen-riggs Jun 27, 2025
2e3d2fd
Revert to Dict
stephen-riggs Jun 27, 2025
97bf289
Forgot the BaseModel
stephen-riggs Jun 27, 2025
72201ec
DB relationships were set up wrong
stephen-riggs Jun 27, 2025
f20e3fd
Sanitise inputs
stephen-riggs Jun 27, 2025
58dd306
No Images-Disc for tomo
stephen-riggs Jun 27, 2025
9824baf
Add new routers to manifest
stephen-riggs Jun 27, 2025
c436d34
Routing fixes
stephen-riggs Jun 27, 2025
6ef2ef6
Ensure the existance of all higher levels before inserting tomo metadata
stephen-riggs Jun 30, 2025
8adb4da
Fixes for posting metadata in the right order
stephen-riggs Jun 30, 2025
7c077ff
File pickup fix
stephen-riggs Jul 1, 2025
51e771d
Not using atlas binning at the moment
stephen-riggs Jul 1, 2025
8c0835a
Register search maps after data collection updates
stephen-riggs Jul 1, 2025
07d068f
Database closure issues
stephen-riggs Jul 1, 2025
6eb9a68
Fix it for k3 flipx
stephen-riggs Jul 2, 2025
d2e6a24
Catches for single batch position
stephen-riggs Jul 2, 2025
893785e
Flip for falcon camera
stephen-riggs Jul 2, 2025
82ee1b1
Merge branch 'main' into tomo-metadata
stephen-riggs Jul 2, 2025
76b0497
Some tests of the search map function
stephen-riggs Jul 3, 2025
6ed6ce5
Try and fix tests
stephen-riggs Jul 3, 2025
09b5f5f
Try and fix tests
stephen-riggs Jul 3, 2025
bcb8b8b
Try and fix tests
stephen-riggs Jul 3, 2025
8301d7e
Fix codeql issue
stephen-riggs Jul 3, 2025
14ee131
If no size is present for a search map, just have to insert something…
stephen-riggs Jul 7, 2025
4393ebb
Make clear that inserted values are wrong
stephen-riggs Jul 8, 2025
538ef47
Fixes
stephen-riggs Jul 8, 2025
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
11 changes: 10 additions & 1 deletion src/murfey/client/analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from murfey.client.contexts.spa import SPAModularContext
from murfey.client.contexts.spa_metadata import SPAMetadataContext
from murfey.client.contexts.tomo import TomographyContext
from murfey.client.contexts.tomo_metadata import TomographyMetadataContext
from murfey.client.instance_environment import MurfeyInstanceEnvironment
from murfey.client.rsync import RSyncerUpdate, TransferResult
from murfey.util.client import Observer, get_machine_config_client
Expand Down Expand Up @@ -226,6 +227,13 @@
and not self._context
):
self._context = SPAMetadataContext("epu", self._basepath)
elif (
"Batch" in transferred_file.parts
or "SearchMaps" in transferred_file.parts
or transferred_file.name == "Session.dm"
and not self._context
):
self._context = TomographyMetadataContext("tomo", self._basepath)

Check warning on line 236 in src/murfey/client/analyser.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/analyser.py#L236

Added line #L236 was not covered by tests
self.post_transfer(transferred_file)
else:
dc_metadata = {}
Expand Down Expand Up @@ -369,9 +377,10 @@
elif isinstance(
self._context,
(
TomographyContext,
SPAModularContext,
SPAMetadataContext,
TomographyContext,
TomographyMetadataContext,
),
):
context = str(self._context).split(" ")[0].split(".")[-1]
Expand Down
302 changes: 302 additions & 0 deletions src/murfey/client/contexts/tomo_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
import logging
from pathlib import Path
from typing import Optional

import requests
import xmltodict

from murfey.client.context import Context
from murfey.client.contexts.spa import _file_transferred_to, _get_source
from murfey.client.contexts.spa_metadata import _atlas_destination
from murfey.client.instance_environment import MurfeyInstanceEnvironment, SampleInfo
from murfey.util.api import url_path_for
from murfey.util.client import authorised_requests, capture_post

logger = logging.getLogger("murfey.client.contexts.tomo_metadata")

requests.get, requests.post, requests.put, requests.delete = authorised_requests()


def ensure_dcg_exists(transferred_file: Path, environment: MurfeyInstanceEnvironment):
# Make sure we have a data collection group
source = _get_source(transferred_file, environment=environment)

Check warning on line 22 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L22

Added line #L22 was not covered by tests
if not source:
return None
dcg_tag = str(source).replace(f"/{environment.visit}", "")
url = f"{str(environment.url.geturl())}{url_path_for('workflow.router', 'register_dc_group', visit_name=environment.visit, session_id=environment.murfey_session)}"
dcg_data = {

Check warning on line 27 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L24-L27

Added lines #L24 - L27 were not covered by tests
"experiment_type": "single particle",
"experiment_type_id": 37,
"tag": dcg_tag,
}
capture_post(url, json=dcg_data)
return dcg_tag

Check warning on line 33 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L32-L33

Added lines #L32 - L33 were not covered by tests


class TomographyMetadataContext(Context):
def __init__(self, acquisition_software: str, basepath: Path):
super().__init__("Tomography_metadata", acquisition_software)
self._basepath = basepath

Check warning on line 39 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L38-L39

Added lines #L38 - L39 were not covered by tests

def post_transfer(
self,
transferred_file: Path,
environment: Optional[MurfeyInstanceEnvironment] = None,
**kwargs,
):
super().post_transfer(

Check warning on line 47 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L47

Added line #L47 was not covered by tests
transferred_file=transferred_file,
environment=environment,
**kwargs,
)

if transferred_file.name == "Session.dm" and environment:
logger.info("Tomography session metadata found")
with open(transferred_file, "r") as session_xml:
session_data = xmltodict.parse(session_xml.read())

Check warning on line 56 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L54-L56

Added lines #L54 - L56 were not covered by tests

windows_path = session_data["TomographySession"]["AtlasId"]
logger.info(f"Windows path to atlas metadata found: {windows_path}")
visit_index = windows_path.split("\\").index(environment.visit)
partial_path = "/".join(windows_path.split("\\")[visit_index + 1 :])
logger.info("Partial Linux path successfully constructed from Windows path")

Check warning on line 62 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L58-L62

Added lines #L58 - L62 were not covered by tests

source = _get_source(transferred_file, environment)

Check warning on line 64 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L64

Added line #L64 was not covered by tests
if not source:
logger.warning(

Check warning on line 66 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L66

Added line #L66 was not covered by tests
f"Source could not be identified for {str(transferred_file)}"
)
return

Check warning on line 69 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L69

Added line #L69 was not covered by tests

source_visit_dir = source.parent

Check warning on line 71 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L71

Added line #L71 was not covered by tests

logger.info(

Check warning on line 73 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L73

Added line #L73 was not covered by tests
f"Looking for atlas XML file in metadata directory {str((source_visit_dir / partial_path).parent)}"
)
atlas_xml_path = list(

Check warning on line 76 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L76

Added line #L76 was not covered by tests
(source_visit_dir / partial_path).parent.glob("Atlas_*.xml")
)[0]
logger.info(f"Atlas XML path {str(atlas_xml_path)} found")
with open(atlas_xml_path, "rb") as atlas_xml:
atlas_xml_data = xmltodict.parse(atlas_xml)
atlas_pixel_size = float(

Check warning on line 82 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L79-L82

Added lines #L79 - L82 were not covered by tests
atlas_xml_data["MicroscopeImage"]["SpatialScale"]["pixelSize"]["x"][
"numericValue"
]
)

for p in partial_path.split("/"):
if p.startswith("Sample"):
sample = int(p.replace("Sample", ""))
break

Check warning on line 91 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L90-L91

Added lines #L90 - L91 were not covered by tests
else:
logger.warning(f"Sample could not be identified for {transferred_file}")
return
environment.samples[source] = SampleInfo(

Check warning on line 95 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L93-L95

Added lines #L93 - L95 were not covered by tests
atlas=Path(partial_path), sample=sample
)
url = f"{str(environment.url.geturl())}{url_path_for('workflow.router', 'register_dc_group', visit_name=environment.visit, session_id=environment.murfey_session)}"
dcg_tag = "/".join(

Check warning on line 99 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L98-L99

Added lines #L98 - L99 were not covered by tests
p for p in transferred_file.parent.parts if p != environment.visit
).replace("//", "/")
dcg_data = {

Check warning on line 102 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L102

Added line #L102 was not covered by tests
"experiment_type": "tomo",
"experiment_type_id": 36,
"tag": dcg_tag,
"atlas": str(
_atlas_destination(environment, source, transferred_file)
/ environment.samples[source].atlas.parent
/ atlas_xml_path.with_suffix(".jpg").name
),
"sample": environment.samples[source].sample,
"atlas_pixel_size": atlas_pixel_size,
}
capture_post(url, json=dcg_data)

Check warning on line 114 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L114

Added line #L114 was not covered by tests

elif transferred_file.name == "SearchMap.xml" and environment:
logger.info("Tomography session search map xml found")
dcg_tag = ensure_dcg_exists(transferred_file, environment)
with open(transferred_file, "r") as sm_xml:
sm_data = xmltodict.parse(sm_xml.read())

Check warning on line 120 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L117-L120

Added lines #L117 - L120 were not covered by tests

# This bit gets SearchMap location on Atlas
sm_pixel_size = float(

Check warning on line 123 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L123

Added line #L123 was not covered by tests
sm_data["MicroscopeImage"]["SpatialScale"]["pixelSize"]["x"][
"numericValue"
]
)
stage_position = sm_data["MicroscopeImage"]["microscopeData"]["stage"][

Check warning on line 128 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L128

Added line #L128 was not covered by tests
"Position"
]
sm_binning = float(

Check warning on line 131 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L131

Added line #L131 was not covered by tests
sm_data["MicroscopeImage"]["microscopeData"]["acquisition"]["camera"][
"Binning"
]["a:x"]
)

# Get the stage transformation
sm_transformations = sm_data["MicroscopeImage"]["CustomData"][

Check warning on line 138 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L138

Added line #L138 was not covered by tests
"a:KeyValueOfstringanyType"
]
stage_matrix: dict[str, float] = {}
image_matrix: dict[str, float] = {}

Check warning on line 142 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L141-L142

Added lines #L141 - L142 were not covered by tests
for key_val in sm_transformations:
if key_val["a:Key"] == "ReferenceCorrectionForStage":
stage_matrix = {

Check warning on line 145 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L145

Added line #L145 was not covered by tests
"m11": float(key_val["a:Value"]["b:_m11"]),
"m12": float(key_val["a:Value"]["b:_m12"]),
"m21": float(key_val["a:Value"]["b:_m21"]),
"m22": float(key_val["a:Value"]["b:_m22"]),
}
elif key_val["a:Key"] == "ReferenceCorrectionForImageShift":
image_matrix = {

Check warning on line 152 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L152

Added line #L152 was not covered by tests
"m11": float(key_val["a:Value"]["b:_m11"]),
"m12": float(key_val["a:Value"]["b:_m12"]),
"m21": float(key_val["a:Value"]["b:_m21"]),
"m22": float(key_val["a:Value"]["b:_m22"]),
}
if not stage_matrix or not image_matrix:
logger.error(

Check warning on line 159 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L159

Added line #L159 was not covered by tests
f"No stage or image shift matrix found for {transferred_file}"
)

ref_matrix = {

Check warning on line 163 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L163

Added line #L163 was not covered by tests
"m11": float(
sm_data["MicroscopeImage"]["ReferenceTransformation"]["matrix"][
"a:_m11"
]
),
"m12": float(
sm_data["MicroscopeImage"]["ReferenceTransformation"]["matrix"][
"a:_m12"
]
),
"m21": float(
sm_data["MicroscopeImage"]["ReferenceTransformation"]["matrix"][
"a:_m21"
]
),
"m22": float(
sm_data["MicroscopeImage"]["ReferenceTransformation"]["matrix"][
"a:_m22"
]
),
}

source = _get_source(transferred_file, environment=environment)
image_path = (

Check warning on line 187 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L186-L187

Added lines #L186 - L187 were not covered by tests
_file_transferred_to(
environment, source, transferred_file.parent / "SearchMap.jpg"
)
if source
else ""
)

sm_url = f"{str(environment.url.geturl())}{url_path_for('session_control.tomo_router', 'register_search_map', session_id=environment.murfey_session, sm_name=transferred_file.parent.name)}"
capture_post(

Check warning on line 196 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L195-L196

Added lines #L195 - L196 were not covered by tests
sm_url,
json={
"tag": dcg_tag,
"x_stage_position": float(stage_position["X"]),
"y_stage_position": float(stage_position["Y"]),
"pixel_size": sm_pixel_size,
"image": str(image_path),
"binning": sm_binning,
"reference_matrix": ref_matrix,
"stage_correction": stage_matrix,
"image_shift_correction": image_matrix,
},
)

elif transferred_file.name == "SearchMap.dm" and environment:
logger.info("Tomography session search map dm found")
dcg_tag = ensure_dcg_exists(transferred_file, environment)
with open(transferred_file, "r") as sm_xml:
sm_data = xmltodict.parse(sm_xml.read())

Check warning on line 215 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L212-L215

Added lines #L212 - L215 were not covered by tests

# This bit gets SearchMap size
sm_width = int(sm_data["TileSetXml"]["ImageSize"]["a:width"])
sm_height = int(sm_data["TileSetXml"]["ImageSize"]["a:height"])

Check warning on line 219 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L218-L219

Added lines #L218 - L219 were not covered by tests

sm_url = f"{str(environment.url.geturl())}{url_path_for('session_control.tomo_router', 'register_search_map', session_id=environment.murfey_session, sm_name=transferred_file.parent.name)}"
capture_post(

Check warning on line 222 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L221-L222

Added lines #L221 - L222 were not covered by tests
sm_url,
json={
"tag": dcg_tag,
"height": sm_height,
"width": sm_width,
},
)

elif transferred_file.name == "BatchPositionsList.xml" and environment:
logger.info("Tomography session batch positions list found")
dcg_tag = ensure_dcg_exists(transferred_file, environment)
with open(transferred_file) as xml:
for_parsing = xml.read()
batch_xml = xmltodict.parse(for_parsing)

Check warning on line 236 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L232-L236

Added lines #L232 - L236 were not covered by tests

batch_positions_list = batch_xml["BatchPositionsList"]["BatchPositions"][

Check warning on line 238 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L238

Added line #L238 was not covered by tests
"BatchPositionParameters"
]
if isinstance(batch_positions_list, dict):
# Case of a single batch
batch_positions_list = [batch_positions_list]

Check warning on line 243 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L243

Added line #L243 was not covered by tests

for batch_position in batch_positions_list:
batch_name = batch_position["Name"]
search_map_name = batch_position["PositionOnTileSet"]["TileSetName"]
batch_stage_location_x = float(

Check warning on line 248 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L246-L248

Added lines #L246 - L248 were not covered by tests
batch_position["PositionOnTileSet"]["StagePositionX"]
)
batch_stage_location_y = float(

Check warning on line 251 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L251

Added line #L251 was not covered by tests
batch_position["PositionOnTileSet"]["StagePositionY"]
)

# Always need search map before batch position
sm_url = f"{str(environment.url.geturl())}{url_path_for('session_control.tomo_router', 'register_search_map', session_id=environment.murfey_session, sm_name=search_map_name)}"
capture_post(

Check warning on line 257 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L256-L257

Added lines #L256 - L257 were not covered by tests
sm_url,
json={
"tag": dcg_tag,
},
)

# Then register batch position
bp_url = f"{str(environment.url.geturl())}{url_path_for('session_control.tomo_router', 'register_batch_position', session_id=environment.murfey_session, batch_name=batch_name)}"
capture_post(

Check warning on line 266 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L265-L266

Added lines #L265 - L266 were not covered by tests
bp_url,
json={
"tag": dcg_tag,
"x_stage_position": batch_stage_location_x,
"y_stage_position": batch_stage_location_y,
"x_beamshift": 0,
"y_beamshift": 0,
"search_map_name": search_map_name,
},
)

# Beamshifts
if batch_position.get("AdditionalExposureTemplateAreas"):
beamshifts = batch_position["AdditionalExposureTemplateAreas"][

Check warning on line 280 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L280

Added line #L280 was not covered by tests
"ExposureTemplateAreaParameters"
]
if type(beamshifts) is dict:
beamshifts = [beamshifts]

Check warning on line 284 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L284

Added line #L284 was not covered by tests
for beamshift in beamshifts:
beamshift_name = beamshift["Name"]
beamshift_position_x = float(beamshift["PositionX"])
beamshift_position_y = float(beamshift["PositionY"])

Check warning on line 288 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L286-L288

Added lines #L286 - L288 were not covered by tests

# Registration of beamshifted position
bp_url = f"{str(environment.url.geturl())}{url_path_for('session_control.tomo_router', 'register_batch_position', session_id=environment.murfey_session, batch_name=beamshift_name)}"
capture_post(

Check warning on line 292 in src/murfey/client/contexts/tomo_metadata.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/client/contexts/tomo_metadata.py#L291-L292

Added lines #L291 - L292 were not covered by tests
bp_url,
json={
"tag": dcg_tag,
"x_stage_position": batch_stage_location_x,
"y_stage_position": batch_stage_location_y,
"x_beamshift": beamshift_position_x,
"y_beamshift": beamshift_position_y,
"search_map_name": search_map_name,
},
)
33 changes: 33 additions & 0 deletions src/murfey/server/api/session_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@
Session,
)
from murfey.util.models import (
BatchPositionParameters,
ClientInfo,
FoilHoleParameters,
GridSquareParameters,
RsyncerInfo,
SearchMapParameters,
Visit,
)
from murfey.workflows.spa.flush_spa_preprocess import (
Expand All @@ -58,6 +60,10 @@
from murfey.workflows.spa.flush_spa_preprocess import (
register_grid_square as _register_grid_square,
)
from murfey.workflows.tomo.tomo_metadata import (
register_batch_position_in_database,
register_search_map_in_database,
)

logger = getLogger("murfey.server.api.session_control")

Expand Down Expand Up @@ -364,6 +370,33 @@
return _register_foil_hole(session_id, gs_name, foil_hole_params, db)


tomo_router = APIRouter(
prefix="/session_control/tomo",
dependencies=[Depends(validate_instrument_token)],
tags=["Session Control: CryoET"],
)


@tomo_router.post("/sessions/{session_id}/search_map/{sm_name}")
def register_search_map(
session_id: MurfeySessionID,
sm_name: str,
search_map_params: SearchMapParameters,
db=murfey_db,
):
return register_search_map_in_database(session_id, sm_name, search_map_params, db)

Check warning on line 387 in src/murfey/server/api/session_control.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/api/session_control.py#L387

Added line #L387 was not covered by tests


@tomo_router.post("/sessions/{session_id}/batch_position/{batch_name}")
def register_batch_position(
session_id: MurfeySessionID,
batch_name: str,
batch_params: BatchPositionParameters,
db=murfey_db,
):
return register_batch_position_in_database(session_id, batch_name, batch_params, db)

Check warning on line 397 in src/murfey/server/api/session_control.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/api/session_control.py#L397

Added line #L397 was not covered by tests


correlative_router = APIRouter(
prefix="/session_control/correlative",
dependencies=[Depends(validate_instrument_token)],
Expand Down
Loading