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 src/uipath/runtime/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
10 changes: 4 additions & 6 deletions src/uipath/runtime/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,15 @@ 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:
"""Execute runtime with context in a 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)

Expand All @@ -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]:
Expand All @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions tests/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down