lmnr 0.4.2__py3-none-any.whl → 0.4.3__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.
lmnr/sdk/evaluations.py CHANGED
@@ -105,59 +105,58 @@ class Evaluation:
105
105
  and then evaluate it by each evaluator function.
106
106
  """
107
107
  response = L.create_evaluation(self.name)
108
- batch_promises = []
109
108
 
109
+ # Process batches sequentially
110
110
  for i in range(0, len(self.data), self.batch_size):
111
111
  batch = (
112
112
  self.data[i : i + self.batch_size]
113
113
  if isinstance(self.data, list)
114
114
  else self.data.slice(i, i + self.batch_size)
115
115
  )
116
- batch_promises.append(self._evaluate_batch(batch))
116
+ try:
117
+ await self._evaluate_batch(batch)
118
+ except Exception as e:
119
+ print(f"Error evaluating batch: {e}")
117
120
 
118
121
  try:
119
- await asyncio.gather(*batch_promises)
120
122
  L.update_evaluation_status(response.name, "Finished")
121
123
  print(f"Evaluation {response.id} complete")
122
124
  except Exception as e:
123
- print(f"Error evaluating batch: {e}")
125
+ print(f"Error updating evaluation status: {e}")
124
126
 
125
127
  async def _evaluate_batch(self, batch: list[EvaluationDatapoint]):
126
- results = []
127
- for datapoint in batch:
128
- output = (
129
- await self.executor(datapoint.data)
130
- if is_async(self.executor)
131
- else self.executor(datapoint.data)
132
- )
133
- target = datapoint.target
134
-
135
- # iterate in order of evaluators
136
- scores = {}
137
- for evaluator_name in self.evaluator_names:
138
- evaluator = self.evaluators[evaluator_name]
139
- value = (
140
- await evaluator(output, target)
141
- if is_async(evaluator)
142
- else evaluator(output, target)
143
- )
128
+ batch_promises = [self._evaluate_datapoint(datapoint) for datapoint in batch]
129
+ results = await asyncio.gather(*batch_promises)
130
+
131
+ return L.post_evaluation_results(self.name, results)
144
132
 
145
- # if the evaluator returns a single number,
146
- # use the evaluator name as the key
147
- if isinstance(value, Numeric):
148
- scores[evaluator_name] = value
149
- else:
150
- # if the evaluator returns an object,
151
- # use the object keys as the keys
152
- scores.update(value)
153
-
154
- results.append(
155
- {
156
- "executorOutput": output,
157
- "data": datapoint.data,
158
- "target": target,
159
- "scores": scores,
160
- }
133
+ async def _evaluate_datapoint(self, datapoint):
134
+ output = (
135
+ await self.executor(datapoint.data)
136
+ if asyncio.iscoroutinefunction(self.executor)
137
+ else self.executor(datapoint.data)
138
+ )
139
+ target = datapoint.target
140
+
141
+ # Iterate over evaluators
142
+ scores = {}
143
+ for evaluator_name in self.evaluator_names:
144
+ evaluator = self.evaluators[evaluator_name]
145
+ value = (
146
+ await evaluator(output, target)
147
+ if asyncio.iscoroutinefunction(evaluator)
148
+ else evaluator(output, target)
161
149
  )
162
150
 
163
- return L.post_evaluation_results(self.name, results)
151
+ # If evaluator returns a single number, use evaluator name as key
152
+ if isinstance(value, (int, float)):
153
+ scores[evaluator_name] = value
154
+ else:
155
+ scores.update(value)
156
+
157
+ return {
158
+ "executorOutput": output,
159
+ "data": datapoint.data,
160
+ "target": target,
161
+ "scores": scores,
162
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lmnr
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Python SDK for Laminar AI
5
5
  License: Apache-2.0
6
6
  Author: lmnr.ai
@@ -1,13 +1,13 @@
1
1
  lmnr/__init__.py,sha256=wQwnHl662Xcz7GdSofFsEjmAK0nxioYA2Yq6Q78m4ps,194
2
2
  lmnr/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  lmnr/sdk/decorators.py,sha256=Xs6n0TGX9LZ9i1hE_UZz4LEyd_ZAfpVGfNQh_rKwOuA,2493
4
- lmnr/sdk/evaluations.py,sha256=LkQApHAhR7y_rC2ovnJi8yHpdcl0-7yesdBqvOJ0BKg,6107
4
+ lmnr/sdk/evaluations.py,sha256=jdXWRJyr17iAWva8Vyvn8yT-rZAoQ8Xz0QQ_zzfPwvY,6044
5
5
  lmnr/sdk/laminar.py,sha256=pMgWugFvzqYaEf1TRIjfFl_yo17GdOGGagnPBEA8nHQ,16520
6
6
  lmnr/sdk/log.py,sha256=EgAMY77Zn1bv1imCqrmflD3imoAJ2yveOkIcrIP3e98,1170
7
7
  lmnr/sdk/types.py,sha256=gDwRSWR9A1__FGtQhVaFc6PUYQuIhubo5tpfYAajTQQ,4055
8
8
  lmnr/sdk/utils.py,sha256=ZsGJ86tq8lIbvOhSb1gJWH5K3GylO_lgX68FN6rG2nM,3358
9
- lmnr-0.4.2.dist-info/LICENSE,sha256=67b_wJHVV1CBaWkrKFWU1wyqTPSdzH77Ls-59631COg,10411
10
- lmnr-0.4.2.dist-info/METADATA,sha256=92uFLKPcVAJBbWApMCY8-Mmj--ks5yXdy4Ce1jHss18,7025
11
- lmnr-0.4.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
- lmnr-0.4.2.dist-info/entry_points.txt,sha256=Qg7ZRax4k-rcQsZ26XRYQ8YFSBiyY2PNxYfq4a6PYXI,41
13
- lmnr-0.4.2.dist-info/RECORD,,
9
+ lmnr-0.4.3.dist-info/LICENSE,sha256=67b_wJHVV1CBaWkrKFWU1wyqTPSdzH77Ls-59631COg,10411
10
+ lmnr-0.4.3.dist-info/METADATA,sha256=woC24QpLILvRBtLdwCktKJydeiPXEOH8LBb7CSAnw4I,7025
11
+ lmnr-0.4.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
+ lmnr-0.4.3.dist-info/entry_points.txt,sha256=Qg7ZRax4k-rcQsZ26XRYQ8YFSBiyY2PNxYfq4a6PYXI,41
13
+ lmnr-0.4.3.dist-info/RECORD,,
File without changes
File without changes