Skip to content

Commit 2854158

Browse files
committed
fix: assign fired_triggers var, filter out api triggers pending check
1 parent 7916399 commit 2854158

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-runtime"
3-
version = "0.8.3"
3+
version = "0.8.4"
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"

src/uipath/runtime/resumable/runtime.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
UiPathRuntimeResult,
1717
UiPathRuntimeStatus,
1818
)
19+
from uipath.runtime.resumable import UiPathResumeTriggerType
1920
from uipath.runtime.resumable.protocols import (
2021
UiPathResumableStorageProtocol,
2122
UiPathResumeTriggerProtocol,
@@ -82,8 +83,11 @@ async def execute(
8283
suspension_result = await self._handle_suspension(result)
8384

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

@@ -115,6 +119,7 @@ async def stream(
115119

116120
final_result: UiPathRuntimeResult | None = None
117121
execution_completed = False
122+
fired_triggers = None
118123

119124
while not execution_completed:
120125
async for event in self.delegate.stream(input, options=options):
@@ -127,8 +132,12 @@ async def stream(
127132
if final_result:
128133
suspension_result = await self._handle_suspension(final_result)
129134

135+
# check if any trigger may be resumed
136+
# api triggers cannot be completed before suspending the job, skip them
130137
if suspension_result.status != UiPathRuntimeStatus.SUSPENDED or not (
131-
fired_triggers := await self._restore_resume_input(None)
138+
fired_triggers := await self._restore_resume_input(
139+
None, skip_trigger_types=[UiPathResumeTriggerType.API]
140+
)
132141
):
133142
yield suspension_result
134143
execution_completed = True
@@ -143,7 +152,9 @@ async def stream(
143152
options.resume = True
144153

145154
async def _restore_resume_input(
146-
self, input: dict[str, Any] | None
155+
self,
156+
input: dict[str, Any] | None,
157+
skip_trigger_types: list[UiPathResumeTriggerType] | None = None,
147158
) -> dict[str, Any] | None:
148159
"""Restore resume input from storage if not provided.
149160
@@ -180,14 +191,18 @@ async def _restore_resume_input(
180191
if not triggers:
181192
return None
182193

183-
return await self._build_resume_map(triggers)
194+
return await self._build_resume_map(triggers, skip_trigger_types)
184195

185196
async def _build_resume_map(
186-
self, triggers: list[UiPathResumeTrigger]
197+
self,
198+
triggers: list[UiPathResumeTrigger],
199+
skip_trigger_types: list[UiPathResumeTriggerType],
187200
) -> dict[str, Any]:
188201
# Build resume map: {interrupt_id: resume_data}
189202
resume_map: dict[str, Any] = {}
190203
for trigger in triggers:
204+
if skip_trigger_types and trigger.trigger_type in skip_trigger_types:
205+
continue
191206
try:
192207
data = await self.trigger_manager.read_trigger(trigger)
193208
assert trigger.interrupt_id is not None, (

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)