agenta 0.27.0a7__py3-none-any.whl → 0.27.0a9__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.

Potentially problematic release.


This version of agenta might be problematic. Click here for more details.

agenta/sdk/agenta_init.py CHANGED
@@ -88,7 +88,7 @@ class AgentaSingleton:
88
88
  )
89
89
 
90
90
  self.tracing = Tracing(
91
- url=f"{self.host}/api/observability/v1/oltp/traces", # type: ignore
91
+ url=f"{self.host}/api/observability/v1/otlp/traces", # type: ignore
92
92
  )
93
93
 
94
94
  self.tracing.configure(
@@ -38,13 +38,23 @@ class InlineTraceExporter(SpanExporter):
38
38
  def force_flush(self, timeout_millis: int = 30000) -> bool:
39
39
  return True
40
40
 
41
+ def is_ready(
42
+ self,
43
+ trace_id: int,
44
+ ) -> bool:
45
+ is_ready = trace_id in self._registry
46
+
47
+ return is_ready
48
+
41
49
  def fetch(
42
50
  self,
43
51
  trace_id: int,
44
52
  ) -> List[ReadableSpan]:
53
+
45
54
  trace = self._registry.get(trace_id, [])
46
55
 
47
- del self._registry[trace_id]
56
+ if trace_id in self._registry:
57
+ del self._registry[trace_id]
48
58
 
49
59
  return trace
50
60
 
@@ -1,4 +1,4 @@
1
- from typing import Optional, Dict
1
+ from typing import Optional, Dict, List
2
2
 
3
3
  from opentelemetry.context import Context
4
4
  from opentelemetry.sdk.trace import Span
@@ -7,6 +7,7 @@ from opentelemetry.sdk.trace.export import (
7
7
  ReadableSpan,
8
8
  BatchSpanProcessor,
9
9
  _DEFAULT_MAX_QUEUE_SIZE,
10
+ _DEFAULT_MAX_EXPORT_BATCH_SIZE,
10
11
  )
11
12
 
12
13
  from agenta.sdk.utils.logging import log
@@ -15,6 +16,7 @@ from agenta.sdk.utils.logging import log
15
16
 
16
17
 
17
18
  class TraceProcessor(BatchSpanProcessor):
19
+
18
20
  def __init__(
19
21
  self,
20
22
  span_exporter: SpanExporter,
@@ -27,14 +29,15 @@ class TraceProcessor(BatchSpanProcessor):
27
29
  super().__init__(
28
30
  span_exporter,
29
31
  _DEFAULT_MAX_QUEUE_SIZE,
30
- 60 * 60 * 1000, # 1 hour
31
- _DEFAULT_MAX_QUEUE_SIZE,
32
+ 12 * 60 * 60 * 1000, # 12 hours
33
+ _DEFAULT_MAX_EXPORT_BATCH_SIZE,
32
34
  500, # < 1 second (0.5 seconds)
33
35
  )
34
36
 
35
37
  self._registry = dict()
36
38
  self._exporter = span_exporter
37
39
  self.references = references or dict()
40
+ self.spans: Dict[int, List[ReadableSpan]] = dict()
38
41
 
39
42
  def on_start(
40
43
  self,
@@ -55,12 +58,32 @@ class TraceProcessor(BatchSpanProcessor):
55
58
  self,
56
59
  span: ReadableSpan,
57
60
  ):
58
- super().on_end(span)
61
+ if self.done:
62
+ return
63
+
64
+ if span.context.trace_id not in self.spans:
65
+ self.spans[span.context.trace_id] = list()
66
+
67
+ self.spans[span.context.trace_id].append(span)
59
68
 
60
69
  del self._registry[span.context.trace_id][span.context.span_id]
61
70
 
62
- if self.is_ready(span.get_span_context().trace_id):
63
- self.force_flush()
71
+ if len(self._registry[span.context.trace_id]) == 0:
72
+ self.export(span.context.trace_id)
73
+
74
+ def export(
75
+ self,
76
+ trace_id: int,
77
+ ):
78
+ spans = self.spans[trace_id]
79
+
80
+ for span in spans:
81
+ self.queue.appendleft(span)
82
+
83
+ with self.condition:
84
+ self.condition.notify()
85
+
86
+ del self.spans[trace_id]
64
87
 
65
88
  def force_flush(
66
89
  self,
@@ -77,7 +100,12 @@ class TraceProcessor(BatchSpanProcessor):
77
100
  self,
78
101
  trace_id: Optional[int] = None,
79
102
  ) -> bool:
80
- is_ready = not len(self._registry.get(trace_id, {}))
103
+ is_ready = True
104
+
105
+ try:
106
+ is_ready = self._exporter.is_ready(trace_id)
107
+ except: # pylint: disable=bare-except
108
+ pass
81
109
 
82
110
  return is_ready
83
111
 
@@ -1,6 +1,5 @@
1
1
  from typing import Optional, Any, Dict
2
2
  from enum import Enum
3
- from uuid import UUID
4
3
 
5
4
  from httpx import get as check
6
5
 
@@ -156,15 +155,6 @@ class Tracing(metaclass=Singleton):
156
155
 
157
156
  for key in refs.keys():
158
157
  if key in [_.value for _ in Reference.__members__.values()]:
159
- # TYPE AND FORMAT CHECKING
160
- if key.endswith(".id"):
161
- try:
162
- refs[key] = str(UUID(refs[key]))
163
- except: # pylint: disable=bare-except
164
- refs[key] = None
165
-
166
- refs[key] = str(refs[key])
167
-
168
158
  # ADD REFERENCE TO THIS SPAN
169
159
  span.set_attribute(
170
160
  key.value if isinstance(key, Enum) else key,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: agenta
3
- Version: 0.27.0a7
3
+ Version: 0.27.0a9
4
4
  Summary: The SDK for agenta is an open-source LLMOps platform.
5
5
  Home-page: https://agenta.ai
6
6
  Keywords: LLMOps,LLM,evaluation,prompt engineering
@@ -133,7 +133,7 @@ agenta/docker/docker-assets/lambda_function.py,sha256=h4UZSSfqwpfsCgERv6frqwm_4J
133
133
  agenta/docker/docker-assets/main.py,sha256=7MI-21n81U7N7A0GxebNi0cmGWtJKcR2sPB6FcH2QfA,251
134
134
  agenta/docker/docker_utils.py,sha256=kO1q2_IR0fEAo4M-2Pt_v-zC7GxxnkLogjKFhU869Ps,3555
135
135
  agenta/sdk/__init__.py,sha256=IopYEonqvpdGXsAYh2wQ4Ai_2YzsY7aF88wTzrclV4M,1208
136
- agenta/sdk/agenta_init.py,sha256=3TVZFGrcD8GzhVRQSA36PepQLr313RQCVVsdinzP_ok,10308
136
+ agenta/sdk/agenta_init.py,sha256=vQcaWvvrMR6xMNJvX6V-9eNIvx3_JsjPA6xcxiahX30,10308
137
137
  agenta/sdk/assets.py,sha256=Zv4i8MVUSB3jMODQon1mzJtYxuntmrCNjLGk8f-2fls,2856
138
138
  agenta/sdk/client.py,sha256=trKyBOYFZRk0v5Eptxvh87yPf50Y9CqY6Qgv4Fy-VH4,2142
139
139
  agenta/sdk/config_manager.py,sha256=HFOJpJKBkhlA0C-KPuxb4-bHNZeZqdpmx_beoX4lQw8,7997
@@ -150,11 +150,11 @@ agenta/sdk/tracing/__init__.py,sha256=rQNe5-zT5Kt7_CDhq-lnUIi1EYTBVzVf_MbfcIxVD9
150
150
  agenta/sdk/tracing/attributes.py,sha256=zh8JQZSeYCLBeIRSopKJx6QQ-WEgw08Cr64DS_WOcT8,3833
151
151
  agenta/sdk/tracing/context.py,sha256=PSJdhcaOXSMAuGUBySpLKPKyx8duF3TJzhUEk2ufqPc,777
152
152
  agenta/sdk/tracing/conventions.py,sha256=JBtznBXZ3aRkGKkLl7cPwdMNh3w1G-H2Ta2YrAxbr38,950
153
- agenta/sdk/tracing/exporters.py,sha256=LzNGjOARwRrJ5gTFjdG9ziZlqnA0WeMjpkUfpsl8BSs,1383
153
+ agenta/sdk/tracing/exporters.py,sha256=VLebUsoq29mcBccpwXvNHOZWwi2Kq3oZvUsKMsb9CGE,1569
154
154
  agenta/sdk/tracing/inline.py,sha256=0ZLy89k5wkmTUaz69vqc3vP51ZdqmLGMj3Qz2o3hieE,32856
155
- agenta/sdk/tracing/processors.py,sha256=uqH8AKdRJkv-MY5FcTD-Qrrr0ARMlAAsImPPKolteQ0,2444
155
+ agenta/sdk/tracing/processors.py,sha256=oyZkIbFBlBLEyl757TY1yykdDm40vH2z1_t-itOC0j0,3116
156
156
  agenta/sdk/tracing/spans.py,sha256=nqUOjjirBxB8Eacv8Qj4Ra_6rknGi3lbJdNyKmk5ODQ,3707
157
- agenta/sdk/tracing/tracing.py,sha256=S-7rt1LMHCF3YzV1XzAnhdkeocCffj9CCwlHScU7mqU,7350
157
+ agenta/sdk/tracing/tracing.py,sha256=laInX27JUBCS_KiOqMax2Ja5UJ9X72tY5bufLbcYebo,6990
158
158
  agenta/sdk/types.py,sha256=B7C7Jpeq0CpmLwmN1dmpggJsZX8WpxyyM42PkdSsx3s,5669
159
159
  agenta/sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
160
160
  agenta/sdk/utils/costs.py,sha256=i8C7ud__pThLS55XkN4YW8czXtGeXr2mx7jjcOFeiXg,5955
@@ -179,7 +179,7 @@ agenta/templates/simple_prompt/app.py,sha256=kODgF6lhzsaJPdgL5b21bUki6jkvqjWZzWR
179
179
  agenta/templates/simple_prompt/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHTabsiOnfQo3c5k,70
180
180
  agenta/templates/simple_prompt/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
181
181
  agenta/templates/simple_prompt/template.toml,sha256=DQBtRrF4GU8LBEXOZ-GGuINXMQDKGTEG5y37tnvIUIE,60
182
- agenta-0.27.0a7.dist-info/METADATA,sha256=ztCgqJSX5gG6RVtrgR_84TjG87fDPd8Hcjtgin-c2m4,31738
183
- agenta-0.27.0a7.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
184
- agenta-0.27.0a7.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
185
- agenta-0.27.0a7.dist-info/RECORD,,
182
+ agenta-0.27.0a9.dist-info/METADATA,sha256=IgUZsGVZc83d5z7nmSivXC7lrpE1lJaV3P2D6LduATI,31738
183
+ agenta-0.27.0a9.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
184
+ agenta-0.27.0a9.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
185
+ agenta-0.27.0a9.dist-info/RECORD,,