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
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[project]
name = "uipath-runtime"
version = "0.0.1"
version = "0.0.2"
description = "UiPath Runtime abstractions"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
dependencies = [
"opentelemetry-sdk>=1.38.0",
"opentelemetry-instrumentation>=0.59b0",
"pydantic>=2.12.3",
"uipath-core>=0.0.1",
]
classifiers = [
"Intended Audience :: Developers",
Expand Down Expand Up @@ -96,7 +97,7 @@ warn_required_dynamic_aliases = true
[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = "test_*.py"
addopts = "-ra -q --cov"
addopts = "-ra -q --cov=src/uipath --cov-report=term-missing"
asyncio_default_fixture_loop_scope = "function"
asyncio_mode = "auto"

Expand Down
5 changes: 3 additions & 2 deletions src/uipath/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from uipath.runtime.base import UiPathBaseRuntime
from uipath.runtime.context import UiPathRuntimeContext
from uipath.runtime.events import UiPathRuntimeEvent
from uipath.runtime.factory import UiPathRuntimeFactory
from uipath.runtime.factory import UiPathRuntimeExecutor, UiPathRuntimeFactory
from uipath.runtime.result import (
UiPathApiTrigger,
UiPathBreakpointResult,
Expand All @@ -16,10 +16,11 @@
"UiPathRuntimeContext",
"UiPathBaseRuntime",
"UiPathRuntimeFactory",
"UiPathRuntimeExecutor",
"UiPathRuntimeResult",
"UiPathRuntimeEvent",
"UiPathBreakpointResult",
"UiPathApiTrigger",
"UiPathResumeTrigger",
"UiPathResumeTriggerType",
"UiPathBreakpointResult",
]
47 changes: 7 additions & 40 deletions src/uipath/runtime/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
import logging
import os
from abc import ABC, abstractmethod
from typing import (
AsyncGenerator,
List,
Optional,
Union,
)

from pydantic import BaseModel
from typing import AsyncGenerator

from uipath.runtime.context import UiPathRuntimeContext
from uipath.runtime.errors import (
Expand All @@ -26,8 +19,7 @@
from uipath.runtime.logging._interceptor import UiPathRuntimeLogsInterceptor
from uipath.runtime.result import UiPathRuntimeResult, UiPathRuntimeStatus
from uipath.runtime.schema import (
UiPathRuntimeBindingResource,
UiPathRuntimeEntrypoint,
UiPathRuntimeSchema,
)

logger = logging.getLogger(__name__)
Expand All @@ -49,28 +41,8 @@ def __init__(self, context: UiPathRuntimeContext):
"""Initialize the runtime with the provided context."""
self.context = context

@classmethod
def from_context(cls, context: UiPathRuntimeContext):
"""Factory method to create a runtime instance from a context.

Args:
context: The runtime context with configuration

Returns:
An initialized Runtime instance
"""
runtime = cls(context)
return runtime

async def get_binding_resources(self) -> List[UiPathRuntimeBindingResource]:
"""Get binding resources for this runtime.

Returns: A list of binding resources.
"""
raise NotImplementedError()

async def get_entrypoint(self) -> UiPathRuntimeEntrypoint:
"""Get entrypoint for this runtime.
async def get_schema(self) -> UiPathRuntimeSchema:
"""Get schema for this runtime.

Returns: A entrypoint for this runtime.
"""
Expand Down Expand Up @@ -130,7 +102,7 @@ async def __aenter__(self):
return self

@abstractmethod
async def execute(self) -> Optional[UiPathRuntimeResult]:
async def execute(self) -> UiPathRuntimeResult:
"""Execute with the provided context.

Returns:
Expand All @@ -143,7 +115,7 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:

async def stream(
self,
) -> AsyncGenerator[Union[UiPathRuntimeEvent, UiPathRuntimeResult], None]:
) -> AsyncGenerator[UiPathRuntimeEvent, None]:
"""Stream execution events in real-time.

This is an optional method that runtimes can implement to support streaming.
Expand Down Expand Up @@ -233,12 +205,7 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
# Write the execution output to file if requested
if self.context.output_file:
with open(self.context.output_file, "w") as f:
if isinstance(execution_result.output, BaseModel):
f.write(execution_result.output.model_dump())
else:
json.dump(
execution_result.output or {}, f, indent=2, default=str
)
f.write(content.get("output", "{}"))

# Don't suppress exceptions
return False
Expand Down
4 changes: 2 additions & 2 deletions src/uipath/runtime/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from uuid import uuid4

from pydantic import BaseModel
from uipath.core.tracing.context import UiPathTraceContext

from .result import UiPathRuntimeResult
from .tracing.context import UiPathTraceContext
from uipath.runtime.result import UiPathRuntimeResult

C = TypeVar("C", bound="UiPathRuntimeContext")

Expand Down
1 change: 1 addition & 0 deletions src/uipath/runtime/events/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class UiPathRuntimeEventType(str, Enum):
RUNTIME_MESSAGE = "runtime_message"
RUNTIME_STATE = "runtime_state"
RUNTIME_ERROR = "runtime_error"
RUNTIME_RESULT = "runtime_result"


class UiPathRuntimeEvent(BaseModel):
Expand Down
Loading