diff --git a/src/uipath/runtime/base.py b/src/uipath/runtime/base.py index 5792c61..3653f3d 100644 --- a/src/uipath/runtime/base.py +++ b/src/uipath/runtime/base.py @@ -44,7 +44,7 @@ def __init__(self, context: UiPathRuntimeContext): async def get_schema(self) -> UiPathRuntimeSchema: """Get schema for this runtime. - Returns: A entrypoint for this runtime. + Returns: The runtime's schema (entrypoint type, input/output json schema). """ raise NotImplementedError() diff --git a/src/uipath/runtime/factory.py b/src/uipath/runtime/factory.py index 248dbde..e0d8697 100644 --- a/src/uipath/runtime/factory.py +++ b/src/uipath/runtime/factory.py @@ -127,7 +127,6 @@ async def stream( async def execute_in_root_span( self, runtime: UiPathBaseRuntime, - execution_id: Optional[str] = None, root_span: str = "root", attributes: Optional[dict[str, str]] = None, ) -> UiPathRuntimeResult: @@ -135,8 +134,8 @@ async def execute_in_root_span( try: tracer: Tracer = trace.get_tracer("uipath-runtime") span_attributes = {} - if execution_id: - span_attributes["execution.id"] = execution_id + if runtime.context.execution_id: + span_attributes["execution.id"] = runtime.context.execution_id if attributes: span_attributes.update(attributes) @@ -151,7 +150,6 @@ async def execute_in_root_span( async def stream_in_root_span( self, runtime: UiPathBaseRuntime, - execution_id: Optional[str] = None, root_span: str = "root", attributes: Optional[dict[str, str]] = None, ) -> AsyncGenerator[UiPathRuntimeEvent, None]: @@ -172,8 +170,8 @@ async def stream_in_root_span( try: tracer: Tracer = trace.get_tracer("uipath-runtime") span_attributes = {} - if execution_id: - span_attributes["execution.id"] = execution_id + if runtime.context.execution_id: + span_attributes["execution.id"] = runtime.context.execution_id if attributes: span_attributes.update(attributes) diff --git a/tests/test_executor.py b/tests/test_executor.py index 85cf797..2eaf1aa 100644 --- a/tests/test_executor.py +++ b/tests/test_executor.py @@ -93,24 +93,24 @@ async def test_multiple_factories_same_executor(): executor = UiPathRuntimeExecutor() # Execute runtime A - runtime_a = factory_a.from_context(UiPathRuntimeContext()) + runtime_a = factory_a.from_context(UiPathRuntimeContext(execution_id="exec-a")) async with runtime_a: result_a = await executor.execute_in_root_span( - runtime_a, execution_id="exec-a", root_span="runtime-a-span" + runtime_a, root_span="runtime-a-span" ) # Execute runtime B - runtime_b = factory_b.from_context(UiPathRuntimeContext()) + runtime_b = factory_b.from_context(UiPathRuntimeContext(execution_id="exec-b")) async with runtime_b: result_b = await executor.execute_in_root_span( - runtime_b, execution_id="exec-b", root_span="runtime-b-span" + runtime_b, root_span="runtime-b-span" ) # Execute runtime C with custom spans - runtime_c = factory_c.from_context(UiPathRuntimeContext()) + runtime_c = factory_c.from_context(UiPathRuntimeContext(execution_id="exec-c")) async with runtime_c: result_c = await executor.execute_in_root_span( - runtime_c, execution_id="exec-c", root_span="runtime-c-span" + runtime_c, root_span="runtime-c-span" ) # Verify results