From e3bf903ad3a2d9a24e5b29679e2d766488f35902 Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Thu, 30 Jul 2026 09:00:07 +0100 Subject: [PATCH 1/2] Add lamella tomography experiment type id --- src/murfey/client/context.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/murfey/client/context.py b/src/murfey/client/context.py index bded966d8..a72bcf908 100644 --- a/src/murfey/client/context.py +++ b/src/murfey/client/context.py @@ -124,6 +124,14 @@ def ensure_dcg_exists( if collection_type == "tomo": windows_path = session_data["TomographySession"]["AtlasId"] + lamella_workflow = session_data.get("TomographySession", {}).get( + "LamellaWorkflow", None + ) + if lamella_workflow == "true": + # Lamella tomography experiment type + experiment_type_id = 49 + else: + logger.warning("Cannot find tomography Session.dm file") else: windows_path = session_data["EpuSessionXml"]["Samples"]["_items"][ "SampleXml" From 892d170fd20e90490179b9c8b343c60b9ae749b8 Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Thu, 30 Jul 2026 12:20:06 +0100 Subject: [PATCH 2/2] Add a test --- src/murfey/client/context.py | 8 ++++---- tests/client/test_context.py | 23 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/murfey/client/context.py b/src/murfey/client/context.py index a72bcf908..372d59522 100644 --- a/src/murfey/client/context.py +++ b/src/murfey/client/context.py @@ -124,10 +124,10 @@ def ensure_dcg_exists( if collection_type == "tomo": windows_path = session_data["TomographySession"]["AtlasId"] - lamella_workflow = session_data.get("TomographySession", {}).get( - "LamellaWorkflow", None - ) - if lamella_workflow == "true": + if ( + session_data.get("TomographySession", {}).get("LamellaWorkflow", None) + == "true" + ): # Lamella tomography experiment type experiment_type_id = 49 else: diff --git a/tests/client/test_context.py b/tests/client/test_context.py index 860669551..277c989cd 100644 --- a/tests/client/test_context.py +++ b/tests/client/test_context.py @@ -1,12 +1,22 @@ from unittest.mock import patch from urllib.parse import urlparse +import pytest + from murfey.client.context import ensure_dcg_exists from murfey.client.instance_environment import MurfeyInstanceEnvironment +# Lamella experiment type options and experiment type ids +lamella_types: list[tuple[str | None, int]] = [ + (None, 36), + ("false", 36), + ("true", 49), +] + +@pytest.mark.parametrize("lamella", lamella_types) @patch("murfey.client.context.capture_post") -def test_ensure_dcg_exists_tomo(mock_capture_post, tmp_path): +def test_ensure_dcg_exists_tomo(mock_capture_post, lamella, tmp_path): env = MurfeyInstanceEnvironment( url=urlparse("http://localhost:8000"), client_id=0, @@ -25,9 +35,14 @@ def test_ensure_dcg_exists_tomo(mock_capture_post, tmp_path): with open(metadata_source / "Session.dm", "w") as dm_file: dm_file.write( "" - r"X:\cm12345-6\atlas\atlas_metadata\Sample6\Atlas\Atlas.dm" - "" + r"X:\cm12345-6\atlas\atlas_metadata\Sample6\Atlas\Atlas.dm" + ) + dm_file.write( + rf"{lamella[0]}" + if lamella[0] is not None + else "" ) + dm_file.write(r"") atlas_xml = tmp_path / "cm12345-6/atlas/atlas_metadata/Sample6/Atlas/Atlas_4.xml" atlas_xml.parent.mkdir(parents=True) @@ -46,7 +61,7 @@ def test_ensure_dcg_exists_tomo(mock_capture_post, tmp_path): ) dcg_data = { - "experiment_type_id": 36, + "experiment_type_id": lamella[1], "tag": f"{tmp_path}/metadata_folder", "atlas": f"{tmp_path}/destination/{atlas_xml.relative_to(tmp_path).with_suffix('.jpg')}", "sample": 6,