44import logging
55import os
66from abc import ABC , abstractmethod
7- from typing import (
8- AsyncGenerator ,
9- List ,
10- Optional ,
11- Union ,
12- )
13-
14- from pydantic import BaseModel
7+ from typing import AsyncGenerator
158
169from uipath .runtime .context import UiPathRuntimeContext
1710from uipath .runtime .errors import (
2619from uipath .runtime .logging ._interceptor import UiPathRuntimeLogsInterceptor
2720from uipath .runtime .result import UiPathRuntimeResult , UiPathRuntimeStatus
2821from uipath .runtime .schema import (
29- UiPathRuntimeBindingResource ,
30- UiPathRuntimeEntrypoint ,
22+ UiPathRuntimeSchema ,
3123)
3224
3325logger = logging .getLogger (__name__ )
@@ -49,28 +41,8 @@ def __init__(self, context: UiPathRuntimeContext):
4941 """Initialize the runtime with the provided context."""
5042 self .context = context
5143
52- @classmethod
53- def from_context (cls , context : UiPathRuntimeContext ):
54- """Factory method to create a runtime instance from a context.
55-
56- Args:
57- context: The runtime context with configuration
58-
59- Returns:
60- An initialized Runtime instance
61- """
62- runtime = cls (context )
63- return runtime
64-
65- async def get_binding_resources (self ) -> List [UiPathRuntimeBindingResource ]:
66- """Get binding resources for this runtime.
67-
68- Returns: A list of binding resources.
69- """
70- raise NotImplementedError ()
71-
72- async def get_entrypoint (self ) -> UiPathRuntimeEntrypoint :
73- """Get entrypoint for this runtime.
44+ async def get_schema (self ) -> UiPathRuntimeSchema :
45+ """Get schema for this runtime.
7446
7547 Returns: A entrypoint for this runtime.
7648 """
@@ -130,7 +102,7 @@ async def __aenter__(self):
130102 return self
131103
132104 @abstractmethod
133- async def execute (self ) -> Optional [ UiPathRuntimeResult ] :
105+ async def execute (self ) -> UiPathRuntimeResult :
134106 """Execute with the provided context.
135107
136108 Returns:
@@ -143,7 +115,7 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
143115
144116 async def stream (
145117 self ,
146- ) -> AsyncGenerator [Union [ UiPathRuntimeEvent , UiPathRuntimeResult ] , None ]:
118+ ) -> AsyncGenerator [UiPathRuntimeEvent , None ]:
147119 """Stream execution events in real-time.
148120
149121 This is an optional method that runtimes can implement to support streaming.
@@ -233,12 +205,7 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
233205 # Write the execution output to file if requested
234206 if self .context .output_file :
235207 with open (self .context .output_file , "w" ) as f :
236- if isinstance (execution_result .output , BaseModel ):
237- f .write (execution_result .output .model_dump ())
238- else :
239- json .dump (
240- execution_result .output or {}, f , indent = 2 , default = str
241- )
208+ f .write (content .get ("output" , "{}" ))
242209
243210 # Don't suppress exceptions
244211 return False
0 commit comments