Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "UiPath Developer Console"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
dependencies = [
"uipath-runtime>=0.0.5, <0.1.0",
"uipath-runtime>=0.0.7, <0.1.0",
"textual>=6.5.0",
"pyperclip>=1.11.0",
]
Expand Down
6 changes: 3 additions & 3 deletions src/uipath/dev/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from uipath.runtime import (
UiPathExecuteOptions,
UiPathExecutionRuntime,
UiPathRuntimeFactory,
UiPathRuntimeFactoryProtocol,
UiPathRuntimeStatus,
)
from uipath.runtime.errors import UiPathErrorContract, UiPathRuntimeError
Expand Down Expand Up @@ -52,7 +52,7 @@ class UiPathDeveloperConsole(App[Any]):

def __init__(
self,
runtime_factory: UiPathRuntimeFactory[Any],
runtime_factory: UiPathRuntimeFactoryProtocol,
trace_manager: UiPathTraceManager,
**kwargs,
):
Expand Down Expand Up @@ -207,7 +207,7 @@ async def _execute_runtime(self, run: ExecutionRun):
run_id=run.id,
callback=self._handle_log_message,
)
runtime = self.runtime_factory.new_runtime(entrypoint=run.entrypoint)
runtime = await self.runtime_factory.new_runtime(entrypoint=run.entrypoint)
execution_runtime = UiPathExecutionRuntime(
delegate=runtime,
trace_manager=self.trace_manager,
Expand Down
35 changes: 24 additions & 11 deletions src/uipath/dev/_demo/mock_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

import asyncio
import logging
from typing import Any, Optional
from typing import Any, AsyncGenerator, Optional

from opentelemetry import trace
from uipath.runtime import (
UiPathBaseRuntime,
UiPathExecuteOptions,
UiPathRuntimeFactory,
UiPathRuntimeEvent,
UiPathRuntimeProtocol,
UiPathRuntimeResult,
UiPathRuntimeStatus,
UiPathStreamOptions,
)
from uipath.runtime.schema import UiPathRuntimeSchema

logger = logging.getLogger(__name__)


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

async def get_schema(self) -> UiPathRuntimeSchema:
Expand Down Expand Up @@ -224,18 +225,30 @@ async def execute(
status=UiPathRuntimeStatus.SUCCESSFUL,
)

async def cleanup(self) -> None:
logger.info("MockRuntime: cleanup() invoked")
print("[MockRuntime] cleanup() invoked")
async def stream(
self,
input: Optional[dict[str, Any]] = None,
options: Optional[UiPathStreamOptions] = None,
) -> AsyncGenerator[UiPathRuntimeEvent, None]:
logger.info("MockRuntime: stream() invoked")
print("[MockRuntime] stream() invoked")
yield await self.execute(input=input, options=options)

async def dispose(self) -> None:
logger.info("MockRuntime: dispose() invoked")
print("[MockRuntime] dispose() invoked")


class MockRuntimeFactory(UiPathRuntimeFactory[MockRuntime]):
class MockRuntimeFactory:
"""Runtime factory compatible with UiPathDevTerminal expectations."""

# This is the method the Textual app calls here:
# runtime = self.runtime_factory.new_runtime(entrypoint=run.entrypoint)
def new_runtime(self, entrypoint: str) -> MockRuntime:
# runtime = await self.runtime_factory.new_runtime(entrypoint=run.entrypoint)
async def new_runtime(self, entrypoint: str) -> UiPathRuntimeProtocol:
return MockRuntime()

def discover_runtimes(self) -> list[MockRuntime]:
def discover_runtimes(self) -> list[UiPathRuntimeProtocol]:
return []

def discover_entrypoints(self) -> list[str]:
return []
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading