Skip to content

Commit 4a4868d

Browse files
authored
Merge pull request #41 from UiPath/fix/resumable_output
fix: debugger emit suspend/resumed
2 parents 37393ee + 1576544 commit 4a4868d

File tree

5 files changed

+142
-125
lines changed

5 files changed

+142
-125
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.1.3"
3+
version = "0.2.0"
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.0.9, <0.1.0",
8+
"uipath-core>=0.1.0, <0.2.0",
99
]
1010
classifiers = [
1111
"Intended Audience :: Developers",

src/uipath/runtime/debug/bridge.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ async def emit_breakpoint_hit(
3737
"""Notify debugger that a breakpoint was hit."""
3838
...
3939

40+
async def emit_execution_suspended(
41+
self, runtime_result: UiPathRuntimeResult
42+
) -> None:
43+
"""Notify debugger that the execution has been suspended."""
44+
...
45+
46+
async def emit_execution_resumed(self, resume_data: Any) -> None:
47+
"""Notify debugger that the execution has resumed."""
48+
...
49+
4050
async def emit_execution_completed(
4151
self,
4252
runtime_result: UiPathRuntimeResult,

src/uipath/runtime/debug/runtime.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
)
2828
from uipath.runtime.resumable.protocols import UiPathResumeTriggerReaderProtocol
2929
from uipath.runtime.resumable.runtime import UiPathResumableRuntime
30-
from uipath.runtime.resumable.trigger import UiPathResumeTrigger
30+
from uipath.runtime.resumable.trigger import (
31+
UiPathResumeTrigger,
32+
UiPathResumeTriggerType,
33+
)
3134
from uipath.runtime.schema import UiPathRuntimeSchema
3235

3336
logger = logging.getLogger(__name__)
@@ -181,20 +184,24 @@ async def _stream_and_debug(
181184
and final_result.status == UiPathRuntimeStatus.SUSPENDED
182185
and final_result.trigger
183186
):
184-
state_event = UiPathRuntimeStateEvent(
185-
node_name="<suspended>",
186-
payload={
187-
"status": "suspended",
188-
"trigger": final_result.trigger.model_dump(),
189-
},
187+
await self.debug_bridge.emit_execution_suspended(
188+
final_result
190189
)
191-
await self.debug_bridge.emit_state_update(state_event)
192190

193191
resume_data: dict[str, Any] | None = None
194192
try:
195-
resume_data = await self._poll_trigger(
196-
final_result.trigger, self.delegate.trigger_manager
197-
)
193+
if (
194+
final_result.trigger.trigger_type
195+
== UiPathResumeTriggerType.API
196+
):
197+
resume_data = (
198+
await self.debug_bridge.wait_for_resume()
199+
)
200+
else:
201+
resume_data = await self._poll_trigger(
202+
final_result.trigger,
203+
self.delegate.trigger_manager,
204+
)
198205
except UiPathDebugQuitError:
199206
final_result = UiPathRuntimeResult(
200207
status=UiPathRuntimeStatus.SUCCESSFUL,
@@ -203,14 +210,9 @@ async def _stream_and_debug(
203210
execution_completed = True
204211

205212
if resume_data is not None:
206-
resumed_event = UiPathRuntimeStateEvent(
207-
node_name="<resumed>",
208-
payload={
209-
"status": "resumed",
210-
"data": resume_data,
211-
},
213+
await self.debug_bridge.emit_execution_resumed(
214+
resume_data
212215
)
213-
await self.debug_bridge.emit_state_update(resumed_event)
214216

215217
# Continue with resumed execution
216218
current_input = resume_data

src/uipath/runtime/resumable/runtime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ async def _restore_resume_input(
111111
Input to use for resume, either provided or from storage
112112
"""
113113
# If user provided explicit input, use it
114-
if input:
114+
if input is not None:
115115
return input
116116

117117
# Otherwise, fetch from storage
@@ -146,6 +146,7 @@ async def _handle_suspension(
146146

147147
suspended_result = UiPathRuntimeResult(
148148
status=UiPathRuntimeStatus.SUSPENDED,
149+
output=result.output,
149150
)
150151

151152
if result.output:

0 commit comments

Comments
 (0)