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 packages/uipath/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath"
version = "2.14.42"
version = "2.14.43"
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
17 changes: 16 additions & 1 deletion packages/uipath/src/uipath/_cli/_run_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import time
import uuid
from enum import Enum
from importlib.metadata import version
from importlib.metadata import PackageNotFoundError, version
from typing import Any

from uipath.platform.common import UiPathConfig, resolve_trace_id
Expand Down Expand Up @@ -50,6 +50,16 @@ def classify_run(agent_type: str | None, agent_framework: str | None) -> RunKind
return RunKind.CODED_AGENT


def _integration_version(factory: object | None) -> str | None:
"""Installed version of the package the factory class ships in."""
if factory is None:
return None
try:
return version(type(factory).__module__.split(".")[0])
except PackageNotFoundError:
return None


def _cloud_user_id() -> str | None:
if configured := UiPathConfig.cloud_user_id:
return configured
Expand Down Expand Up @@ -113,13 +123,15 @@ def __init__(
*,
kind: RunKind,
agent_framework: str | None,
integration_version: str | None,
entrypoint: str | None,
execution_source: str | None,
is_conversational: bool,
) -> None:
"""Key the run on its job so a suspend/resume pair stays one run."""
self._kind = kind
self._agent_framework = agent_framework
self._integration_version = integration_version
self._entrypoint = entrypoint
self._execution_source = execution_source
self._is_conversational = is_conversational
Expand All @@ -135,6 +147,7 @@ def start(
entrypoint: str | None,
execution_source: str | None = None,
is_conversational: bool = False,
factory: object | None = None,
) -> "RunTelemetry | None":
"""Emit Start and return a handle, or ``None`` when not reporting.

Expand All @@ -150,6 +163,7 @@ def start(
instance = cls(
kind=kind,
agent_framework=agent_framework,
integration_version=_integration_version(factory),
entrypoint=entrypoint,
execution_source=execution_source,
is_conversational=is_conversational,
Expand Down Expand Up @@ -198,6 +212,7 @@ def _emit(
"AgentRunId": self._run_id,
"AgentType": "Coded",
"AgentFramework": self._agent_framework,
"IntegrationVersion": self._integration_version,
"AgentRunSource": self._execution_source,
"Entrypoint": self._entrypoint,
"IsConversational": self._is_conversational,
Expand Down
1 change: 1 addition & 0 deletions packages/uipath/src/uipath/_cli/cli_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ async def execute_debug_runtime():
entrypoint=entrypoint,
execution_source=ctx.execution_source,
is_conversational=ctx.conversation_id is not None,
factory=factory,
)

governance_bootstrap = await resolve_governance(
Expand Down
1 change: 1 addition & 0 deletions packages/uipath/src/uipath/_cli/cli_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ async def execute() -> None:
entrypoint=resolved_entrypoint,
execution_source=ctx.execution_source,
is_conversational=ctx.conversation_id is not None,
factory=factory,
)

governance_bootstrap = await resolve_governance(
Expand Down
22 changes: 22 additions & 0 deletions packages/uipath/tests/cli/test_run_telemetry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for coded run lifecycle telemetry."""

from importlib.metadata import version
from typing import Any
from unittest.mock import patch

Expand Down Expand Up @@ -71,6 +72,7 @@ def start(
entrypoint=kwargs.pop("entrypoint", "main"),
execution_source=kwargs.pop("execution_source", "runtime"),
is_conversational=kwargs.pop("is_conversational", False),
factory=kwargs.pop("factory", None),
)


Expand Down Expand Up @@ -130,6 +132,26 @@ def test_framework_is_reported_on_every_event(self, emitted):
assert properties.get("AgentFramework") == "llamaindex", name


class TestIntegrationVersion:
def test_version_of_the_factory_package_is_reported_on_every_event(self, emitted):
factory_cls = type("Factory", (), {"__module__": "pluggy._factory"})
handle = start(factory=factory_cls())
assert handle is not None
handle.finished(successful())

assert names(emitted) == ["CodedAgentRun.Start", "CodedAgentRun.End"]
for name, properties in emitted:
assert properties.get("IntegrationVersion") == version("pluggy"), name

def test_factory_outside_an_installed_package_reports_no_version(self, emitted):
factory_cls = type("Factory", (), {"__module__": "main"})

start(factory=factory_cls())

assert names(emitted) == ["CodedAgentRun.Start"]
assert "IntegrationVersion" not in emitted[0][1]


class TestScopeBlock:
def test_scope_is_present_on_start_and_terminal_events(self, emitted):
started().finished(successful())
Expand Down
2 changes: 1 addition & 1 deletion packages/uipath/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading