diff --git a/pyproject.toml b/pyproject.toml index 6f8d7bced..bf024661e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath" -version = "2.6.25" +version = "2.6.26" 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/_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..b4ac727b1 100644 --- a/src/uipath/_cli/_utils/_eval_set.py +++ b/src/uipath/_cli/_utils/_eval_set.py @@ -1,8 +1,9 @@ import json from pathlib import Path +from typing import Any import click -from pydantic import TypeAdapter, ValidationError +from pydantic import ValidationError from uipath._cli._evals._models._evaluation_set import ( EvaluationItem, @@ -19,6 +20,24 @@ EVAL_SETS_DIRECTORY_NAME = "evaluations/eval-sets" +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 + 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 isinstance(version, (int, float, str)) and float(version) >= 1: + return EvaluationSet.model_validate(data) + return LegacyEvaluationSet.model_validate(data) + + class EvalHelpers: @staticmethod def auto_discover_eval_set() -> str: @@ -100,9 +119,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 ac590d185..fc6d8b446 100644 --- a/uv.lock +++ b/uv.lock @@ -2491,7 +2491,7 @@ wheels = [ [[package]] name = "uipath" -version = "2.6.25" +version = "2.6.26" source = { editable = "." } dependencies = [ { name = "applicationinsights" },