Skip to content

Commit 8ff70cc

Browse files
authored
Merge pull request #86 from UiPath/fix/clear_fired_triggers
fix: fired triggers follow-up
2 parents f6eb7e7 + 92a2d2a commit 8ff70cc

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
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 & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,8 @@ async def execute(
8383
suspension_result = await self._handle_suspension(result)
8484

8585
# check if any trigger may be resumed
86-
# api triggers cannot be completed before suspending the job, skip them
8786
if suspension_result.status != UiPathRuntimeStatus.SUSPENDED or not (
88-
fired_triggers := await self._restore_resume_input(
89-
None, skip_trigger_types=[UiPathResumeTriggerType.API]
90-
)
87+
fired_triggers := await self._get_fired_triggers()
9188
):
9289
return suspension_result
9390

@@ -133,11 +130,8 @@ async def stream(
133130
suspension_result = await self._handle_suspension(final_result)
134131

135132
# check if any trigger may be resumed
136-
# api triggers cannot be completed before suspending the job, skip them
137133
if suspension_result.status != UiPathRuntimeStatus.SUSPENDED or not (
138-
fired_triggers := await self._restore_resume_input(
139-
None, skip_trigger_types=[UiPathResumeTriggerType.API]
140-
)
134+
fired_triggers := await self._get_fired_triggers()
141135
):
142136
yield suspension_result
143137
execution_completed = True
@@ -151,10 +145,26 @@ async def stream(
151145
else:
152146
options.resume = True
153147

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

194-
return await self._build_resume_map(triggers, skip_trigger_types)
204+
return await self._build_resume_map(triggers)
195205

196206
async def _build_resume_map(
197207
self,
198208
triggers: list[UiPathResumeTrigger],
199-
skip_trigger_types: list[UiPathResumeTriggerType] | None,
200209
) -> dict[str, Any]:
201-
# Build resume map: {interrupt_id: resume_data}
210+
"""Build resume map from triggers: {interrupt_id: resume_data}.
211+
212+
Args:
213+
triggers: List of triggers to read and map
214+
215+
Returns:
216+
A dict mapping interrupt_id to the trigger's resume data.
217+
"""
202218
resume_map: dict[str, Any] = {}
203219
for trigger in triggers:
204-
if skip_trigger_types and trigger.trigger_type in skip_trigger_types:
205-
continue
206220
try:
207221
data = await self.trigger_manager.read_trigger(trigger)
208222
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)