trybench-sdk 0.1.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.
- bench_sdk/__init__.py +6 -0
- bench_sdk/client.py +290 -0
- bench_sdk/evaluation.py +258 -0
- bench_sdk/py.typed +0 -0
- trybench_sdk-0.1.0.dist-info/METADATA +155 -0
- trybench_sdk-0.1.0.dist-info/RECORD +9 -0
- trybench_sdk-0.1.0.dist-info/WHEEL +5 -0
- trybench_sdk-0.1.0.dist-info/licenses/LICENSE +201 -0
- trybench_sdk-0.1.0.dist-info/top_level.txt +1 -0
bench_sdk/__init__.py
ADDED
bench_sdk/client.py
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import contextvars
|
|
4
|
+
import ipaddress
|
|
5
|
+
import json
|
|
6
|
+
import math
|
|
7
|
+
import random
|
|
8
|
+
import re
|
|
9
|
+
import secrets
|
|
10
|
+
import threading
|
|
11
|
+
import time
|
|
12
|
+
import urllib.error
|
|
13
|
+
import urllib.request
|
|
14
|
+
from contextlib import contextmanager
|
|
15
|
+
from datetime import datetime, timezone
|
|
16
|
+
from typing import Any, Callable, Iterator
|
|
17
|
+
from urllib.parse import urlsplit
|
|
18
|
+
|
|
19
|
+
_SENSITIVE = re.compile(r"authorization|cookie|password|secret|token|api.?key|email|phone|address|user.?id|(?:first|last|full).?name|card.?number", re.I)
|
|
20
|
+
_METADATA = re.compile(r"^(code\.(filepath|lineno)|gen_ai\.(system|provider\.name|operation\.name|request\.model|response\.model|tool\.(name|type|call\.id)|usage\.(input_tokens|output_tokens))|bench\.(component_id|environment|prompt_version|duration_ms|cost\.(usd|source|pricing_version)))$")
|
|
21
|
+
_SECRETS = re.compile(r"(?:bench_sk_|apikey_|sk-)[a-zA-Z0-9_-]{8,}|Bearer\s+[a-zA-Z0-9._~+/-]+", re.I)
|
|
22
|
+
_EMAIL = re.compile(r"(?<![a-z0-9.!#$%&'*+/=?^_`{|}~-])[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9-]+)+", re.I)
|
|
23
|
+
_PHONE = re.compile(r"\+\d[\d ()-]{8,}\d")
|
|
24
|
+
_IP = re.compile(r"\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b")
|
|
25
|
+
_CARD = re.compile(r"\b(?:[0-9]{4}(?:[ -][0-9]{4}){3}[ -][0-9]{3}|[0-9]{4}(?:[ -][0-9]{4}){3}|[0-9]{4}[ -][0-9]{6}[ -][0-9]{5}|[0-9]{13,19})\b")
|
|
26
|
+
_KINDS = {"LLM", "TOOL", "CHAIN", "RETRIEVER", "AGENT", "EMBEDDING"}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _ip(match: re.Match) -> str:
|
|
30
|
+
try:
|
|
31
|
+
ipaddress.IPv4Address(match[0])
|
|
32
|
+
return "[REDACTED_IP]"
|
|
33
|
+
except ValueError:
|
|
34
|
+
return match[0]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _card(match: re.Match) -> str:
|
|
38
|
+
digits = "".join(c for c in match[0] if c.isdigit())
|
|
39
|
+
candidates = [digits]
|
|
40
|
+
if len(digits) == 19 and len(match[0]) > 19:
|
|
41
|
+
candidates.append(digits[:16])
|
|
42
|
+
for candidate in candidates:
|
|
43
|
+
total = sum(n if i % 2 == 0 else n * 2 - (9 if n > 4 else 0) for i, n in enumerate(map(int, reversed(candidate))))
|
|
44
|
+
if total > 0 and total % 10 == 0:
|
|
45
|
+
return "[REDACTED_PAYMENT_NUMBER]"
|
|
46
|
+
return match[0]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _redact(value: Any, depth: int = 0, max_items: int = 100) -> Any:
|
|
50
|
+
if depth > 12:
|
|
51
|
+
return "[DEPTH_LIMIT]"
|
|
52
|
+
if isinstance(value, str):
|
|
53
|
+
if len(value) > 16000:
|
|
54
|
+
return "[CONTENT_LIMIT]"
|
|
55
|
+
# Encoded JSON must receive the same field filtering as an object.
|
|
56
|
+
if value.lstrip().startswith(("{", "[")):
|
|
57
|
+
try:
|
|
58
|
+
return json.dumps(_redact(json.loads(value), depth + 1, max_items), ensure_ascii=False)[:16000]
|
|
59
|
+
except (ValueError, RecursionError):
|
|
60
|
+
pass
|
|
61
|
+
value = _SECRETS.sub("[REDACTED_SECRET]", value)
|
|
62
|
+
value = _EMAIL.sub("[REDACTED_EMAIL]", value)
|
|
63
|
+
value = _CARD.sub(_card, _IP.sub(_ip, value))
|
|
64
|
+
return _PHONE.sub("[REDACTED_PHONE]", value)[:16000]
|
|
65
|
+
if isinstance(value, dict):
|
|
66
|
+
return {_redact(str(k), depth + 1, max_items): "[REDACTED]" if _SENSITIVE.search(str(k)) and not (_METADATA.fullmatch(str(k)) and str(k).startswith("gen_ai.usage.") and isinstance(v, (int, float))) else _redact(v, depth + 1, max_items) for k, v in list(value.items())[:max_items]}
|
|
67
|
+
if isinstance(value, (list, tuple)):
|
|
68
|
+
return [_redact(v, depth + 1, max_items) for v in value[:max_items]]
|
|
69
|
+
if not isinstance(value, bool) and (isinstance(value, int) or (isinstance(value, float) and math.isfinite(value) and value.is_integer())):
|
|
70
|
+
normalized = str(int(value))
|
|
71
|
+
if 13 <= len(normalized) <= 19:
|
|
72
|
+
filtered = _CARD.sub(_card, normalized)
|
|
73
|
+
return filtered if filtered != normalized else value
|
|
74
|
+
if value is None or isinstance(value, (bool, int)):
|
|
75
|
+
return value
|
|
76
|
+
if isinstance(value, float) and math.isfinite(value):
|
|
77
|
+
return value
|
|
78
|
+
return None
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _now() -> str:
|
|
82
|
+
return datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class _NoRedirect(urllib.request.HTTPRedirectHandler):
|
|
86
|
+
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
|
87
|
+
return None
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class Span:
|
|
91
|
+
"""Use set_output for a request's final value; model errors are not captured."""
|
|
92
|
+
def __init__(self, name: str, kind: str, input: Any, attributes: dict | None, model: str | None, component_id: int | None):
|
|
93
|
+
self.name, self.kind, self.input = name, kind, input
|
|
94
|
+
self.attributes, self.model, self.component_id = attributes or {}, model, component_id
|
|
95
|
+
self.output: Any = None
|
|
96
|
+
|
|
97
|
+
def set_output(self, value: Any) -> None:
|
|
98
|
+
self.output = value
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class Bench:
|
|
102
|
+
"""Thread-safe, bounded telemetry with explicit flush at lifecycle boundaries.
|
|
103
|
+
|
|
104
|
+
trace() is a context manager usable around sync code and across await points.
|
|
105
|
+
Async tasks inherit their parent's context without sharing sibling span IDs.
|
|
106
|
+
"""
|
|
107
|
+
def __init__(self, *, api_key: str, repository: str, branch: str, system_name: str | None = None,
|
|
108
|
+
environment: str | None = None, endpoint: str = "https://api.trybench.ai",
|
|
109
|
+
capture_content: bool = False, sample_rate: float = 1, max_queue_size: int = 200,
|
|
110
|
+
timeout: float = 5, redact: Callable[[Any], Any] | None = None,
|
|
111
|
+
on_error: Callable[[str], None] | None = None,
|
|
112
|
+
transport: Callable[[str, dict[str, str], bytes, float], int] | None = None):
|
|
113
|
+
if not api_key.startswith("bench_sk_") or not repository or not branch:
|
|
114
|
+
raise ValueError("A Bench key, repository and branch are required.")
|
|
115
|
+
if not re.fullmatch(r"[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+", repository) or any(len(v) > 200 or re.search(r"[\x00-\x1f\x7f]", v) or _redact(v) != v for v in (repository, branch)):
|
|
116
|
+
raise ValueError("Use static repository and branch names without personal data or secrets.")
|
|
117
|
+
parsed = urlsplit(endpoint)
|
|
118
|
+
if not parsed.hostname or parsed.username or parsed.password or parsed.query or parsed.fragment or not (parsed.scheme == "https" or (parsed.scheme == "http" and parsed.hostname in ("localhost", "127.0.0.1", "::1"))):
|
|
119
|
+
raise ValueError("Use HTTPS or a loopback HTTP endpoint.")
|
|
120
|
+
if environment is not None and not re.fullmatch(r"[A-Za-z0-9_.-]{1,64}", environment):
|
|
121
|
+
raise ValueError("Use a short environment name.")
|
|
122
|
+
if not 0 <= sample_rate <= 1 or type(max_queue_size) is not int or not 1 <= max_queue_size <= 2000 or not 0.1 <= timeout <= 30:
|
|
123
|
+
raise ValueError("Sampling, queue size or timeout is out of range.")
|
|
124
|
+
self._key, self._repository, self._branch = api_key, repository, branch
|
|
125
|
+
self._system, self._environment = _redact(system_name or repository.rsplit("/", 1)[-1]), environment
|
|
126
|
+
self._endpoint, self._capture, self._sample = endpoint.rstrip("/") + "/api/traces", capture_content, sample_rate
|
|
127
|
+
self._max, self._timeout, self._redactor, self._on_error = max_queue_size, timeout, redact, on_error
|
|
128
|
+
self._transport = transport or self._http
|
|
129
|
+
self._context: contextvars.ContextVar = contextvars.ContextVar("bench_span", default=None)
|
|
130
|
+
self._evaluation: contextvars.ContextVar = contextvars.ContextVar("bench_evaluation", default=None)
|
|
131
|
+
self._lock, self._flush_lock = threading.Lock(), threading.Lock()
|
|
132
|
+
self._queue: list[dict] = []
|
|
133
|
+
self._closed, self._dropped = False, 0
|
|
134
|
+
|
|
135
|
+
def _safe(self, value: Any) -> Any:
|
|
136
|
+
return _redact(self._redactor(value) if self._redactor else value)
|
|
137
|
+
|
|
138
|
+
def _report(self, message: str) -> None:
|
|
139
|
+
if self._on_error:
|
|
140
|
+
try:
|
|
141
|
+
self._on_error(message)
|
|
142
|
+
except Exception:
|
|
143
|
+
pass
|
|
144
|
+
|
|
145
|
+
@contextmanager
|
|
146
|
+
def trace(self, name: str, *, kind: str = "LLM", input: Any = None, model: str | None = None,
|
|
147
|
+
attributes: dict | None = None, component_id: int | None = None) -> Iterator[Span]:
|
|
148
|
+
if kind not in _KINDS:
|
|
149
|
+
raise ValueError("Invalid span kind.")
|
|
150
|
+
evaluation = self._evaluation.get()
|
|
151
|
+
if evaluation is not None:
|
|
152
|
+
evaluation.start()
|
|
153
|
+
parent = self._context.get()
|
|
154
|
+
trace_id = parent[0] if parent else secrets.token_hex(16)
|
|
155
|
+
sampled = evaluation is not None or (parent[2] if parent else random.random() < self._sample)
|
|
156
|
+
span_id, started, duration_start = secrets.token_hex(8), _now(), time.monotonic()
|
|
157
|
+
token = self._context.set((trace_id, span_id, sampled))
|
|
158
|
+
span, status = Span(name, kind, input, attributes, model, component_id), "error"
|
|
159
|
+
try:
|
|
160
|
+
yield span
|
|
161
|
+
status = "ok"
|
|
162
|
+
finally:
|
|
163
|
+
self._context.reset(token)
|
|
164
|
+
if sampled:
|
|
165
|
+
self._record(span, trace_id, span_id, parent[1] if parent else None, started, status, evaluation, (time.monotonic() - duration_start) * 1000)
|
|
166
|
+
|
|
167
|
+
def _record(self, span: Span, trace_id: str, span_id: str, parent: str | None, started: str, status: str, evaluation=None, duration_ms: float = 0) -> None:
|
|
168
|
+
row = None
|
|
169
|
+
try:
|
|
170
|
+
attrs = {k: v for k, v in span.attributes.items() if self._capture or _METADATA.fullmatch(k)}
|
|
171
|
+
attrs["bench.duration_ms"] = duration_ms
|
|
172
|
+
if self._environment:
|
|
173
|
+
attrs["bench.environment"] = self._environment
|
|
174
|
+
if span.component_id is not None:
|
|
175
|
+
attrs["bench.component_id"] = span.component_id
|
|
176
|
+
row = {"span_id": span_id, "name": str(self._safe(span.name))[:200], "kind": span.kind,
|
|
177
|
+
"started_at": started, "ended_at": _now(), "status": status, "attributes": self._safe(attrs)}
|
|
178
|
+
if parent:
|
|
179
|
+
row["parent_span_id"] = parent
|
|
180
|
+
if span.model:
|
|
181
|
+
row["model_name"] = str(self._safe(span.model))[:200]
|
|
182
|
+
if self._capture or evaluation is not None:
|
|
183
|
+
row["input_value"] = json.dumps(self._safe(span.input), ensure_ascii=False, allow_nan=False)
|
|
184
|
+
row["output_value"] = json.dumps(self._safe(span.output), ensure_ascii=False, allow_nan=False)
|
|
185
|
+
trace = {"trace_id": trace_id, "source": "bench_sdk", "spans": [row]}
|
|
186
|
+
if len(json.dumps(trace).encode()) > 200000:
|
|
187
|
+
raise ValueError("Trace too large")
|
|
188
|
+
if evaluation is not None:
|
|
189
|
+
evaluation.finish(row)
|
|
190
|
+
return
|
|
191
|
+
with self._lock:
|
|
192
|
+
if self._closed or len(self._queue) >= self._max:
|
|
193
|
+
self._dropped += 1
|
|
194
|
+
else:
|
|
195
|
+
self._queue.append(trace)
|
|
196
|
+
except Exception:
|
|
197
|
+
if evaluation is not None:
|
|
198
|
+
evaluation.finish(None)
|
|
199
|
+
return
|
|
200
|
+
with self._lock:
|
|
201
|
+
self._dropped += 1
|
|
202
|
+
self._report("Trace could not be captured; dropped.")
|
|
203
|
+
|
|
204
|
+
async def evaluate_system(self, **options) -> dict:
|
|
205
|
+
"""Run application cases locally. Returns a redacted report; no implicit upload."""
|
|
206
|
+
from .evaluation import evaluate
|
|
207
|
+
return await evaluate(self, **options)
|
|
208
|
+
|
|
209
|
+
async def simulate_system(self, **options) -> dict:
|
|
210
|
+
"""Replay customer turns against a fresh app session and independently observed state."""
|
|
211
|
+
from .evaluation import simulate
|
|
212
|
+
return await simulate(self, **options)
|
|
213
|
+
|
|
214
|
+
async def publish_system_evaluation(self, system_id: int, report: dict) -> None:
|
|
215
|
+
"""Explicitly save a redacted report. Raises on failure; spends no evaluations."""
|
|
216
|
+
import asyncio
|
|
217
|
+
if type(system_id) is not int or not 1 <= system_id <= 9007199254740991:
|
|
218
|
+
raise ValueError("Select a system.")
|
|
219
|
+
raw = self._redactor(report) if self._redactor else report
|
|
220
|
+
body = json.dumps(_redact(raw, max_items=300), allow_nan=False).encode()
|
|
221
|
+
if len(body) > 500000:
|
|
222
|
+
raise ValueError("Runtime report exceeds 500 KB. Retain it locally or split the suite.")
|
|
223
|
+
url = self._endpoint.removesuffix("/api/traces") + f"/api/ai-systems/{system_id}/runtime-evaluations"
|
|
224
|
+
status = await asyncio.to_thread(self._transport, url, {"Content-Type": "application/json", "Authorization": "Bearer " + self._key}, body, self._timeout)
|
|
225
|
+
if not 200 <= status < 300:
|
|
226
|
+
raise RuntimeError(f"Could not save application results (HTTP {status}). Local results remain available.")
|
|
227
|
+
|
|
228
|
+
@staticmethod
|
|
229
|
+
def _http(url: str, headers: dict[str, str], body: bytes, timeout: float) -> int:
|
|
230
|
+
request = urllib.request.Request(url, body, headers, method="POST")
|
|
231
|
+
try:
|
|
232
|
+
with urllib.request.build_opener(_NoRedirect()).open(request, timeout=timeout) as response:
|
|
233
|
+
return response.status
|
|
234
|
+
except urllib.error.HTTPError as error:
|
|
235
|
+
status = error.code
|
|
236
|
+
error.close()
|
|
237
|
+
return status
|
|
238
|
+
|
|
239
|
+
@property
|
|
240
|
+
def stats(self) -> dict[str, int]:
|
|
241
|
+
with self._lock:
|
|
242
|
+
return {"queued": len(self._queue), "dropped": self._dropped}
|
|
243
|
+
|
|
244
|
+
def flush(self) -> None:
|
|
245
|
+
"""Bounded network work. Delivery failures never raise into application code."""
|
|
246
|
+
with self._flush_lock:
|
|
247
|
+
with self._lock:
|
|
248
|
+
pending, self._queue = self._queue, []
|
|
249
|
+
while pending:
|
|
250
|
+
batch, size = [], 0
|
|
251
|
+
while pending and len(batch) < 20:
|
|
252
|
+
next_size = len(json.dumps(pending[0]).encode())
|
|
253
|
+
if size + next_size > 800000:
|
|
254
|
+
break
|
|
255
|
+
size += next_size
|
|
256
|
+
batch.append(pending.pop(0))
|
|
257
|
+
body = json.dumps({"repo_full_name": self._repository, "branch": self._branch, "system_name": self._system, "capture_content": self._capture, "traces": batch}).encode()
|
|
258
|
+
delivered = False
|
|
259
|
+
for attempt in range(2):
|
|
260
|
+
try:
|
|
261
|
+
status = self._transport(self._endpoint, {"Content-Type": "application/json", "Authorization": "Bearer " + self._key}, body, self._timeout)
|
|
262
|
+
if 200 <= status < 300:
|
|
263
|
+
delivered = True
|
|
264
|
+
break
|
|
265
|
+
if status != 429 and status < 500:
|
|
266
|
+
break
|
|
267
|
+
except Exception:
|
|
268
|
+
pass
|
|
269
|
+
if attempt == 0:
|
|
270
|
+
time.sleep(0.25)
|
|
271
|
+
if not delivered:
|
|
272
|
+
with self._lock:
|
|
273
|
+
self._dropped += len(batch)
|
|
274
|
+
self._report("Bench trace delivery failed; batch dropped.")
|
|
275
|
+
|
|
276
|
+
async def aflush(self) -> None:
|
|
277
|
+
"""Flush without blocking an asyncio event loop."""
|
|
278
|
+
import asyncio
|
|
279
|
+
await asyncio.to_thread(self.flush)
|
|
280
|
+
|
|
281
|
+
def shutdown(self) -> None:
|
|
282
|
+
with self._lock:
|
|
283
|
+
self._closed = True
|
|
284
|
+
self.flush()
|
|
285
|
+
|
|
286
|
+
def __enter__(self) -> Bench:
|
|
287
|
+
return self
|
|
288
|
+
|
|
289
|
+
def __exit__(self, *_: Any) -> None:
|
|
290
|
+
self.shutdown()
|
bench_sdk/evaluation.py
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"""Application checks share the versioned Bench report contract, without network work."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import asyncio
|
|
5
|
+
import hashlib
|
|
6
|
+
import inspect
|
|
7
|
+
import json
|
|
8
|
+
import re
|
|
9
|
+
import threading
|
|
10
|
+
import time
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from typing import Any, Callable
|
|
13
|
+
|
|
14
|
+
_ALIASES = {"expected_output": "expectedOutput", "expected_state": "expectedState", "business_outcome": "businessOutcome",
|
|
15
|
+
"required_tools": "requiredTools", "forbidden_tools": "forbiddenTools", "max_tool_calls": "maxToolCalls", "max_model_calls": "maxModelCalls"}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def snapshot(value: Any) -> Any:
|
|
19
|
+
return json.loads(json.dumps(value, allow_nan=False))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def equal(a: Any, b: Any) -> bool:
|
|
23
|
+
if isinstance(a, bool) or isinstance(b, bool):
|
|
24
|
+
return type(a) is type(b) and a == b
|
|
25
|
+
if isinstance(a, dict) and isinstance(b, dict):
|
|
26
|
+
return a.keys() == b.keys() and all(equal(a[k], b[k]) for k in a)
|
|
27
|
+
if isinstance(a, list) and isinstance(b, list):
|
|
28
|
+
return len(a) == len(b) and all(equal(x, y) for x, y in zip(a, b))
|
|
29
|
+
return a == b
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(frozen=True)
|
|
33
|
+
class EvaluationContext:
|
|
34
|
+
case_id: str
|
|
35
|
+
signal: threading.Event
|
|
36
|
+
deadline: float
|
|
37
|
+
turn_index: int | None = None
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def cancelled(self) -> bool:
|
|
41
|
+
return self.signal.is_set() or time.monotonic() >= self.deadline
|
|
42
|
+
|
|
43
|
+
def raise_if_cancelled(self) -> None:
|
|
44
|
+
if self.cancelled:
|
|
45
|
+
raise asyncio.CancelledError()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class Capture:
|
|
49
|
+
def __init__(self):
|
|
50
|
+
self.lock = threading.Lock()
|
|
51
|
+
self.active, self.limited, self.pending = True, False, 0
|
|
52
|
+
self.spans: list[dict] = []
|
|
53
|
+
|
|
54
|
+
def start(self):
|
|
55
|
+
with self.lock:
|
|
56
|
+
self.pending += 1
|
|
57
|
+
|
|
58
|
+
def finish(self, row):
|
|
59
|
+
with self.lock:
|
|
60
|
+
self.pending -= 1
|
|
61
|
+
if self.active:
|
|
62
|
+
if row is None or len(self.spans) >= 100:
|
|
63
|
+
self.limited = True
|
|
64
|
+
else:
|
|
65
|
+
self.spans.append(row)
|
|
66
|
+
|
|
67
|
+
def freeze(self):
|
|
68
|
+
with self.lock:
|
|
69
|
+
self.active = False
|
|
70
|
+
return list(self.spans), self.limited, self.pending
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def validate(source_revision, context_revision, cases, timeout):
|
|
74
|
+
if not isinstance(source_revision, str) or not re.fullmatch(r"[a-f0-9]{40}", source_revision) or not isinstance(context_revision, str) or not 1 <= len(context_revision) <= 200:
|
|
75
|
+
raise ValueError("Pin a full source revision and a context revision.")
|
|
76
|
+
if not isinstance(cases, list) or not 1 <= len(cases) <= 100 or isinstance(timeout, bool) or not 0 < timeout <= 300:
|
|
77
|
+
raise ValueError("Use 1 to 100 cases and a timeout up to 300 seconds.")
|
|
78
|
+
pinned = snapshot(cases)
|
|
79
|
+
if len(json.dumps(pinned).encode()) > 500000:
|
|
80
|
+
raise ValueError("Case suite exceeds 500 KB.")
|
|
81
|
+
ids = set()
|
|
82
|
+
for case in pinned:
|
|
83
|
+
if not isinstance(case, dict):
|
|
84
|
+
raise ValueError("A case must be an object.")
|
|
85
|
+
for key, alias in _ALIASES.items():
|
|
86
|
+
if key in case:
|
|
87
|
+
if alias in case:
|
|
88
|
+
raise ValueError("Use one spelling per case field.")
|
|
89
|
+
case[alias] = case.pop(key)
|
|
90
|
+
name = case.get("id")
|
|
91
|
+
if not isinstance(name, str) or not 1 <= len(name) <= 100 or name in ids:
|
|
92
|
+
raise ValueError("Case IDs must be unique and nonempty.")
|
|
93
|
+
ids.add(name)
|
|
94
|
+
if "input" not in case or case.get("split", "regression") not in ("capability", "incident", "regression", "holdout"):
|
|
95
|
+
raise ValueError("Each case needs an input and valid split.")
|
|
96
|
+
if "businessOutcome" in case and (not isinstance(case["businessOutcome"], str) or not 1 <= len(case["businessOutcome"]) <= 2000):
|
|
97
|
+
raise ValueError("Provide a bounded business outcome.")
|
|
98
|
+
count = 0
|
|
99
|
+
for key in ("requiredTools", "forbiddenTools"):
|
|
100
|
+
names = case.get(key, [])
|
|
101
|
+
if not isinstance(names, list) or any(not isinstance(n, str) or not 1 <= len(n) <= 200 for n in names):
|
|
102
|
+
raise ValueError("Invalid tool assertions.")
|
|
103
|
+
count += len(names)
|
|
104
|
+
if count > 90:
|
|
105
|
+
raise ValueError("Use at most 90 tool assertions per case.")
|
|
106
|
+
for key in ("maxToolCalls", "maxModelCalls"):
|
|
107
|
+
if key in case and (type(case[key]) is not int or not 0 <= case[key] <= 10000):
|
|
108
|
+
raise ValueError("Call limits must be nonnegative integers up to 10000.")
|
|
109
|
+
return pinned
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
async def invoke(fn: Callable, *args):
|
|
113
|
+
# Sync callbacks run off-loop. Cancellation cannot kill a Python thread.
|
|
114
|
+
result = fn(*args) if inspect.iscoroutinefunction(fn) else await asyncio.to_thread(fn, *args)
|
|
115
|
+
return await result if inspect.isawaitable(result) else result
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def score(case, output, state, observed, spans, error):
|
|
119
|
+
if not any(not s.get("parent_span_id") and s["kind"] == "AGENT" and s["status"] == "ok" for s in spans):
|
|
120
|
+
error = error or "Application root was not recorded. No complete score."
|
|
121
|
+
if "expectedState" in case and not observed:
|
|
122
|
+
error = error or "Application state was not observed. No complete score."
|
|
123
|
+
checks, findings = [], []
|
|
124
|
+
def check(id, passed, reason):
|
|
125
|
+
checks.append(dict(id=id, passed=passed, reason=reason))
|
|
126
|
+
if "expectedOutput" in case:
|
|
127
|
+
check("expected-output", equal(output, case["expectedOutput"]), "Compare actual output with the expected outcome.")
|
|
128
|
+
if "expectedState" in case and observed:
|
|
129
|
+
check("expected-state", equal(state, case["expectedState"]), "Compare observed tool effects with the expected business state.")
|
|
130
|
+
tools = [s for s in spans if s["kind"] == "TOOL"]
|
|
131
|
+
for name in case.get("requiredTools", []):
|
|
132
|
+
check("required-tool:" + name, any(s["name"] == name and s["status"] == "ok" for s in tools), "A successful recorded tool call is required.")
|
|
133
|
+
for name in case.get("forbiddenTools", []):
|
|
134
|
+
check("forbidden-tool:" + name, not any(s["name"] == name for s in tools), "This tool must not be invoked.")
|
|
135
|
+
for field, kind, label in (("maxToolCalls", "TOOL", "tool"), ("maxModelCalls", "LLM", "model")):
|
|
136
|
+
if field in case:
|
|
137
|
+
count = sum(s["kind"] == kind for s in spans)
|
|
138
|
+
check(label + "-call-limit", count <= case[field], f"{count} recorded calls; limit {case[field]}.")
|
|
139
|
+
for tool in tools:
|
|
140
|
+
if tool["status"] == "error":
|
|
141
|
+
findings.append(dict(category="tool", title=tool["name"] + " failed", evidence_span_ids=[tool["span_id"]], confidence="observed_failure", fix_brief="Inspect this tool's contract and dependencies. Reproduce the failure, fix it, and rerun incident and regression cases."))
|
|
142
|
+
for item in checks:
|
|
143
|
+
if not item["passed"]:
|
|
144
|
+
findings.append(dict(category="quality" if item["id"] in ("expected-output", "expected-state") else "harness", title=item["id"], evidence_span_ids=[s["span_id"] for s in spans], confidence="hypothesis", fix_brief="Inspect the real application path, tools, state, routing and retries. Change one suspected cause and rerun unchanged incident, regression and holdout cases."))
|
|
145
|
+
status = "error" if error else "unscored" if not checks else "passed" if all(c["passed"] for c in checks) else "failed"
|
|
146
|
+
return dict(id=case["id"], split=case.get("split", "regression"), status=status, checks=checks, findings=findings, spans=spans, **({"error": error} if error else {}))
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
async def evaluate(bench, *, source_revision: str, context_revision: str, cases: list[dict], run: Callable,
|
|
150
|
+
observe: Callable | None = None, timeout: float = 30, cancel_event: threading.Event | None = None) -> dict:
|
|
151
|
+
pinned = validate(source_revision, context_revision, cases, timeout)
|
|
152
|
+
if not callable(run) or (observe is not None and not callable(observe)):
|
|
153
|
+
raise ValueError("A real application entry point is required.")
|
|
154
|
+
if bench._closed or bench._evaluation.get() is not None:
|
|
155
|
+
raise ValueError("Use an open client outside another application evaluation.")
|
|
156
|
+
results = []
|
|
157
|
+
for case in pinned:
|
|
158
|
+
if cancel_event and cancel_event.is_set():
|
|
159
|
+
break
|
|
160
|
+
capture = Capture()
|
|
161
|
+
context = EvaluationContext(case["id"], threading.Event(), time.monotonic() + timeout)
|
|
162
|
+
async def execute():
|
|
163
|
+
own = bench._evaluation.set(capture)
|
|
164
|
+
parent = bench._context.set(None)
|
|
165
|
+
try:
|
|
166
|
+
with bench.trace("system-entrypoint", kind="AGENT", input=snapshot(case["input"])) as root:
|
|
167
|
+
output = snapshot(await invoke(run, snapshot(case["input"]), context))
|
|
168
|
+
state = snapshot(await invoke(observe, context)) if observe else None
|
|
169
|
+
root.set_output(output)
|
|
170
|
+
return output, state
|
|
171
|
+
finally:
|
|
172
|
+
bench._context.reset(parent)
|
|
173
|
+
bench._evaluation.reset(own)
|
|
174
|
+
async def cancellation():
|
|
175
|
+
while not (cancel_event and cancel_event.is_set()):
|
|
176
|
+
await asyncio.sleep(0.01)
|
|
177
|
+
task, cancel = asyncio.create_task(execute()), asyncio.create_task(cancellation())
|
|
178
|
+
error, output, state, observed, stopped = None, None, None, False, False
|
|
179
|
+
try:
|
|
180
|
+
done, _ = await asyncio.wait([task, cancel], timeout=timeout, return_when=asyncio.FIRST_COMPLETED)
|
|
181
|
+
if task not in done or context.cancelled or (cancel_event and cancel_event.is_set()):
|
|
182
|
+
stopped = True
|
|
183
|
+
error = "Application timed out or was stopped. No complete score."
|
|
184
|
+
else:
|
|
185
|
+
try:
|
|
186
|
+
output, state = task.result()
|
|
187
|
+
observed = observe is not None
|
|
188
|
+
except (Exception, asyncio.CancelledError):
|
|
189
|
+
error = "Application execution failed. Inspect recorded spans."
|
|
190
|
+
finally:
|
|
191
|
+
context.signal.set()
|
|
192
|
+
cancel.cancel()
|
|
193
|
+
if not task.done():
|
|
194
|
+
task.cancel()
|
|
195
|
+
# Consume eventual exceptions without waiting forever for uncooperative code.
|
|
196
|
+
task.add_done_callback(lambda t: t.exception() if not t.cancelled() else None)
|
|
197
|
+
spans, limited, pending = capture.freeze()
|
|
198
|
+
if limited or pending:
|
|
199
|
+
error = "Application evidence is incomplete. Await all tools and stay within capture limits."
|
|
200
|
+
stopped = stopped or bool(pending)
|
|
201
|
+
result = score(case, output, state, observed, spans, error)
|
|
202
|
+
try:
|
|
203
|
+
result["case_definition"] = bench._safe(case)
|
|
204
|
+
result["output"] = bench._safe(output)
|
|
205
|
+
if observed:
|
|
206
|
+
result["observedState"] = bench._safe(state)
|
|
207
|
+
except Exception:
|
|
208
|
+
result.update(status="error", error="Application evidence could not be redacted.")
|
|
209
|
+
results.append(result)
|
|
210
|
+
if stopped:
|
|
211
|
+
break
|
|
212
|
+
counts = {"passed": 0, "failed": 0, "errors": 0, "unscored": 0}
|
|
213
|
+
for case in results:
|
|
214
|
+
counts["errors" if case["status"] == "error" else case["status"]] += 1
|
|
215
|
+
complete = len(results) == len(pinned) and not counts["errors"] and not counts["unscored"]
|
|
216
|
+
digest = hashlib.sha256(json.dumps(dict(context=context_revision, cases=pinned), sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode()).hexdigest()
|
|
217
|
+
return dict(schema_version=1, execution_mode="application_runtime", evidence_origin="sdk_client_reported",
|
|
218
|
+
environment=bench._environment or "unspecified", source_revision=source_revision, context_revision=context_revision,
|
|
219
|
+
suite_hash=digest, planned_case_count=len(pinned), coverage=dict(instrumentation="explicit_spans", tool_dependencies="application_configured", hosted_validation=False),
|
|
220
|
+
cases=results, summary=dict(status="completed" if complete else "incomplete", score=100 * counts["passed"] / len(pinned) if complete else None, **counts))
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
async def simulate(bench, *, create_session: Callable, **options) -> dict:
|
|
224
|
+
if not callable(create_session):
|
|
225
|
+
raise ValueError("An application session factory is required.")
|
|
226
|
+
cases = snapshot(options["cases"])
|
|
227
|
+
for case in cases:
|
|
228
|
+
data = case.get("input", {})
|
|
229
|
+
if not isinstance(data, dict) or not isinstance(data.get("turns"), list) or not 1 <= len(data["turns"]) <= 20:
|
|
230
|
+
raise ValueError("A simulation requires 1 to 20 scripted user turns.")
|
|
231
|
+
if "expected_state" not in case and "expectedState" not in case:
|
|
232
|
+
raise ValueError("A simulation requires the expected business state.")
|
|
233
|
+
if "initial_state" in data:
|
|
234
|
+
if "initialState" in data:
|
|
235
|
+
raise ValueError("Use one spelling for initial state.")
|
|
236
|
+
data["initialState"] = data.pop("initial_state")
|
|
237
|
+
if "initialState" not in data:
|
|
238
|
+
raise ValueError("Provide initial_state for a fresh simulation session.")
|
|
239
|
+
observations = {}
|
|
240
|
+
async def run(data, context):
|
|
241
|
+
session = await invoke(create_session, data["initialState"], context)
|
|
242
|
+
try:
|
|
243
|
+
if not all(callable(getattr(session, method, None)) for method in ("turn", "observe", "close")):
|
|
244
|
+
raise ValueError("A session must provide turn, observe and close.")
|
|
245
|
+
reply = None
|
|
246
|
+
for index, message in enumerate(data["turns"]):
|
|
247
|
+
context.raise_if_cancelled()
|
|
248
|
+
turn = EvaluationContext(context.case_id, context.signal, context.deadline, index)
|
|
249
|
+
reply = await invoke(session.turn, message, turn)
|
|
250
|
+
context.raise_if_cancelled()
|
|
251
|
+
observations[context.case_id] = snapshot(await invoke(session.observe))
|
|
252
|
+
return reply
|
|
253
|
+
finally:
|
|
254
|
+
if callable(getattr(session, "close", None)):
|
|
255
|
+
await invoke(session.close)
|
|
256
|
+
def observe(context):
|
|
257
|
+
return observations.pop(context.case_id)
|
|
258
|
+
return await evaluate(bench, **{**options, "cases": cases}, run=run, observe=observe)
|
bench_sdk/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: trybench-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Trace AI applications and test their behavior with Bench
|
|
5
|
+
Author: Bench
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Documentation, https://docs.usebench.ai/sdk/python
|
|
8
|
+
Project-URL: Repository, https://github.com/trybench/bench-sdk
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# Bench Python SDK · Beta
|
|
18
|
+
|
|
19
|
+
**Beta, version 0.1.0.** Pin versions and test upgrades in staging.
|
|
20
|
+
|
|
21
|
+
Trace Python applications, agents and tools without changing their behavior.
|
|
22
|
+
Python 3.10+. No third-party runtime dependencies. Apache-2.0.
|
|
23
|
+
|
|
24
|
+
Install with `python -m pip install trybench-sdk`. The Python import is `bench_sdk`.
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
import os
|
|
28
|
+
from bench_sdk import Bench
|
|
29
|
+
|
|
30
|
+
bench = Bench(
|
|
31
|
+
api_key=os.environ["BENCH_API_KEY"],
|
|
32
|
+
repository="your-team/your-app",
|
|
33
|
+
branch="main",
|
|
34
|
+
environment="staging",
|
|
35
|
+
system_name="Support agent",
|
|
36
|
+
endpoint=os.environ.get("BENCH_API_BASE_URL", "https://api.trybench.ai"),
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
with bench.trace("support-request", kind="AGENT") as span:
|
|
41
|
+
# Call your existing application here.
|
|
42
|
+
result = handle_request()
|
|
43
|
+
span.set_output(result)
|
|
44
|
+
finally:
|
|
45
|
+
# Deliver success and failure events after this application's work finishes.
|
|
46
|
+
bench.shutdown()
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Use the same `with bench.trace(...)` around `await agent.ainvoke(...)` in an
|
|
50
|
+
async application, then `await bench.aflush()`. Context is preserved across
|
|
51
|
+
await points and inherited by nested tasks. Wrap tools in nested spans with
|
|
52
|
+
`kind="TOOL"`. Separate requests started outside a parent get separate trace IDs.
|
|
53
|
+
|
|
54
|
+
Works with explicit wrappers around Deep Agents, LangGraph, LangChain, model
|
|
55
|
+
clients and custom Python code. It does not automatically instrument framework
|
|
56
|
+
internals or consume a streaming result; keep the span open while reading the stream.
|
|
57
|
+
|
|
58
|
+
Inputs, outputs and custom attributes are omitted by default. With permission,
|
|
59
|
+
set `capture_content=True`, pass `input=...` and call `span.set_output(...)`.
|
|
60
|
+
Built-in matching removes common secrets, emails, supported phone numbers, IPv4
|
|
61
|
+
addresses, card patterns and sensitive structured fields before transmission.
|
|
62
|
+
Add a `redact(value)` callback for application-specific data. These rules do not
|
|
63
|
+
recognize every personal detail in free text.
|
|
64
|
+
|
|
65
|
+
Set `component_id` to a real prompt component from Bench to link the event to
|
|
66
|
+
its criteria. Use operational attributes such as `gen_ai.usage.input_tokens`
|
|
67
|
+
and `gen_ai.usage.output_tokens` for usage counts. Never invent component IDs.
|
|
68
|
+
|
|
69
|
+
The queue defaults to 200 spans. Flush explicitly at request or process lifecycle
|
|
70
|
+
boundaries. Transient delivery failures retry once with unchanged IDs, then drop
|
|
71
|
+
the batch. `bench.stats` reports queued and dropped spans. `on_error(message)`
|
|
72
|
+
receives a fixed message, without content or keys. A telemetry failure does not
|
|
73
|
+
replace an application exception. This is a bounded queue, not durable storage.
|
|
74
|
+
|
|
75
|
+
## Test your application
|
|
76
|
+
|
|
77
|
+
`await bench.evaluate_system(...)` calls your application's request handler with
|
|
78
|
+
pinned cases. It captures the real nested tool/model traces, compares the final
|
|
79
|
+
output and independently observed state, and returns a redacted report locally.
|
|
80
|
+
Use a test database and test service credentials.
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
report = await bench.evaluate_system(
|
|
84
|
+
source_revision=os.environ["GIT_COMMIT_SHA"], # Full 40-character commit SHA
|
|
85
|
+
context_revision="refund-policy-v1",
|
|
86
|
+
cases=[{
|
|
87
|
+
"id": "outside-refund-policy", "split": "regression",
|
|
88
|
+
"input": {"days": 45}, "expected_output": {"refunded": False},
|
|
89
|
+
"forbidden_tools": ["issue-refund"],
|
|
90
|
+
}],
|
|
91
|
+
run=lambda request, context: handle_request(request),
|
|
92
|
+
)
|
|
93
|
+
assert report["summary"]["status"] == "completed"
|
|
94
|
+
assert all(case["status"] == "passed" for case in report["cases"])
|
|
95
|
+
# Explicit upload, only when you want this report saved in Bench:
|
|
96
|
+
await bench.publish_system_evaluation(int(os.environ["BENCH_SYSTEM_ID"]), report)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`run(input, context)` and `observe(context)` may be synchronous or asynchronous.
|
|
100
|
+
When a case has `expected_state`, supply `observe` to read the authoritative test
|
|
101
|
+
state. Context provides `case_id`, `cancelled`, `signal`, `deadline` and
|
|
102
|
+
`raise_if_cancelled()`. Inputs are JSON snapshots; changes inside the application
|
|
103
|
+
do not change the case's assertions.
|
|
104
|
+
|
|
105
|
+
`await bench.simulate_system(...)` accepts the same revisions and cases, plus
|
|
106
|
+
`create_session(initial_state, context)`. Cases use
|
|
107
|
+
`input={"initial_state": {...}, "turns": [...]}` and require `expected_state`.
|
|
108
|
+
Return an object with `turn(message, context)`, `observe()` and `close()` methods.
|
|
109
|
+
A fresh session receives 1 to 20 scripted customer turns. Bench snapshots observed
|
|
110
|
+
state before closing the session. `context.turn_index` identifies the turn.
|
|
111
|
+
|
|
112
|
+
Both helpers use a 30-second timeout per case, configurable with `timeout` up to
|
|
113
|
+
300 seconds. Pass a `threading.Event` as `cancel_event` to stop the suite. Missing
|
|
114
|
+
assertions, missing state, unfinished traces and timeouts remain incomplete.
|
|
115
|
+
Callbacks must honor cancellation; Python cannot forcibly stop a synchronous
|
|
116
|
+
thread. Await all child work and isolate external side effects. These helpers
|
|
117
|
+
are local execution, not a process sandbox or a hosted verification claim.
|
|
118
|
+
|
|
119
|
+
Tests record redacted content even when production capture is metadata-only, so
|
|
120
|
+
use synthetic inputs. Reports are not uploaded and paid checks are not started
|
|
121
|
+
unless you take a separate explicit action. Automatic framework adapters are
|
|
122
|
+
coming soon.
|
|
123
|
+
|
|
124
|
+
Run checks from this directory:
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
PYTHONPATH=src python -m unittest discover -s tests -v
|
|
128
|
+
python -m build
|
|
129
|
+
python -m twine check dist/*
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
See [Bench documentation](https://docs.usebench.ai/sdk/python) and the repository's
|
|
133
|
+
[publishing guide](../PUBLISHING.md).
|
|
134
|
+
|
|
135
|
+
## Latency, tool calls and cost
|
|
136
|
+
|
|
137
|
+
Every recorded call carries start/end timestamps, status, parent span ID and an
|
|
138
|
+
automatically measured `bench.duration_ms` from a monotonic clock. Wrap each tool
|
|
139
|
+
execution, including retries, with a TOOL span to retain its individual timing.
|
|
140
|
+
Use `gen_ai.operation.name=execute_tool` and `gen_ai.tool.name` for tool identity.
|
|
141
|
+
Production sampling can omit traces; a rate of 1 records each instrumented call.
|
|
142
|
+
The bounded delivery queue is not a guarantee against network or process loss.
|
|
143
|
+
|
|
144
|
+
Add `gen_ai.provider.name`, `gen_ai.request.model`, `gen_ai.response.model`,
|
|
145
|
+
`gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` when your provider
|
|
146
|
+
returns them. Add `bench.cost.usd` for the cost of that individual call and
|
|
147
|
+
`bench.cost.source` as `reported` or `estimated`. For estimates, also include
|
|
148
|
+
`bench.cost.pricing_version`. These fields survive metadata-only capture, so you
|
|
149
|
+
can measure usage without recording prompts or responses. Missing cost is unknown,
|
|
150
|
+
not zero. Do not repeat a child cost on its parent or count overlapping token
|
|
151
|
+
categories twice. The SDK does not guess provider prices or a tool's own charges.
|
|
152
|
+
|
|
153
|
+
The `gen_ai.*` names follow selected OpenTelemetry conventions. `bench.cost.*` and
|
|
154
|
+
`bench.duration_ms` are Bench extensions. Events currently use Bench JSON over
|
|
155
|
+
HTTPS; this release is not an OTLP exporter or collector.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
bench_sdk/__init__.py,sha256=2gfNuc8rQrrMiUBUNm7HY9XhACWOtC_c9qicn36n1DI,202
|
|
2
|
+
bench_sdk/client.py,sha256=XyZTqlgjvOWqFEzmhtn4cI72L031u5T45El8-evCAb4,14778
|
|
3
|
+
bench_sdk/evaluation.py,sha256=RkmHdtQLejxNomykzrX1i4e1okYuwhABfNVOt7IWHmM,13843
|
|
4
|
+
bench_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
trybench_sdk-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
6
|
+
trybench_sdk-0.1.0.dist-info/METADATA,sha256=83ik3zqA12bzVC_cWBWcig6yUwhUkO8molQceqVuZe8,7290
|
|
7
|
+
trybench_sdk-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
8
|
+
trybench_sdk-0.1.0.dist-info/top_level.txt,sha256=H5RBp5ZBWSuTh8LoxKB2m1SDDsZs96MPy0eimVW0BZ8,10
|
|
9
|
+
trybench_sdk-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bench_sdk
|