trodo-python 2.26.1__tar.gz → 2.26.2__tar.gz
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.
- {trodo_python-2.26.1 → trodo_python-2.26.2}/PKG-INFO +1 -1
- {trodo_python-2.26.1 → trodo_python-2.26.2}/pyproject.toml +1 -1
- trodo_python-2.26.2/tests/test_end_run_order.py +50 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/__init__.py +1 -1
- trodo_python-2.26.2/trodo/_version.py +1 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/otel/processor.py +18 -1
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo_python.egg-info/PKG-INFO +1 -1
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo_python.egg-info/SOURCES.txt +1 -0
- trodo_python-2.26.1/trodo/_version.py +0 -1
- {trodo_python-2.26.1 → trodo_python-2.26.2}/README.md +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/setup.cfg +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_anon_distinct_id.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_auto_instrument_fixes.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_cross_process_session.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_datasets.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_end_run.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_error_enrichment.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_experiments.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_framework_deference.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_get_prompt_version_types.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_instrumentor_resolution.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_llm_usage_cost.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_multi_agent_shape.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_processor_methods.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_prompt_fingerprint.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_prompt_trace.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_prompts.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_register_otel.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_sender.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_start_run.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_user_traits.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/tests/test_wrap_agent_unchanged.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/api/__init__.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/api/_retry.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/api/async_client.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/api/endpoints.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/api/http_client.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/auto/__init__.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/auto/auto_event_manager.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/client.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/delivery/__init__.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/delivery/sender.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/managers/__init__.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/managers/dataset_manager.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/managers/experiment_manager.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/managers/group_manager.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/managers/people_manager.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/managers/prompt_manager.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/managers/user_manager.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/otel/__init__.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/otel/auto_instrument.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/otel/context.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/otel/helpers.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/otel/prompt_trace.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/otel/register.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/otel/transport.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/otel/wrap_agent.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/prompts/__init__.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/prompts/compile.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/prompts/template.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/prompts/types.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/queue/__init__.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/queue/batch_flusher.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/queue/event_queue.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/session/__init__.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/session/server_session.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/session/session_manager.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/types.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/user_context.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/util/__init__.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo/util/lru.py +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo_python.egg-info/dependency_links.txt +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo_python.egg-info/requires.txt +0 -0
- {trodo_python-2.26.1 → trodo_python-2.26.2}/trodo_python.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""end_run sends the run's queued spans before the end itself."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from typing import Any, Dict, List, Optional
|
|
5
|
+
|
|
6
|
+
from trodo.otel.processor import TrodoSpanProcessor, TrodoSpan
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class _Http:
|
|
10
|
+
def __init__(self, order: List[str]) -> None:
|
|
11
|
+
self.order = order
|
|
12
|
+
|
|
13
|
+
def post_run_end(self, run_id: str, payload: Dict[str, Any]) -> None:
|
|
14
|
+
self.order.append("end")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class _Sender:
|
|
18
|
+
def __init__(self, order: List[str]) -> None:
|
|
19
|
+
self.order = order
|
|
20
|
+
self.queued: List[Any] = []
|
|
21
|
+
|
|
22
|
+
def enqueue(self, item: Any) -> None:
|
|
23
|
+
self.queued.append(item)
|
|
24
|
+
|
|
25
|
+
def flush(self, timeout_s: Optional[float] = None) -> None:
|
|
26
|
+
self.order.append(f"flush:{len(self.queued)}")
|
|
27
|
+
self.queued.clear()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _span(run_id: str, span_id: str) -> TrodoSpan:
|
|
31
|
+
return TrodoSpan(span_id=span_id, run_id=run_id, parent_span_id=None, kind="tool", name=span_id, status="ok", started_at="t")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_joined_spans_are_sent_before_the_end():
|
|
35
|
+
order: List[str] = []
|
|
36
|
+
proc = TrodoSpanProcessor(http_client=_Http(order), sender=_Sender(order))
|
|
37
|
+
proc.mark_joined("r1")
|
|
38
|
+
proc.enqueue_span(_span("r1", "s1"))
|
|
39
|
+
proc.enqueue_span(_span("r1", "s2"))
|
|
40
|
+
proc.end_run("r1", {"status": "ok"})
|
|
41
|
+
assert order == ["flush:2", "end"]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_buffered_spans_of_an_unjoined_run_are_not_lost():
|
|
45
|
+
order: List[str] = []
|
|
46
|
+
sender = _Sender(order)
|
|
47
|
+
proc = TrodoSpanProcessor(http_client=_Http(order), sender=sender)
|
|
48
|
+
proc.enqueue_span(_span("r2", "s1"))
|
|
49
|
+
proc.end_run("r2", {"status": "ok"})
|
|
50
|
+
assert order == ["flush:1", "end"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
SDK_VERSION = "2.26.2"
|
|
@@ -11,6 +11,9 @@ import threading
|
|
|
11
11
|
from dataclasses import dataclass, asdict
|
|
12
12
|
from typing import Any, Dict, List, Optional, Union
|
|
13
13
|
|
|
14
|
+
# How long end_run waits for the run's queued spans to send before sending the end.
|
|
15
|
+
END_RUN_FLUSH_S = 5.0
|
|
16
|
+
|
|
14
17
|
|
|
15
18
|
@dataclass
|
|
16
19
|
class TrodoRun:
|
|
@@ -189,7 +192,21 @@ class TrodoSpanProcessor:
|
|
|
189
192
|
pass
|
|
190
193
|
|
|
191
194
|
def end_run(self, run_id: str, payload: Dict[str, Any]) -> None:
|
|
192
|
-
"""Finalise a Run opened by start_run.
|
|
195
|
+
"""Finalise a Run opened by start_run.
|
|
196
|
+
|
|
197
|
+
The run's spans go first: joined spans wait in the sender's queue, and
|
|
198
|
+
an end that overtakes them gets the run evaluated on a partial trace.
|
|
199
|
+
Bounded, and a failure here never holds up the end.
|
|
200
|
+
"""
|
|
201
|
+
try:
|
|
202
|
+
with self._lock:
|
|
203
|
+
buffered = self._pending.pop(run_id, None) or []
|
|
204
|
+
if buffered:
|
|
205
|
+
self._send_spans(run_id, [s.to_dict() for s in buffered])
|
|
206
|
+
if self._sender is not None:
|
|
207
|
+
self._sender.flush(END_RUN_FLUSH_S)
|
|
208
|
+
except Exception:
|
|
209
|
+
pass
|
|
193
210
|
try:
|
|
194
211
|
self._http.post_run_end(run_id, payload)
|
|
195
212
|
except Exception:
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
SDK_VERSION = "2.26.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|