From 2dcdf8345ccb3a615d230b73b1d5691afa446494 Mon Sep 17 00:00:00 2001 From: Jacob Williamson Date: Wed, 19 Aug 2026 17:39:43 +0100 Subject: [PATCH 1/3] Bugfixes --- src/daq_queuing_service/plugins/converter.py | 5 ++- .../plugins/i15_1/i15_1_converter.py | 5 ++- src/daq_queuing_service/task_queue/queue.py | 21 ++++++---- .../plugins/i15-1/test_i15_1_converter.py | 42 +++++++++++++++++-- tests/unit_tests/test_api.py | 2 +- 5 files changed, 62 insertions(+), 13 deletions(-) diff --git a/src/daq_queuing_service/plugins/converter.py b/src/daq_queuing_service/plugins/converter.py index 5124080..c0a6545 100644 --- a/src/daq_queuing_service/plugins/converter.py +++ b/src/daq_queuing_service/plugins/converter.py @@ -6,7 +6,10 @@ from daq_queuing_service.task_queue.task import Experiment, Task, TaskWithPosition -class ConverterError(Exception): ... +class ConverterError(Exception): + def __init__(self, original: Exception): + super().__init__(f"{type(original).__name__}: {original}") + self.original = original class ValidateError(Exception): ... diff --git a/src/daq_queuing_service/plugins/i15_1/i15_1_converter.py b/src/daq_queuing_service/plugins/i15_1/i15_1_converter.py index 97db4b3..b53306f 100644 --- a/src/daq_queuing_service/plugins/i15_1/i15_1_converter.py +++ b/src/daq_queuing_service/plugins/i15_1/i15_1_converter.py @@ -65,6 +65,7 @@ def _construct_blueapi_tasks_from_experiment( self, experiment: Experiment, ) -> list[TaskRequest]: + LOGGER.debug(f"Converting to blueapi calls, experiment = {experiment}") sample_name = experiment.sample.name # Assume sample name is of form test_8_1 to load from position 8 on puck 1 _, position, puck = sample_name.split("_") @@ -225,6 +226,8 @@ def _construct_background_experiment( # Need to get sample info for test samples (air, empty capillary etc) sample=Sample(name="fq_1_1", id="", data={}), experiment_definition=ExperimentDefinition( - name="background_scan", id="", data={"background": background} + name="background_scan", + id="", + data={"background": background, "time_per_pdf": 10}, ), ) diff --git a/src/daq_queuing_service/task_queue/queue.py b/src/daq_queuing_service/task_queue/queue.py index b9b26e5..362b657 100644 --- a/src/daq_queuing_service/task_queue/queue.py +++ b/src/daq_queuing_service/task_queue/queue.py @@ -136,6 +136,7 @@ def _sync(self): modified, and also right before a call is popped off the front of the queue. """ LOGGER.debug("Syncing") + LOGGER.debug(f"Queue before sync: {self._queue}") for task_id in list(self._queue): task = self._tasks[task_id] if task.status in (Status.COMPLETE, Status.ERROR): @@ -162,7 +163,7 @@ def _sync(self): self._queue_history, ) except Exception as e: - raise ConverterError(*e.args) from e + raise ConverterError(e) from e # Update task_registry to match new tasks # Not needed as long as pre_process modifies in place @@ -200,7 +201,7 @@ def _sync(self): self._queue_history, ) except Exception as e: - raise ConverterError(*e.args) from e + raise ConverterError(e) from e self._call_queue.extend(new_calls) @@ -215,6 +216,7 @@ def _sync(self): self._save_contents() self._broadcast_changes() self._modifying.notify_all() + LOGGER.debug(f"Queue after sync: {self._queue}") def _copy_contents(self) -> QueueContents: return deepcopy( @@ -231,13 +233,18 @@ def _save_contents(self): self._last_good_contents = self._copy_contents() def _restore_from_contents(self, contents: QueueContents): - self._tasks = TaskRegistry(contents["tasks"]) - self._queue = contents["queue"] - self._history = contents["history"] - self._call_queue = contents["call_queue"] - self._call_history = contents["call_history"] + LOGGER.info(f"Restoring to contents: {contents}") + + restored = deepcopy(contents) + + self._tasks = TaskRegistry(restored["tasks"]) + self._queue = restored["queue"] + self._history = restored["history"] + self._call_queue = restored["call_queue"] + self._call_history = restored["call_history"] def _restore_latest_good_contents(self): + LOGGER.info("Restoring to last good contents") self._restore_from_contents(self._last_good_contents) def _broadcast_changes(self): diff --git a/tests/unit_tests/plugins/i15-1/test_i15_1_converter.py b/tests/unit_tests/plugins/i15-1/test_i15_1_converter.py index 366eb39..4e7a1b2 100644 --- a/tests/unit_tests/plugins/i15-1/test_i15_1_converter.py +++ b/tests/unit_tests/plugins/i15-1/test_i15_1_converter.py @@ -6,8 +6,10 @@ from blueapi.service.model import TaskRequest from daq_queuing_service.blueapi_interaction.blueapi_call import BlueapiCall +from daq_queuing_service.broadcaster import Broadcaster from daq_queuing_service.plugins.i15_1.backgrounds import BackgroundInfo from daq_queuing_service.plugins.i15_1.i15_1_converter import I151Converter +from daq_queuing_service.task_queue.queue import TaskQueue from daq_queuing_service.task_queue.task import ( Experiment, ExperimentDefinition, @@ -27,6 +29,34 @@ def assert_tasks_equal(task1: Task | TaskWithPosition, task2: Task | TaskWithPos assert task1 == task2 +@pytest.fixture +async def queue_with_i15_1_plugin(background_not_found_in_tiled: None): + queue = TaskQueue(converter=I151Converter(), broadcaster=Broadcaster()) + tasks = [ + Task( + experiment=Experiment( + name=f"task_{i}", + instrument_session="cm12345-1", + experiment_definition=ExperimentDefinition( + name="", + id="", + data={ + "list_of_temperatures": [100 * i, 100 * i + 20], + "time_per_pdf": i, + "settle_time": 5, + "ramp_rate": 10, + }, + ), + sample=Sample(name=f"sample_{i}_2", id=str(i), data={}), + ) + ) + for i in range(5) + ] + await queue.add_tasks(tasks) + await queue.resume_queue() + return queue + + @pytest.fixture(autouse=True) def background_found_in_tiled(): with patch( @@ -256,7 +286,7 @@ def test_if_no_background_found_in_tiled_then_background_scan_added_to_tasks( "experiment_definition": { "name": "background_scan", "id": "", - "data": {"background": {"bg_type": "fq"}}, + "data": {"background": {"bg_type": "fq"}, "time_per_pdf": 10}, }, }, "id": "", @@ -337,7 +367,7 @@ def test_same_experiment_in_different_instrument_sessions_will_add_background_in "experiment_definition": { "name": "background_scan", "id": "", - "data": {"background": {"bg_type": "fq"}}, + "data": {"background": {"bg_type": "fq"}, "time_per_pdf": 10}, }, }, "id": "", @@ -355,7 +385,7 @@ def test_same_experiment_in_different_instrument_sessions_will_add_background_in "experiment_definition": { "name": "background_scan", "id": "", - "data": {"background": {"bg_type": "fq"}}, + "data": {"background": {"bg_type": "fq"}, "time_per_pdf": 10}, }, }, "id": "", @@ -427,3 +457,9 @@ def test_add_tiled_background_to_md_adds_expected_metadata( I151Converter()._add_tiled_background_to_md(params, tiled_id, background) assert params == expected_params + + +async def test_queue_with_i15_1_converter_can_sync(queue_with_i15_1_plugin: TaskQueue): + first_task = await queue_with_i15_1_plugin.get_task_by_position(0) + assert first_task + await queue_with_i15_1_plugin.move_task(first_task.id, 2) diff --git a/tests/unit_tests/test_api.py b/tests/unit_tests/test_api.py index b3296c3..fb1bbf3 100644 --- a/tests/unit_tests/test_api.py +++ b/tests/unit_tests/test_api.py @@ -449,7 +449,7 @@ def fail_conversion( assert response.status_code == 422 assert response.json() == { "error": "converter_error", - "message": "Conversion failed because xyz", + "message": "SomeError: Conversion failed because xyz", } assert task_queue_with_history._queue == ["2", "3", "4"] From 8ae0bd8844a3b02f6c26a25d4588708a72f091cb Mon Sep 17 00:00:00 2001 From: Jacob Williamson Date: Thu, 20 Aug 2026 10:13:42 +0100 Subject: [PATCH 2/3] Get background time per pdf time from max in queue --- .../plugins/i15_1/backgrounds.py | 4 +- .../plugins/i15_1/i15_1_converter.py | 18 ++++++-- .../i15-1/test_get_background_tiled_id.py | 8 ++-- .../plugins/i15-1/test_i15_1_converter.py | 45 ++++++++++++------- 4 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/daq_queuing_service/plugins/i15_1/backgrounds.py b/src/daq_queuing_service/plugins/i15_1/backgrounds.py index 179b272..995f3cc 100644 --- a/src/daq_queuing_service/plugins/i15_1/backgrounds.py +++ b/src/daq_queuing_service/plugins/i15_1/backgrounds.py @@ -12,11 +12,11 @@ class BackgroundInfo(BaseModel): # https://github.com/DiamondLightSource/daq-queuing-service/issues/84 model_config = ConfigDict(frozen=True) bg_type: BACKGROUND_TYPES + time_per_pdf: int def add_tiled_id(self, tiled_id: str) -> "TiledBackground": return TiledBackground( - bg_type=self.bg_type, - tiled_id=tiled_id, + bg_type=self.bg_type, tiled_id=tiled_id, time_per_pdf=self.time_per_pdf ) diff --git a/src/daq_queuing_service/plugins/i15_1/i15_1_converter.py b/src/daq_queuing_service/plugins/i15_1/i15_1_converter.py index b53306f..740c86d 100644 --- a/src/daq_queuing_service/plugins/i15_1/i15_1_converter.py +++ b/src/daq_queuing_service/plugins/i15_1/i15_1_converter.py @@ -156,6 +156,14 @@ def _add_required_background_scans(self, tasks: list[Task]) -> list[Task]: # This can be made more robust https://github.com/DiamondLightSource/daq-queuing-service/issues/80 new_tasks: list[Task] = [] + pdf_times = [ + task.experiment.experiment_definition.data["time_per_pdf"] + for task in tasks + if isinstance(task.experiment, Experiment) + and "time_per_pdf" in task.experiment.experiment_definition.data + ] + max_time_per_pdf = max(pdf_times) if pdf_times else 10 + for task in tasks: experiment = task.experiment if ( @@ -163,7 +171,9 @@ def _add_required_background_scans(self, tasks: list[Task]) -> list[Task]: and experiment.name != BACKGROUND_SCAN ): instrument_session = experiment.instrument_session - backgrounds = self._get_required_backgrounds(experiment) + backgrounds = self._get_required_backgrounds( + experiment, max_time_per_pdf + ) for background in backgrounds: if tiled_id := get_background_tiled_id( @@ -200,9 +210,11 @@ def _remove_repeated_backgrounds(self, tasks: list[Task]) -> list[Task]: LOGGER.debug(f"Removing repeated background scan: {task.experiment}") return new_tasks - def _get_required_backgrounds(self, experiment: Experiment) -> list[BackgroundInfo]: + def _get_required_backgrounds( + self, experiment: Experiment, time_per_pdf: int + ) -> list[BackgroundInfo]: # This should be fleshed out https://github.com/DiamondLightSource/daq-queuing-service/issues/79 - return [BackgroundInfo(bg_type="fq")] + return [BackgroundInfo(bg_type="fq", time_per_pdf=time_per_pdf)] def _add_tiled_background_to_md( self, params: dict[str, Any], tiled_id: str, background: BackgroundInfo diff --git a/tests/unit_tests/plugins/i15-1/test_get_background_tiled_id.py b/tests/unit_tests/plugins/i15-1/test_get_background_tiled_id.py index 00220c2..f9399fa 100644 --- a/tests/unit_tests/plugins/i15-1/test_get_background_tiled_id.py +++ b/tests/unit_tests/plugins/i15-1/test_get_background_tiled_id.py @@ -41,7 +41,7 @@ def test_get_background_tiled_id_makes_expected_searches( client, search_2, search_3 = mock_tiled_searches get_background_tiled_id( client, - BackgroundInfo(bg_type="air"), + BackgroundInfo(bg_type="air", time_per_pdf=10), instrument_session="cm12345-1", ) client.search.assert_called_once_with( @@ -51,7 +51,7 @@ def test_get_background_tiled_id_makes_expected_searches( search_3.search.assert_called_once_with( Eq( key="start.experiment_definition.metadata.background", - value='{"bg_type":"air"}', + value='{"bg_type":"air","time_per_pdf":10}', ) ) @@ -63,7 +63,7 @@ def test_get_background_tiled_returns_most_recent_valid_background( assert ( get_background_tiled_id( client, - BackgroundInfo(bg_type="air"), + BackgroundInfo(bg_type="air", time_per_pdf=10), instrument_session="cm12345-1", ) == "tiled_id_2" @@ -78,7 +78,7 @@ def test_get_background_tiled_id_returns_none_if_no_matching_backgrounds_found( assert ( get_background_tiled_id( client, - BackgroundInfo(bg_type="air"), + BackgroundInfo(bg_type="air", time_per_pdf=10), instrument_session="cm12345-1", ) is None diff --git a/tests/unit_tests/plugins/i15-1/test_i15_1_converter.py b/tests/unit_tests/plugins/i15-1/test_i15_1_converter.py index 4e7a1b2..8a31534 100644 --- a/tests/unit_tests/plugins/i15-1/test_i15_1_converter.py +++ b/tests/unit_tests/plugins/i15-1/test_i15_1_converter.py @@ -286,7 +286,10 @@ def test_if_no_background_found_in_tiled_then_background_scan_added_to_tasks( "experiment_definition": { "name": "background_scan", "id": "", - "data": {"background": {"bg_type": "fq"}, "time_per_pdf": 10}, + "data": { + "background": {"bg_type": "fq", "time_per_pdf": 100}, + "time_per_pdf": 10, + }, }, }, "id": "", @@ -300,11 +303,13 @@ def test_if_no_background_found_in_tiled_then_background_scan_added_to_tasks( def test_add_required_background_scans_does_not_add_the_same_background_twice( tasks: list[Task], background_not_found_in_tiled: None ): - bg_1 = BackgroundInfo(bg_type="air") - bg_2 = BackgroundInfo(bg_type="bs") - bg_3 = BackgroundInfo(bg_type="fq") + bg_1 = BackgroundInfo(bg_type="air", time_per_pdf=5) + bg_2 = BackgroundInfo(bg_type="bs", time_per_pdf=10) + bg_3 = BackgroundInfo(bg_type="fq", time_per_pdf=15) - def fake_get_required_background(self: I151Converter, experiment: Experiment): + def fake_get_required_background( + self: I151Converter, experiment: Experiment, max_time_per_pdf: int + ): # Get the same background scans every other experiment # Only one of each background should be added if int(experiment.sample.id) % 2 == 0: @@ -367,7 +372,10 @@ def test_same_experiment_in_different_instrument_sessions_will_add_background_in "experiment_definition": { "name": "background_scan", "id": "", - "data": {"background": {"bg_type": "fq"}, "time_per_pdf": 10}, + "data": { + "background": {"bg_type": "fq", "time_per_pdf": 10}, + "time_per_pdf": 10, + }, }, }, "id": "", @@ -385,7 +393,10 @@ def test_same_experiment_in_different_instrument_sessions_will_add_background_in "experiment_definition": { "name": "background_scan", "id": "", - "data": {"background": {"bg_type": "fq"}, "time_per_pdf": 10}, + "data": { + "background": {"bg_type": "fq", "time_per_pdf": 10}, + "time_per_pdf": 10, + }, }, }, "id": "", @@ -410,10 +421,12 @@ def test_add_required_background_scans_if_found_in_tiled_then_no_background_adde ( {"sample": "my_sample"}, ["tiled_id"], - [BackgroundInfo(bg_type="bs")], + [BackgroundInfo(bg_type="bs", time_per_pdf=5)], { "metadata": { - "tiled_backgrounds": {"tiled_id": BackgroundInfo(bg_type="bs")} + "tiled_backgrounds": { + "tiled_id": BackgroundInfo(bg_type="bs", time_per_pdf=5) + } }, "sample": "my_sample", }, @@ -421,10 +434,12 @@ def test_add_required_background_scans_if_found_in_tiled_then_no_background_adde ( {}, ["tiled_id"], - [BackgroundInfo(bg_type="bs")], + [BackgroundInfo(bg_type="bs", time_per_pdf=5)], { "metadata": { - "tiled_backgrounds": {"tiled_id": BackgroundInfo(bg_type="bs")} + "tiled_backgrounds": { + "tiled_id": BackgroundInfo(bg_type="bs", time_per_pdf=5) + } }, }, ), @@ -432,14 +447,14 @@ def test_add_required_background_scans_if_found_in_tiled_then_no_background_adde {"sample": "my_sample"}, ["tiled_id_1", "tiled_id_2"], [ - BackgroundInfo(bg_type="bs"), - BackgroundInfo(bg_type="air"), + BackgroundInfo(bg_type="bs", time_per_pdf=5), + BackgroundInfo(bg_type="air", time_per_pdf=5), ], { "metadata": { "tiled_backgrounds": { - "tiled_id_1": BackgroundInfo(bg_type="bs"), - "tiled_id_2": BackgroundInfo(bg_type="air"), + "tiled_id_1": BackgroundInfo(bg_type="bs", time_per_pdf=5), + "tiled_id_2": BackgroundInfo(bg_type="air", time_per_pdf=5), } }, "sample": "my_sample", From da7274f2b50b47ec9bcbc1f92fad0cd82d6eb96a Mon Sep 17 00:00:00 2001 From: Jacob Williamson Date: Thu, 20 Aug 2026 15:32:20 +0100 Subject: [PATCH 3/3] PR comments --- .../plugins/i15_1/i15_1_converter.py | 9 ++- .../plugins/i15-1/test_i15_1_converter.py | 74 ++++++++++--------- 2 files changed, 48 insertions(+), 35 deletions(-) diff --git a/src/daq_queuing_service/plugins/i15_1/i15_1_converter.py b/src/daq_queuing_service/plugins/i15_1/i15_1_converter.py index 740c86d..aef1442 100644 --- a/src/daq_queuing_service/plugins/i15_1/i15_1_converter.py +++ b/src/daq_queuing_service/plugins/i15_1/i15_1_converter.py @@ -160,8 +160,8 @@ def _add_required_background_scans(self, tasks: list[Task]) -> list[Task]: task.experiment.experiment_definition.data["time_per_pdf"] for task in tasks if isinstance(task.experiment, Experiment) - and "time_per_pdf" in task.experiment.experiment_definition.data ] + max_time_per_pdf = max(pdf_times) if pdf_times else 10 for task in tasks: @@ -214,6 +214,8 @@ def _get_required_backgrounds( self, experiment: Experiment, time_per_pdf: int ) -> list[BackgroundInfo]: # This should be fleshed out https://github.com/DiamondLightSource/daq-queuing-service/issues/79 + # And we should instead do the following to work out pdf_times for backgrounds + # https://github.com/DiamondLightSource/daq-queuing-service/issues/80 return [BackgroundInfo(bg_type="fq", time_per_pdf=time_per_pdf)] def _add_tiled_background_to_md( @@ -240,6 +242,9 @@ def _construct_background_experiment( experiment_definition=ExperimentDefinition( name="background_scan", id="", - data={"background": background, "time_per_pdf": 10}, + data={ + "background": background, + "time_per_pdf": background.time_per_pdf, + }, ), ) diff --git a/tests/unit_tests/plugins/i15-1/test_i15_1_converter.py b/tests/unit_tests/plugins/i15-1/test_i15_1_converter.py index 8a31534..fa0b432 100644 --- a/tests/unit_tests/plugins/i15-1/test_i15_1_converter.py +++ b/tests/unit_tests/plugins/i15-1/test_i15_1_converter.py @@ -21,17 +21,8 @@ ) -def assert_tasks_equal(task1: Task | TaskWithPosition, task2: Task | TaskWithPosition): - # Check two tasks are equal other than the generated UUID - copy1 = type(task1).model_validate(task1) - copy2 = type(task2).model_validate(task2) - copy1.id = copy2.id = "" - assert task1 == task2 - - @pytest.fixture -async def queue_with_i15_1_plugin(background_not_found_in_tiled: None): - queue = TaskQueue(converter=I151Converter(), broadcaster=Broadcaster()) +def i15_1_tasks(tasks: list[Task]): tasks = [ Task( experiment=Experiment( @@ -42,7 +33,7 @@ async def queue_with_i15_1_plugin(background_not_found_in_tiled: None): id="", data={ "list_of_temperatures": [100 * i, 100 * i + 20], - "time_per_pdf": i, + "time_per_pdf": (i + 1) * 5, "settle_time": 5, "ramp_rate": 10, }, @@ -52,7 +43,24 @@ async def queue_with_i15_1_plugin(background_not_found_in_tiled: None): ) for i in range(5) ] - await queue.add_tasks(tasks) + return tasks + + +def assert_tasks_equal(task1: Task | TaskWithPosition, task2: Task | TaskWithPosition): + # Check two tasks are equal other than the generated UUID + copy1 = type(task1).model_validate(task1) + copy2 = type(task2).model_validate(task2) + copy1.id = copy2.id = "" + assert task1 == task2 + + +@pytest.fixture +async def queue_with_i15_1_plugin( + i15_1_tasks: list[Task], background_not_found_in_tiled: None +): + queue = TaskQueue(converter=I151Converter(), broadcaster=Broadcaster()) + + await queue.add_tasks(i15_1_tasks) await queue.resume_queue() return queue @@ -77,9 +85,9 @@ def background_not_found_in_tiled(): @pytest.fixture() def tasks_and_calls( - tasks: list[Task], + i15_1_tasks: list[Task], ) -> tuple[list[TaskWithPosition], list[BlueapiCall]]: - tasks_with_positions = [TaskWithPosition.from_task(task) for task in tasks] + tasks_with_positions = [TaskWithPosition.from_task(task) for task in i15_1_tasks] calls: list[BlueapiCall] = [] for task in tasks_with_positions: assert isinstance(task.experiment, Experiment) @@ -288,7 +296,7 @@ def test_if_no_background_found_in_tiled_then_background_scan_added_to_tasks( "id": "", "data": { "background": {"bg_type": "fq", "time_per_pdf": 100}, - "time_per_pdf": 10, + "time_per_pdf": 100, }, }, }, @@ -301,7 +309,7 @@ def test_if_no_background_found_in_tiled_then_background_scan_added_to_tasks( def test_add_required_background_scans_does_not_add_the_same_background_twice( - tasks: list[Task], background_not_found_in_tiled: None + i15_1_tasks: list[Task], background_not_found_in_tiled: None ): bg_1 = BackgroundInfo(bg_type="air", time_per_pdf=5) bg_2 = BackgroundInfo(bg_type="bs", time_per_pdf=10) @@ -317,12 +325,12 @@ def fake_get_required_background( else: return [bg_3] - assert len(tasks) == 5 + assert len(i15_1_tasks) == 5 with patch( "daq_queuing_service.plugins.i15_1.i15_1_converter.I151Converter._get_required_backgrounds", fake_get_required_background, ): - new_tasks = I151Converter()._add_required_background_scans(tasks) + new_tasks = I151Converter()._add_required_background_scans(i15_1_tasks) assert len(new_tasks) == 8 @@ -330,7 +338,7 @@ def fake_get_required_background( new_tasks[0], Task( experiment=I151Converter()._construct_background_experiment( - bg_1, instrument_session="" + bg_1, instrument_session="cm12345-1" ), ), ) @@ -338,7 +346,7 @@ def fake_get_required_background( new_tasks[1], Task( experiment=I151Converter()._construct_background_experiment( - bg_2, instrument_session="" + bg_2, instrument_session="cm12345-1" ), ), ) @@ -347,34 +355,34 @@ def fake_get_required_background( new_tasks[3], Task( experiment=I151Converter()._construct_background_experiment( - bg_3, instrument_session="" + bg_3, instrument_session="cm12345-1" ), ), ) def test_same_experiment_in_different_instrument_sessions_will_add_background_in_each( - tasks: list[Task], background_not_found_in_tiled: None + i15_1_tasks: list[Task], background_not_found_in_tiled: None ): - tasks[1].experiment.instrument_session = "different" + i15_1_tasks[1].experiment.instrument_session = "different" - assert len(tasks) == 5 + assert len(i15_1_tasks) == 5 - new_tasks = I151Converter()._add_required_background_scans(tasks) + new_tasks = I151Converter()._add_required_background_scans(i15_1_tasks) assert len(new_tasks) == 7 new_tasks[0].id = "" assert new_tasks[0].model_dump() == { "experiment": { "name": "Background", - "instrument_session": "", + "instrument_session": "cm12345-1", "sample": {"name": "fq_1_1", "id": "", "data": {}}, "experiment_definition": { "name": "background_scan", "id": "", "data": { - "background": {"bg_type": "fq", "time_per_pdf": 10}, - "time_per_pdf": 10, + "background": {"bg_type": "fq", "time_per_pdf": 25}, + "time_per_pdf": 25, }, }, }, @@ -394,8 +402,8 @@ def test_same_experiment_in_different_instrument_sessions_will_add_background_in "name": "background_scan", "id": "", "data": { - "background": {"bg_type": "fq", "time_per_pdf": 10}, - "time_per_pdf": 10, + "background": {"bg_type": "fq", "time_per_pdf": 25}, + "time_per_pdf": 25, }, }, }, @@ -408,11 +416,11 @@ def test_same_experiment_in_different_instrument_sessions_will_add_background_in def test_add_required_background_scans_if_found_in_tiled_then_no_background_added( - tasks: list[Task], + i15_1_tasks: list[Task], background_found_in_tiled: None, ): - tasks_after = I151Converter()._add_required_background_scans(tasks) - assert tasks_after == tasks + tasks_after = I151Converter()._add_required_background_scans(i15_1_tasks) + assert tasks_after == i15_1_tasks @pytest.mark.parametrize(