litellm/tests/rust-python-harness/strategies/trace_parity/models.py
yujonglee ee08c36fc0
refactor(tests): restructure rust python harness around strategy definitions (#39628)
* wip

* refactor(tests): move sdk function tracing into rust python harness

* dead code

* fix: handle harness keyboard interrupts

* refactor(tests): deduplicate rust python harness helpers

* fix(harness): expose validated strategy choices

* wip

* refactor(harness): let strategies own parity reports

* docs(harness): update strategy structure

* refactor(harness): localize strategy report views

* wip

* fix(harness): satisfy mapping runner type checks

* fix(harness): clarify trace parity output

* wip

* fix(harness): clarify unit mapping report

* fix(harness): finalize trace parity contracts

* refactor(harness): structure parity contracts

* feat: derive unit test mapping from traces

* feat(harness): map rstest test families

* feat(ocr): port Azure document intelligence tests

* feat(harness): enforce complete unit mappings

* feat(ocr): add reducto core transforms

* feat(harness): classify host-only unit tests

* fix(ocr): complete Rust provider plumbing

* fix(harness): reuse OCR parity workers
2026-09-03 21:15:01 -07:00

61 lines
1.7 KiB
Python

from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass
from typing import Final, Literal, TypeAlias
from ...shared.parity.recorded_http import RecordedHttpResponse
from ...shared.reporting.models import SdkFunction
from ...shared.tracing.steps import Engine, TraceContract, TraceMapping
TraceMode = Literal["sync", "async"]
TraceFailureSource = Literal["python", "rust", "harness"]
@dataclass(frozen=True, slots=True)
class RouteFixture:
kwargs: dict[str, object]
provider_responses: tuple[RecordedHttpResponse, ...]
@dataclass(frozen=True, slots=True)
class RouteSpec:
route: SdkFunction
python_entrypoints: tuple[str, str]
rust_entrypoints: tuple[str, str]
fixture: Callable[[Engine, str], RouteFixture]
@dataclass(frozen=True, slots=True)
class GatewayRouteSpec:
route: SdkFunction
TraceRouteSpec: TypeAlias = RouteSpec | GatewayRouteSpec
@dataclass(frozen=True, slots=True)
class TraceScenario:
name: str
fixture: Callable[[Engine, str], RouteFixture]
mappings: tuple[TraceMapping, ...]
modes: tuple[TraceMode, ...] = ("sync", "async")
contract: TraceContract = TraceContract()
sync_mappings: tuple[TraceMapping, ...] | None = None
async_mappings: tuple[TraceMapping, ...] | None = None
def mappings_for(self, mode: TraceMode) -> tuple[TraceMapping, ...]:
selected: Final = self.async_mappings if mode == "async" else self.sync_mappings
return self.mappings if selected is None else selected
@dataclass(frozen=True, slots=True)
class TraceSuite:
route: TraceRouteSpec
scenarios: tuple[TraceScenario, ...]
@dataclass(frozen=True, slots=True)
class TraceExecutionFailure:
engine: TraceFailureSource
message: str