Skip to content

Commit bd7ba60

Browse files
authored
Merge pull request #4 from UiPath/fix/add_custom_log_handler
fix: update runtime protocol
2 parents 03f8571 + a191d6a commit bd7ba60

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "UiPath Developer Console"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
77
dependencies = [
8-
"uipath-runtime>=0.0.5, <0.1.0",
8+
"uipath-runtime>=0.0.7, <0.1.0",
99
"textual>=6.5.0",
1010
"pyperclip>=1.11.0",
1111
]

src/uipath/dev/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from uipath.runtime import (
2020
UiPathExecuteOptions,
2121
UiPathExecutionRuntime,
22-
UiPathRuntimeFactory,
22+
UiPathRuntimeFactoryProtocol,
2323
UiPathRuntimeStatus,
2424
)
2525
from uipath.runtime.errors import UiPathErrorContract, UiPathRuntimeError
@@ -52,7 +52,7 @@ class UiPathDeveloperConsole(App[Any]):
5252

5353
def __init__(
5454
self,
55-
runtime_factory: UiPathRuntimeFactory[Any],
55+
runtime_factory: UiPathRuntimeFactoryProtocol,
5656
trace_manager: UiPathTraceManager,
5757
**kwargs,
5858
):
@@ -207,7 +207,7 @@ async def _execute_runtime(self, run: ExecutionRun):
207207
run_id=run.id,
208208
callback=self._handle_log_message,
209209
)
210-
runtime = self.runtime_factory.new_runtime(entrypoint=run.entrypoint)
210+
runtime = await self.runtime_factory.new_runtime(entrypoint=run.entrypoint)
211211
execution_runtime = UiPathExecutionRuntime(
212212
delegate=runtime,
213213
trace_manager=self.trace_manager,

src/uipath/dev/_demo/mock_runtime.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22

33
import asyncio
44
import logging
5-
from typing import Any, Optional
5+
from typing import Any, AsyncGenerator, Optional
66

77
from opentelemetry import trace
88
from uipath.runtime import (
9-
UiPathBaseRuntime,
109
UiPathExecuteOptions,
11-
UiPathRuntimeFactory,
10+
UiPathRuntimeEvent,
11+
UiPathRuntimeProtocol,
1212
UiPathRuntimeResult,
1313
UiPathRuntimeStatus,
14+
UiPathStreamOptions,
1415
)
1516
from uipath.runtime.schema import UiPathRuntimeSchema
1617

1718
logger = logging.getLogger(__name__)
1819

1920

20-
class MockRuntime(UiPathBaseRuntime):
21+
class MockRuntime:
2122
"""A mock runtime that simulates a multi-step workflow with rich telemetry."""
2223

2324
async def get_schema(self) -> UiPathRuntimeSchema:
@@ -224,18 +225,30 @@ async def execute(
224225
status=UiPathRuntimeStatus.SUCCESSFUL,
225226
)
226227

227-
async def cleanup(self) -> None:
228-
logger.info("MockRuntime: cleanup() invoked")
229-
print("[MockRuntime] cleanup() invoked")
228+
async def stream(
229+
self,
230+
input: Optional[dict[str, Any]] = None,
231+
options: Optional[UiPathStreamOptions] = None,
232+
) -> AsyncGenerator[UiPathRuntimeEvent, None]:
233+
logger.info("MockRuntime: stream() invoked")
234+
print("[MockRuntime] stream() invoked")
235+
yield await self.execute(input=input, options=options)
236+
237+
async def dispose(self) -> None:
238+
logger.info("MockRuntime: dispose() invoked")
239+
print("[MockRuntime] dispose() invoked")
230240

231241

232-
class MockRuntimeFactory(UiPathRuntimeFactory[MockRuntime]):
242+
class MockRuntimeFactory:
233243
"""Runtime factory compatible with UiPathDevTerminal expectations."""
234244

235245
# This is the method the Textual app calls here:
236-
# runtime = self.runtime_factory.new_runtime(entrypoint=run.entrypoint)
237-
def new_runtime(self, entrypoint: str) -> MockRuntime:
246+
# runtime = await self.runtime_factory.new_runtime(entrypoint=run.entrypoint)
247+
async def new_runtime(self, entrypoint: str) -> UiPathRuntimeProtocol:
238248
return MockRuntime()
239249

240-
def discover_runtimes(self) -> list[MockRuntime]:
250+
def discover_runtimes(self) -> list[UiPathRuntimeProtocol]:
251+
return []
252+
253+
def discover_entrypoints(self) -> list[str]:
241254
return []

uv.lock

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

0 commit comments

Comments
 (0)