neens-eval 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
neens_eval/__init__.py ADDED
@@ -0,0 +1,115 @@
1
+ """Neens pre-prod evaluation runner — the thin CI glue for the PULL model.
2
+
3
+ In the pull model, YOUR CI harness drives YOUR candidate agent against a golden dataset's
4
+ frozen prompts and emits OpenTelemetry traces tagged so Neens can correlate + score them.
5
+ This package is the one-liner that makes that a CI step: for each frozen prompt it injects the
6
+ Neens correlation attributes (via ``OTEL_RESOURCE_ATTRIBUTES`` + plain env vars) and executes
7
+ YOUR agent command, then starts the run, polls to a terminal state, fetches the gate, and
8
+ returns an exit code CI can gate on (0 = gate passed).
9
+
10
+ It is deliberately NOT a universal agent-caller: it subprocesses a user-supplied command and
11
+ relies on that agent already being OpenTelemetry-instrumented and pointed at the Neens OTLP
12
+ receiver. Neens is the observability tool — the agent emits the traces.
13
+
14
+ Zero runtime dependencies (stdlib ``urllib``/``json`` only) so ``pip install ./sdk`` needs no
15
+ network and adds nothing to a CI image beyond Python itself.
16
+ """
17
+ from __future__ import annotations
18
+
19
+ from .client import NeensEvalClient, NeensEvalError
20
+ from .correlation import build_item_env
21
+ from .legacy_env import (
22
+ LEGACY_ENV_IGNORE_VAR,
23
+ SDK_ENV_VARS,
24
+ LegacyEnvVarError,
25
+ check_legacy_env,
26
+ scan_legacy_env,
27
+ )
28
+ from .gate import (
29
+ GateEvaluation,
30
+ GatePolicy,
31
+ GatePolicyError,
32
+ RuleResult,
33
+ evaluate,
34
+ )
35
+ from .runner import (
36
+ ItemResult,
37
+ RunOutcome,
38
+ legacy_correlation_notice,
39
+ run_eval,
40
+ run_push_eval,
41
+ )
42
+ from .sweep import (
43
+ SWEEP_TERMINAL_STATUSES,
44
+ VERDICT_NONE_CLEAR,
45
+ VERDICT_UNAVAILABLE,
46
+ VERDICT_WINNER,
47
+ SweepArgError,
48
+ SweepOutcome,
49
+ decide_comparison_exit_code,
50
+ decide_exit_code,
51
+ decide_sweep,
52
+ get_sweep,
53
+ parse_arm,
54
+ parse_arms,
55
+ preview_sweep,
56
+ render_comparison,
57
+ start_sweep,
58
+ )
59
+
60
+ __all__ = [
61
+ "NeensEvalClient",
62
+ "NeensEvalError",
63
+ "build_item_env",
64
+ "ItemResult",
65
+ "RunOutcome",
66
+ "legacy_correlation_notice",
67
+ "run_eval",
68
+ "run_push_eval",
69
+ # Multi-model sweeps (issue #449)
70
+ "SweepArgError",
71
+ "SweepOutcome",
72
+ "SWEEP_TERMINAL_STATUSES",
73
+ "decide_exit_code",
74
+ "get_sweep",
75
+ "parse_arm",
76
+ "parse_arms",
77
+ "preview_sweep",
78
+ "start_sweep",
79
+ # N-way comparison verdict (issue #450) — the SDK RENDERS the server's ranking, never its own
80
+ "VERDICT_WINNER",
81
+ "VERDICT_NONE_CLEAR",
82
+ "VERDICT_UNAVAILABLE",
83
+ "decide_comparison_exit_code",
84
+ "decide_sweep",
85
+ "render_comparison",
86
+ # Gate-as-code policy layer
87
+ "GatePolicy",
88
+ "GatePolicyError",
89
+ "GateEvaluation",
90
+ "RuleResult",
91
+ "evaluate",
92
+ # Legacy-configuration guard (issue #470). Exported so a wrapper that embeds the SDK can run
93
+ # the same check; importing this package never runs it (only the CLI entry point does).
94
+ # Kept name-for-name with `sdk-ts/src/index.ts` — a wrapper that reads the hatch name off the
95
+ # package root must work in both.
96
+ "LEGACY_ENV_IGNORE_VAR",
97
+ "SDK_ENV_VARS",
98
+ "LegacyEnvVarError",
99
+ "check_legacy_env",
100
+ "scan_legacy_env",
101
+ # OTel correlation attribute names — the wire contract with the backend
102
+ # (mirrors ``core/preprod.py``; duplicated here so the SDK stays self-contained).
103
+ "EVAL_RUN_ID_ATTR",
104
+ "DATASET_ITEM_ID_ATTR",
105
+ "VERSION_LABEL_ATTR",
106
+ ]
107
+
108
+ # The OTel attribute NAMES Neens correlates on. These MUST match ``core/preprod.py`` in the
109
+ # backend — they are the wire contract. Kept as literals (not an import) so the SDK is a
110
+ # free-standing, installable package with no dependency on the Neens backend source tree.
111
+ EVAL_RUN_ID_ATTR = "neens.eval_run_id"
112
+ DATASET_ITEM_ID_ATTR = "neens.dataset_item_id"
113
+ VERSION_LABEL_ATTR = "neens.version_label"
114
+
115
+ __version__ = "0.3.0"