lmnr 0.4.42__py3-none-any.whl → 0.4.44__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.
@@ -3,11 +3,13 @@ from functools import wraps
3
3
  import logging
4
4
  import os
5
5
  import pydantic
6
+ import traceback
6
7
  import types
7
8
  from typing import Any, Optional
8
9
 
9
10
  from opentelemetry import trace
10
11
  from opentelemetry import context as context_api
12
+ from opentelemetry.trace import Span
11
13
 
12
14
  from lmnr.sdk.utils import get_input_from_func_args, is_method
13
15
  from lmnr.openllmetry_sdk.tracing import get_tracer
@@ -69,7 +71,12 @@ def entity_method(
69
71
  except TypeError:
70
72
  pass
71
73
 
72
- res = fn(*args, **kwargs)
74
+ try:
75
+ res = fn(*args, **kwargs)
76
+ except Exception as e:
77
+ _process_exception(span, e)
78
+ span.end()
79
+ raise e
73
80
 
74
81
  # span will be ended in the generator
75
82
  if isinstance(res, types.GeneratorType):
@@ -131,7 +138,12 @@ def aentity_method(
131
138
  except TypeError:
132
139
  pass
133
140
 
134
- res = await fn(*args, **kwargs)
141
+ try:
142
+ res = await fn(*args, **kwargs)
143
+ except Exception as e:
144
+ _process_exception(span, e)
145
+ span.end()
146
+ raise e
135
147
 
136
148
  # span will be ended in the generator
137
149
  if isinstance(res, types.AsyncGeneratorType):
@@ -177,3 +189,17 @@ def _should_send_prompts():
177
189
  return (
178
190
  os.getenv("TRACELOOP_TRACE_CONTENT") or "true"
179
191
  ).lower() == "true" or context_api.get_value("override_enable_content_tracing")
192
+
193
+
194
+ def _process_exception(span: Span, e: Exception):
195
+ exception_path = [type(e).__module__] if type(e).__module__ != "builtins" else []
196
+ exception_path.append(type(e).__qualname__)
197
+ span.add_event(
198
+ "exception",
199
+ {
200
+ "exception.message": str(e),
201
+ "exception.type": ".".join(exception_path),
202
+ "exception.stacktrace": traceback.format_exc(),
203
+ "exception.escaped": True,
204
+ },
205
+ )
lmnr/sdk/laminar.py CHANGED
@@ -347,6 +347,7 @@ class Laminar:
347
347
 
348
348
  if not cls.is_initialized():
349
349
  yield
350
+ return
350
351
 
351
352
  with get_tracer() as tracer:
352
353
  span_path = get_span_path(name)
lmnr/sdk/types.py CHANGED
@@ -124,7 +124,7 @@ ExecutorFunctionReturnType = Any
124
124
  EvaluatorFunctionReturnType = Union[Numeric, dict[str, Numeric]]
125
125
 
126
126
  ExecutorFunction = Callable[
127
- [EvaluationDatapointData, Any, dict[str, Any]],
127
+ [EvaluationDatapointData, Any],
128
128
  Union[ExecutorFunctionReturnType, Awaitable[ExecutorFunctionReturnType]],
129
129
  ]
130
130
 
@@ -133,7 +133,7 @@ ExecutorFunction = Callable[
133
133
  # record of string keys and number values. The latter is useful for evaluating
134
134
  # multiple criteria in one go instead of running multiple evaluators.
135
135
  EvaluatorFunction = Callable[
136
- [ExecutorFunctionReturnType, Any, dict[str, Any]],
136
+ [ExecutorFunctionReturnType, Any],
137
137
  Union[EvaluatorFunctionReturnType, Awaitable[EvaluatorFunctionReturnType]],
138
138
  ]
139
139
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lmnr
3
- Version: 0.4.42
3
+ Version: 0.4.44
4
4
  Summary: Python SDK for Laminar AI
5
5
  License: Apache-2.0
6
6
  Author: lmnr.ai
@@ -5,7 +5,7 @@ lmnr/openllmetry_sdk/.python-version,sha256=9OLQBQVbD4zE4cJsPePhnAfV_snrPSoqEQw-
5
5
  lmnr/openllmetry_sdk/__init__.py,sha256=vVSGTAwUnJvdulHtslkGAd8QCBuv78WUK3bgfBpH6Do,2390
6
6
  lmnr/openllmetry_sdk/config/__init__.py,sha256=DliMGp2NjYAqRFLKpWQPUKjGMHRO8QsVfazBA1qENQ8,248
7
7
  lmnr/openllmetry_sdk/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- lmnr/openllmetry_sdk/decorators/base.py,sha256=UpOFkiEWEXbfDhJ-wZNzD4GJ9IyIsb13w-mgyUJYPeU,5567
8
+ lmnr/openllmetry_sdk/decorators/base.py,sha256=xwLsUFd5husf3p-ZllVTYEe9gkwl9T3Bf1WpW1-Ua5I,6413
9
9
  lmnr/openllmetry_sdk/instruments.py,sha256=CGGUEELldrXkQwAzAkDeAtDq07_pjhz7i14a92P7C_E,1036
10
10
  lmnr/openllmetry_sdk/tracing/__init__.py,sha256=xT73L1t2si2CM6QmMiTZ7zn-dKKYBLNrpBBWq6WfVBw,68
11
11
  lmnr/openllmetry_sdk/tracing/attributes.py,sha256=h970zmb7yTszzf2oHBfOY3cDYhE6O7LhkiHLqa_7x1k,1261
@@ -22,12 +22,12 @@ lmnr/sdk/datasets.py,sha256=KNMp_v3z1ocIltIw7kTgj8o-l9R8N8Tgj0sw1ajQ9C8,1582
22
22
  lmnr/sdk/decorators.py,sha256=ja2EUWUWvFOp28ER0k78PRuxNahwCVyH0TdM3U-xY7U,1856
23
23
  lmnr/sdk/eval_control.py,sha256=G6Fg3Xx_KWv72iBaWlNMdyRTF2bZFQnwJ68sJNSpIcY,177
24
24
  lmnr/sdk/evaluations.py,sha256=gLImD_uB9uXgw07QiJ_OYRTFDGxiPtFCO1c8HyOq2s0,15935
25
- lmnr/sdk/laminar.py,sha256=rStB42gKOwz8_0HeNZwrFJ23Qk8qC_nHhu9lpdh73cI,30005
25
+ lmnr/sdk/laminar.py,sha256=wCQ-GyJkH58kbazfYfYzZj-oSh-TOZycRIyf2f01v6w,30024
26
26
  lmnr/sdk/log.py,sha256=cZBeUoSK39LMEV-X4-eEhTWOciULRfHaKfRK8YqIM8I,1532
27
- lmnr/sdk/types.py,sha256=fxRslW0IptnAuWCeFyF_jEZUToyi79-du4kyOcqeSfQ,6352
27
+ lmnr/sdk/types.py,sha256=hqaZ8sg97PIrZzmCyEc2uH_g4GKRPIIz4c_LuGlNyHM,6320
28
28
  lmnr/sdk/utils.py,sha256=Uk8y15x-sd5tP2ERONahElLDJVEy_3dA_1_5g9A6auY,3358
29
- lmnr-0.4.42.dist-info/LICENSE,sha256=67b_wJHVV1CBaWkrKFWU1wyqTPSdzH77Ls-59631COg,10411
30
- lmnr-0.4.42.dist-info/METADATA,sha256=dZnXnQNNoYgDnPQGUcaqA9aE2ZPr3wwGFczF-jgGk7Y,12350
31
- lmnr-0.4.42.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
32
- lmnr-0.4.42.dist-info/entry_points.txt,sha256=K1jE20ww4jzHNZLnsfWBvU3YKDGBgbOiYG5Y7ivQcq4,37
33
- lmnr-0.4.42.dist-info/RECORD,,
29
+ lmnr-0.4.44.dist-info/LICENSE,sha256=67b_wJHVV1CBaWkrKFWU1wyqTPSdzH77Ls-59631COg,10411
30
+ lmnr-0.4.44.dist-info/METADATA,sha256=gj3Eu8hQmEXB3azu404wIGU6VUFetHDIemd5f3S2EEE,12350
31
+ lmnr-0.4.44.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
32
+ lmnr-0.4.44.dist-info/entry_points.txt,sha256=K1jE20ww4jzHNZLnsfWBvU3YKDGBgbOiYG5Y7ivQcq4,37
33
+ lmnr-0.4.44.dist-info/RECORD,,
File without changes
File without changes