From fd99ee229a68279b0eee5af95f04dda919b739ab Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Fri, 30 Jan 2026 13:46:36 +0200 Subject: [PATCH 1/2] fix(evals): change eval set discrimination strategy --- pyproject.toml | 1 + .../_cli/_evals/_models/_evaluation_set.py | 11 --------- src/uipath/_cli/_utils/_eval_set.py | 24 +++++++++++++++---- uv.lock | 2 ++ 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ff52e089a..d1fcb85b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ dependencies = [ "coverage>=7.8.2", "mermaid-builder==0.0.3", "applicationinsights>=0.11.10", + "pydantic>=2.12.5", ] classifiers = [ "Intended Audience :: Developers", diff --git a/src/uipath/_cli/_evals/_models/_evaluation_set.py b/src/uipath/_cli/_evals/_models/_evaluation_set.py index 714a88034..bf1a08d89 100644 --- a/src/uipath/_cli/_evals/_models/_evaluation_set.py +++ b/src/uipath/_cli/_evals/_models/_evaluation_set.py @@ -186,14 +186,3 @@ class EvaluationStatus(IntEnum): IN_PROGRESS = 1 COMPLETED = 2 FAILED = 3 - - -def _discriminate_eval_set( - v: Any, -) -> Literal["evaluation_set", "legacy_evaluation_set"]: - """Discriminator function that returns a tag based on version field.""" - if isinstance(v, dict): - version = v.get("version") - if version == "1.0": - return "evaluation_set" - return "legacy_evaluation_set" diff --git a/src/uipath/_cli/_utils/_eval_set.py b/src/uipath/_cli/_utils/_eval_set.py index a36e96f6e..833f6159a 100644 --- a/src/uipath/_cli/_utils/_eval_set.py +++ b/src/uipath/_cli/_utils/_eval_set.py @@ -2,7 +2,7 @@ from pathlib import Path import click -from pydantic import TypeAdapter, ValidationError +from pydantic import ValidationError from uipath._cli._evals._models._evaluation_set import ( EvaluationItem, @@ -19,6 +19,24 @@ EVAL_SETS_DIRECTORY_NAME = "evaluations/eval-sets" +def discriminate_eval_set(data: dict) -> EvaluationSet | LegacyEvaluationSet: + """Discriminate and parse evaluation set based on version field. + + Uses explicit version checking instead of Pydantic's smart union matching + to avoid incorrect type selection when both types have matching fields. + + Args: + data: Dictionary containing evaluation set data + + Returns: + Either EvaluationSet (for version 1.0) or LegacyEvaluationSet + """ + version = data.get("version") + if version == "1.0": + return EvaluationSet.model_validate(data) + return LegacyEvaluationSet.model_validate(data) + + class EvalHelpers: @staticmethod def auto_discover_eval_set() -> str: @@ -100,9 +118,7 @@ def load_eval_set( ) from e try: - eval_set: EvaluationSet | LegacyEvaluationSet = TypeAdapter( - EvaluationSet | LegacyEvaluationSet - ).validate_python(data) + eval_set = discriminate_eval_set(data) if isinstance(eval_set, LegacyEvaluationSet): def migrate_evaluation_item( diff --git a/uv.lock b/uv.lock index b3289b67b..a6a9ef718 100644 --- a/uv.lock +++ b/uv.lock @@ -2501,6 +2501,7 @@ dependencies = [ { name = "mermaid-builder" }, { name = "mockito" }, { name = "pathlib" }, + { name = "pydantic" }, { name = "pydantic-function-models" }, { name = "pyjwt" }, { name = "pysignalr" }, @@ -2551,6 +2552,7 @@ requires-dist = [ { name = "mermaid-builder", specifier = "==0.0.3" }, { name = "mockito", specifier = ">=1.5.4" }, { name = "pathlib", specifier = ">=1.0.1" }, + { name = "pydantic", specifier = ">=2.12.5" }, { name = "pydantic-function-models", specifier = ">=0.1.11" }, { name = "pyjwt", specifier = ">=2.10.1" }, { name = "pysignalr", specifier = "==1.3.0" }, From 72ffc1ede312a4fa0383416362314e290dd9246f Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Fri, 30 Jan 2026 13:49:42 +0200 Subject: [PATCH 2/2] fix: typing issue and version bump --- pyproject.toml | 2 +- src/uipath/_cli/_utils/_eval_set.py | 3 ++- uv.lock | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d1fcb85b4..a119c9d94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath" -version = "2.6.22" +version = "2.6.23" 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" diff --git a/src/uipath/_cli/_utils/_eval_set.py b/src/uipath/_cli/_utils/_eval_set.py index 833f6159a..31e48d12b 100644 --- a/src/uipath/_cli/_utils/_eval_set.py +++ b/src/uipath/_cli/_utils/_eval_set.py @@ -1,5 +1,6 @@ import json from pathlib import Path +from typing import Any import click from pydantic import ValidationError @@ -19,7 +20,7 @@ EVAL_SETS_DIRECTORY_NAME = "evaluations/eval-sets" -def discriminate_eval_set(data: dict) -> EvaluationSet | LegacyEvaluationSet: +def discriminate_eval_set(data: dict[str, Any]) -> EvaluationSet | LegacyEvaluationSet: """Discriminate and parse evaluation set based on version field. Uses explicit version checking instead of Pydantic's smart union matching diff --git a/uv.lock b/uv.lock index a6a9ef718..48e9b6498 100644 --- a/uv.lock +++ b/uv.lock @@ -2491,7 +2491,7 @@ wheels = [ [[package]] name = "uipath" -version = "2.6.22" +version = "2.6.23" source = { editable = "." } dependencies = [ { name = "applicationinsights" },