Skip to content

Commit 3ff2250

Browse files
committed
Recipe and manuall recipe wrapping are not needed for messages not originating from Murfey
1 parent 5d930fd commit 3ff2250

3 files changed

Lines changed: 15 additions & 51 deletions

File tree

recipes/ispyb/correlative-align-images.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/cryoemservices/services/correlative_align_images.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from pathlib import Path
2+
from typing import Any
23

34
from pydantic import BaseModel, ValidationError
4-
from workflows.recipe import wrap_subscribe
5+
from workflows.recipe import RecipeWrapper, wrap_subscribe
56

67
from cryoemservices.services.common_service import CommonService
7-
from cryoemservices.util.models import MockRW
88

99

1010
class AlignImagesParameters(BaseModel):
@@ -35,19 +35,13 @@ def initializing(self):
3535
allow_non_recipe_messages=True,
3636
)
3737

38-
def call_align_images(self, rw, header, message):
38+
def call_align_images(
39+
self,
40+
rw: RecipeWrapper,
41+
header: dict[str, Any],
42+
message: dict[str, Any] | None,
43+
):
3944
"""Pass incoming message to the relevant plugin function."""
40-
# Encase message in ReceipeWrapper if none was provided
41-
if not rw:
42-
self.log.info("Received a simple message")
43-
if not isinstance(message, dict):
44-
self.log.error("Rejected invalid simple message")
45-
self._reject_message(header, requeue=False)
46-
return
47-
# Create a wrapper-like object to be passed to functions
48-
rw = MockRW(self._transport)
49-
rw.recipe_step = {"paramters": message}
50-
5145
try:
5246
if isinstance(message, dict):
5347
params = AlignImagesParameters(

tests/services/test_correlative_align_images_service.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,9 @@ def offline_transport(mocker: MockerFixture):
2020
return transport
2121

2222

23-
@pytest.mark.parametrize(
24-
"use_recwrap",
25-
(
26-
True,
27-
False,
28-
),
29-
)
3023
def test_align_images_service(
3124
tmp_path: Path,
3225
offline_transport: OfflineTransport,
33-
use_recwrap: bool,
3426
):
3527
# Set up the message parameters
3628
header = {
@@ -51,20 +43,13 @@ def test_align_images_service(
5143
service = AlignImagesService(environment={"queue": ""}, transport=offline_transport)
5244
service.log = MagicMock() # Mock the logger to evaluate calls
5345
service.initializing()
54-
if use_recwrap:
55-
recwrap = MockRW(offline_transport)
56-
recwrap.recipe_step = {"parameters": align_images_test_message}
57-
service.call_align_images(
58-
recwrap,
59-
header=header,
60-
message=None,
61-
)
62-
else:
63-
service.call_align_images(
64-
None,
65-
header=header,
66-
message=align_images_test_message,
67-
)
46+
recwrap = MockRW(offline_transport)
47+
recwrap.recipe_step = {"parameters": align_images_test_message}
48+
service.call_align_images(
49+
recwrap,
50+
header=header,
51+
message=None,
52+
)
6853

6954
# Check that the main block in the function was run
7055
service.log.info.assert_called_with(

0 commit comments

Comments
 (0)