diff --git a/src/murfey/client/context.py b/src/murfey/client/context.py index bded966d8..372d59522 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"] + if ( + session_data.get("TomographySession", {}).get("LamellaWorkflow", None) + == "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" 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,