Skip to content

Commit f034115

Browse files
committed
fix: fired triggers follow-up
1 parent f6eb7e7 commit f034115

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
22
name = "uipath-runtime"
3-
version = "0.8.4"
3+
version = "0.8.5"
44
description = "Runtime abstractions and interfaces for building agents and automation scripts in the UiPath ecosystem"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
77
dependencies = [
8-
"uipath-core>=0.4.0, <0.5.0",
8+
"uipath-core>=0.4.1, <0.5.0",
99
]
1010
classifiers = [
1111
"Intended Audience :: Developers",

src/uipath/runtime/resumable/runtime.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ async def execute(
8585
# check if any trigger may be resumed
8686
# api triggers cannot be completed before suspending the job, skip them
8787
if suspension_result.status != UiPathRuntimeStatus.SUSPENDED or not (
88-
fired_triggers := await self._restore_resume_input(
89-
None, skip_trigger_types=[UiPathResumeTriggerType.API]
90-
)
88+
fired_triggers := await self._get_fired_triggers()
9189
):
9290
return suspension_result
9391

@@ -133,11 +131,8 @@ async def stream(
133131
suspension_result = await self._handle_suspension(final_result)
134132

135133
# check if any trigger may be resumed
136-
# api triggers cannot be completed before suspending the job, skip them
137134
if suspension_result.status != UiPathRuntimeStatus.SUSPENDED or not (
138-
fired_triggers := await self._restore_resume_input(
139-
None, skip_trigger_types=[UiPathResumeTriggerType.API]
140-
)
135+
fired_triggers := await self._get_fired_triggers()
141136
):
142137
yield suspension_result
143138
execution_completed = True
@@ -151,10 +146,26 @@ async def stream(
151146
else:
152147
options.resume = True
153148

149+
async def _get_fired_triggers(self) -> dict[str, Any]:
150+
"""Check stored triggers for any that have already fired (excluding API triggers).
151+
152+
API triggers cannot be completed before suspending the job, so they are skipped.
153+
154+
Returns:
155+
A resume map of {interrupt_id: resume_data} for fired triggers, or empty dict.
156+
"""
157+
triggers = await self.storage.get_triggers(self.runtime_id)
158+
if not triggers:
159+
return {}
160+
161+
non_api_triggers = [
162+
t for t in triggers if t.trigger_type != UiPathResumeTriggerType.API
163+
]
164+
return await self._build_resume_map(non_api_triggers)
165+
154166
async def _restore_resume_input(
155167
self,
156168
input: dict[str, Any] | None,
157-
skip_trigger_types: list[UiPathResumeTriggerType] | None = None,
158169
) -> dict[str, Any] | None:
159170
"""Restore resume input from storage if not provided.
160171
@@ -191,18 +202,22 @@ async def _restore_resume_input(
191202
if not triggers:
192203
return None
193204

194-
return await self._build_resume_map(triggers, skip_trigger_types)
205+
return await self._build_resume_map(triggers)
195206

196207
async def _build_resume_map(
197208
self,
198209
triggers: list[UiPathResumeTrigger],
199-
skip_trigger_types: list[UiPathResumeTriggerType] | None,
200210
) -> dict[str, Any]:
201-
# Build resume map: {interrupt_id: resume_data}
211+
"""Build resume map from triggers: {interrupt_id: resume_data}.
212+
213+
Args:
214+
triggers: List of triggers to read and map
215+
216+
Returns:
217+
A dict mapping interrupt_id to the trigger's resume data.
218+
"""
202219
resume_map: dict[str, Any] = {}
203220
for trigger in triggers:
204-
if skip_trigger_types and trigger.trigger_type in skip_trigger_types:
205-
continue
206221
try:
207222
data = await self.trigger_manager.read_trigger(trigger)
208223
assert trigger.interrupt_id is not None, (

uv.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)