trodo-python 2.26.0__py3-none-any.whl → 2.26.2__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.
trodo/__init__.py CHANGED
@@ -41,7 +41,7 @@ Downstream microservice (join the caller's run instead of making a new one):
41
41
 
42
42
  from __future__ import annotations
43
43
 
44
- __version__ = "2.26.0"
44
+ __version__ = "2.26.2"
45
45
 
46
46
  from typing import Any, Callable, Dict, List, Optional, Union
47
47
 
trodo/_version.py CHANGED
@@ -1 +1 @@
1
- SDK_VERSION = "2.26.0"
1
+ SDK_VERSION = "2.26.2"
@@ -17,16 +17,28 @@ from typing import Any, Dict, List, Optional, Union
17
17
 
18
18
  __all__ = ["DatasetManager"]
19
19
 
20
- # The optional per-item fields, in wire order. ``input`` is always required.
21
- _ITEM_OPTIONAL = ("expected_output", "metadata", "source_trace_ref")
20
+ # The optional per-item fields, in wire order. ``input`` is required on a row.
21
+ _ITEM_OPTIONAL = ("output", "expected_output", "metadata", "source_trace_ref", "tags")
22
+ # A reference to production instead of content: the item becomes that unit's
23
+ # row (Input, Output and Evaluations filled by Trodo). ``eval_run_id`` names a
24
+ # verdict: Output is what the eval said, Expected its correction.
25
+ _UNIT_REF_KEYS = ("span_id", "run_id", "conversation_id", "eval_run_id")
26
+ _UNIT_REF_OPTIONAL = ("tags", "metadata")
22
27
 
23
28
 
24
29
  def _clean_item(item: Dict[str, Any]) -> Dict[str, Any]:
25
30
  if not isinstance(item, dict):
26
31
  raise ValueError("trodo: each dataset item must be a dict")
32
+ ref = [k for k in _UNIT_REF_KEYS if item.get(k)]
33
+ if ref and ("input" not in item or item["input"] is None):
34
+ out: Dict[str, Any] = {ref[0]: str(item[ref[0]])}
35
+ for key in _UNIT_REF_OPTIONAL:
36
+ if item.get(key) is not None:
37
+ out[key] = item[key]
38
+ return out
27
39
  if "input" not in item or item["input"] is None:
28
- raise ValueError("trodo: each dataset item requires an 'input' dict")
29
- out: Dict[str, Any] = {"input": item["input"]}
40
+ raise ValueError("trodo: each dataset item requires an 'input' dict, or a span_id / run_id / conversation_id / eval_run_id")
41
+ out = {"input": item["input"]}
30
42
  for key in _ITEM_OPTIONAL:
31
43
  if item.get(key) is not None:
32
44
  out[key] = item[key]
trodo/otel/processor.py CHANGED
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trodo-python
3
- Version: 2.26.0
3
+ Version: 2.26.2
4
4
  Summary: Trodo Analytics SDK for Python — server-side event tracking
5
5
  License: ISC
6
6
  Keywords: analytics,tracking,trodo,server-side
@@ -1,5 +1,5 @@
1
- trodo/__init__.py,sha256=P8tsY10bg0h-A8TjIYYEiFuYpo-jGSbDzViEsKbnKsU,28752
2
- trodo/_version.py,sha256=MX7IGM5dYbXPeFIXOWPhV7DPbCslhEe8Q7DCvxwKmhY,23
1
+ trodo/__init__.py,sha256=VDSYG1fk0IQ7WHKaU9OFHUpgQyNAhtzlxl-rq1MP8hM,28752
2
+ trodo/_version.py,sha256=GiZggLfKnXVCrwzvq12hUijpWwqpB6bz8DKCKTTDDPU,23
3
3
  trodo/client.py,sha256=6k6HeKrGV2720kK17--u6BjbhAUFZNUzpd9yEYiaQOs,24137
4
4
  trodo/types.py,sha256=eySgUvCXROG2TxtxgiU0MNr5iH0DEcduK8bmYtTKG44,3138
5
5
  trodo/user_context.py,sha256=uHCI2WYoOI3cNwdIUEuZdX4VYSu14pzm348ksn6hn_c,8195
@@ -13,7 +13,7 @@ trodo/auto/auto_event_manager.py,sha256=cztuRsRkNoJE5R4NfSfTrTJTGl4jx2Yb-Ncy0aVA
13
13
  trodo/delivery/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  trodo/delivery/sender.py,sha256=urO7m6mRMnSEW7_cNAmJ4A6jtDNxuihZHOxCx1jQScI,21348
15
15
  trodo/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- trodo/managers/dataset_manager.py,sha256=kR3aoyuq1gcZ5Gpr6bf2Mz_cqv275dXlO6cGL5qfwEA,4902
16
+ trodo/managers/dataset_manager.py,sha256=mifHYkHLWo0olXCNfQOqvpLPL8DDgbub7YAWWlrjIHQ,5609
17
17
  trodo/managers/experiment_manager.py,sha256=V-vemLtenfSI5VIcP0HPiXzEy8AyTrRrbJVCA9Z6wjo,10579
18
18
  trodo/managers/group_manager.py,sha256=ki3Se3qEoSZfREX63oeDeBmEfZF-ISHLE8azEtLg0tM,3542
19
19
  trodo/managers/people_manager.py,sha256=mMVnx40Mlifx6NGgChvohC9ViK6dQu2mkXNHbV8pK1E,2882
@@ -23,7 +23,7 @@ trodo/otel/__init__.py,sha256=yiRFXWUU45bAM2CV37XeO7zf1hmnmjufdP4XO50yEyE,624
23
23
  trodo/otel/auto_instrument.py,sha256=M5YVpFoPqn9bQohDFM7yyADrVGJPqFBToJLnBO7nOSA,29029
24
24
  trodo/otel/context.py,sha256=Jd0aTc0Q-1dM5kXXinhZD8YtnpdKgvneNiODyboVGKY,1418
25
25
  trodo/otel/helpers.py,sha256=XOMWcgZHaq5SQbkFxDaXPE4CDFjn01xjJmJ1vIxvwpw,20730
26
- trodo/otel/processor.py,sha256=WgtLdXT9gpR4TZ_9iuoX-kBP4UN4nelCtoDnogtW_Qc,8289
26
+ trodo/otel/processor.py,sha256=GiMQR3uKHq_sbqXU00MdyarStaBzrZLmPgU1YnlzZb4,8965
27
27
  trodo/otel/prompt_trace.py,sha256=-kywRBU0Q2gWntS9HU-P5i7Kc5U-IJU7UVLjkdC2jw4,13593
28
28
  trodo/otel/register.py,sha256=7X3AfFQ5YvHGOUmdq8J38LQGvOJFPD907yT3uAp90lI,9607
29
29
  trodo/otel/transport.py,sha256=hzZz8gwSMGJ8CxdijmLn1Ljt18owr9XTWy13DLbwYbw,2441
@@ -40,7 +40,7 @@ trodo/session/server_session.py,sha256=McsudEiq33XDq3nqxgzBcUvIjQxCMscwEuAPnYXrT
40
40
  trodo/session/session_manager.py,sha256=7ht5LeeZX1HLLfPeNV_a8NkXGbHl3up0CRtCGr3EzjQ,2995
41
41
  trodo/util/__init__.py,sha256=Z9c4rPPdKg06Kk3byKheDqksSgR4WNvS475oQ5sNljc,54
42
42
  trodo/util/lru.py,sha256=QIsM7s6J_E9ZjiXatSyReZIEeGypTAcgrPWWy8YsRa4,2465
43
- trodo_python-2.26.0.dist-info/METADATA,sha256=RE-9yCbqYEzBYYWCQuyXOGsyhGTSPw6rLpiv9cfEdF4,25308
44
- trodo_python-2.26.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
45
- trodo_python-2.26.0.dist-info/top_level.txt,sha256=VCQu1CJWFmNsqTs1YxMcw4Mq35Tc3z3uI9RwHEXAayQ,6
46
- trodo_python-2.26.0.dist-info/RECORD,,
43
+ trodo_python-2.26.2.dist-info/METADATA,sha256=-GYtkkYP3I9IlFhwYAqfq5rinYCAB0h12KcfErRwmoE,25308
44
+ trodo_python-2.26.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
45
+ trodo_python-2.26.2.dist-info/top_level.txt,sha256=VCQu1CJWFmNsqTs1YxMcw4Mq35Tc3z3uI9RwHEXAayQ,6
46
+ trodo_python-2.26.2.dist-info/RECORD,,