Skip to content

Commit 737c58c

Browse files
authored
fix(robot-server): notify /runs when a non-current run is deleted (#14974)
Closes RQA-2599
1 parent 2d57126 commit 737c58c

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

robot-server/robot_server/runs/run_data_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ async def delete(self, run_id: str) -> None:
284284
"""
285285
if run_id == self._engine_store.current_run_id:
286286
await self._engine_store.clear()
287-
await self._runs_publisher.clean_up_current_run()
287+
288+
await self._runs_publisher.clean_up_run(run_id=run_id)
288289

289290
self._run_store.remove(run_id=run_id)
290291

robot-server/robot_server/service/notifications/publishers/runs_publisher.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,33 +71,33 @@ async def initialize(
7171
)
7272
self._engine_state_slice = EngineStateSlice()
7373

74-
await self._publish_runs_advise_refetch_async()
74+
await self._publish_runs_advise_refetch_async(run_id=run_id)
7575

76-
async def clean_up_current_run(self) -> None:
77-
"""Publish final refetch and unsubscribe flags."""
78-
await self._publish_runs_advise_refetch_async()
79-
await self._publish_runs_advise_unsubscribe_async()
76+
async def clean_up_run(self, run_id: str) -> None:
77+
"""Publish final refetch and unsubscribe flags for the given run."""
78+
await self._publish_runs_advise_refetch_async(run_id=run_id)
79+
await self._publish_runs_advise_unsubscribe_async(run_id=run_id)
8080

8181
async def _publish_current_command(self) -> None:
8282
"""Publishes the equivalent of GET /runs/:runId/commands?cursor=null&pageLength=1."""
8383
await self._client.publish_advise_refetch_async(
8484
topic=Topics.RUNS_CURRENT_COMMAND
8585
)
8686

87-
async def _publish_runs_advise_refetch_async(self) -> None:
87+
async def _publish_runs_advise_refetch_async(self, run_id: str) -> None:
8888
"""Publish a refetch flag for relevant runs topics."""
89+
await self._client.publish_advise_refetch_async(topic=Topics.RUNS)
90+
8991
if self._run_hooks is not None:
90-
await self._client.publish_advise_refetch_async(topic=Topics.RUNS)
9192
await self._client.publish_advise_refetch_async(
92-
topic=f"{Topics.RUNS}/{self._run_hooks.run_id}"
93+
topic=f"{Topics.RUNS}/{run_id}"
9394
)
9495

95-
async def _publish_runs_advise_unsubscribe_async(self) -> None:
96+
async def _publish_runs_advise_unsubscribe_async(self, run_id: str) -> None:
9697
"""Publish an unsubscribe flag for relevant runs topics."""
97-
if self._run_hooks is not None:
98-
await self._client.publish_advise_unsubscribe_async(
99-
topic=f"{Topics.RUNS}/{self._run_hooks.run_id}"
100-
)
98+
await self._client.publish_advise_unsubscribe_async(
99+
topic=f"{Topics.RUNS}/{run_id}"
100+
)
101101

102102
async def _handle_current_command_change(self) -> None:
103103
"""Publish a refetch flag if the current command has changed."""
@@ -121,7 +121,9 @@ async def _handle_engine_status_change(self) -> None:
121121
and self._engine_state_slice.state_summary_status
122122
!= current_state_summary.status
123123
):
124-
await self._publish_runs_advise_refetch_async()
124+
await self._publish_runs_advise_refetch_async(
125+
run_id=self._run_hooks.run_id
126+
)
125127
self._engine_state_slice.state_summary_status = (
126128
current_state_summary.status
127129
)

robot-server/tests/service/notifications/publishers/test_runs_publisher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def test_clean_up_current_run(
7171
"""It should publish to appropriate topics at the end of a run."""
7272
await runs_publisher.initialize("1234", AsyncMock(), AsyncMock())
7373

74-
await runs_publisher.clean_up_current_run()
74+
await runs_publisher.clean_up_run(run_id="1234")
7575

7676
notification_client.publish_advise_refetch_async.assert_any_await(topic=Topics.RUNS)
7777
notification_client.publish_advise_refetch_async.assert_any_await(

0 commit comments

Comments
 (0)