|
1 | 1 | # UiPath Runtime |
2 | 2 |
|
| 3 | +[](https://pypi.org/project/uipath-runtime/) |
| 4 | +[](https://pypi.org/project/uipath-runtime/) |
| 5 | + |
3 | 6 | Core runtime abstractions and contracts for the UiPath Python SDK. |
4 | 7 |
|
5 | 8 | ## Overview |
@@ -36,7 +39,7 @@ class MyCustomRuntime(UiPathBaseRuntime): |
36 | 39 |
|
37 | 40 | async def stream( |
38 | 41 | self, |
39 | | - ) -> AsyncGenerator[Union[UiPathRuntimeEvent, UiPathRuntimeResult], None]: |
| 42 | + ) -> AsyncGenerator[UiPathRuntimeEvent, None]: |
40 | 43 | # Stream events during execution for real-time monitoring |
41 | 44 | yield UiPathRuntimeStateEvent( |
42 | 45 | payload={"status": "starting"}, |
@@ -69,30 +72,30 @@ class MyCustomRuntime(UiPathBaseRuntime): |
69 | 72 | The factory pattern handles runtime instantiation, instrumentation, and tracing: |
70 | 73 |
|
71 | 74 | ```python |
72 | | -from uipath.runtime import UiPathRuntimeFactory, UiPathRuntimeContext |
| 75 | +from uipath.runtime import UiPathRuntimeFactory, UiPathRuntimeContext, UiPathRuntimeExecutor |
73 | 76 |
|
74 | | -factory = UiPathRuntimeFactory( |
75 | | - MyCustomRuntime, |
76 | | - UiPathRuntimeContext, |
77 | | -) |
| 77 | +factory = UiPathRuntimeFactory(MyCustomRuntime) |
| 78 | + |
| 79 | +executor = UiPathRuntimeExecutor() |
78 | 80 |
|
79 | 81 | # Add OpenTelemetry instrumentation |
80 | | -factory.add_instrumentor(MyInstrumentor, get_current_span) |
| 82 | +executor.add_instrumentor(MyInstrumentor, get_current_span) |
81 | 83 |
|
82 | 84 | # Add span exporters for tracing |
83 | | -factory.add_span_exporter(JsonLinesFileExporter("trace.jsonl")) |
| 85 | +executor.add_span_exporter(JsonLinesFileExporter("trace.jsonl")) |
84 | 86 |
|
85 | 87 | # Execute |
86 | 88 | context = UiPathRuntimeContext(entrypoint="main.py", input='{"query": "hello"}') |
87 | | -result = await factory.execute(context) |
| 89 | +async with factory.from_context(context): |
| 90 | + result = await executor.execute(runtime) |
88 | 91 | ``` |
89 | 92 |
|
90 | 93 | ### Event Streaming |
91 | 94 |
|
92 | 95 | Runtimes can stream events during execution for real-time monitoring: |
93 | 96 |
|
94 | 97 | ```python |
95 | | -async for event in factory.stream(context): |
| 98 | +async for event in executor.stream(runtime): |
96 | 99 | if isinstance(event, UiPathRuntimeStateEvent): |
97 | 100 | print(f"State update: {event.payload}") |
98 | 101 | elif isinstance(event, UiPathRuntimeMessageEvent): |
|
0 commit comments