orca-sdk 0.1.4__py3-none-any.whl → 0.1.6__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.
- orca_sdk/_shared/metrics.py +186 -43
- orca_sdk/_shared/metrics_test.py +99 -6
- orca_sdk/_utils/data_parsing_test.py +1 -1
- orca_sdk/async_client.py +52 -14
- orca_sdk/classification_model.py +107 -30
- orca_sdk/classification_model_test.py +327 -8
- orca_sdk/client.py +52 -14
- orca_sdk/conftest.py +140 -21
- orca_sdk/embedding_model.py +0 -2
- orca_sdk/memoryset.py +141 -26
- orca_sdk/memoryset_test.py +253 -4
- orca_sdk/regression_model.py +73 -16
- orca_sdk/regression_model_test.py +213 -0
- {orca_sdk-0.1.4.dist-info → orca_sdk-0.1.6.dist-info}/METADATA +1 -1
- {orca_sdk-0.1.4.dist-info → orca_sdk-0.1.6.dist-info}/RECORD +16 -16
- {orca_sdk-0.1.4.dist-info → orca_sdk-0.1.6.dist-info}/WHEEL +0 -0
|
@@ -193,6 +193,140 @@ def test_evaluate_with_telemetry(regression_model, eval_dataset: Dataset):
|
|
|
193
193
|
assert all(np.allclose(p.expected_score, s) for p, s in zip(predictions, eval_dataset["score"]))
|
|
194
194
|
|
|
195
195
|
|
|
196
|
+
def test_evaluate_with_partition_column_dataset(partitioned_regression_model: RegressionModel):
|
|
197
|
+
"""Test evaluate with partition_column on a Dataset"""
|
|
198
|
+
# Create a test dataset with partition_id column
|
|
199
|
+
eval_dataset_with_partition = Dataset.from_list(
|
|
200
|
+
[
|
|
201
|
+
{"value": "soup is good", "score": 0.1, "partition_id": "p1"},
|
|
202
|
+
{"value": "cats are cute", "score": 0.9, "partition_id": "p1"},
|
|
203
|
+
{"value": "homemade soup recipes", "score": 0.1, "partition_id": "p2"},
|
|
204
|
+
{"value": "cats purr when happy", "score": 0.9, "partition_id": "p2"},
|
|
205
|
+
]
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
# Evaluate with partition_column
|
|
209
|
+
result = partitioned_regression_model.evaluate(
|
|
210
|
+
eval_dataset_with_partition,
|
|
211
|
+
partition_column="partition_id",
|
|
212
|
+
partition_filter_mode="exclude_global",
|
|
213
|
+
)
|
|
214
|
+
assert result is not None
|
|
215
|
+
assert isinstance(result, RegressionMetrics)
|
|
216
|
+
assert isinstance(result.mae, float)
|
|
217
|
+
assert isinstance(result.mse, float)
|
|
218
|
+
assert isinstance(result.rmse, float)
|
|
219
|
+
assert result.r2 is not None
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def test_evaluate_with_partition_column_include_global(partitioned_regression_model: RegressionModel):
|
|
223
|
+
"""Test evaluate with partition_column and include_global mode"""
|
|
224
|
+
eval_dataset_with_partition = Dataset.from_list(
|
|
225
|
+
[
|
|
226
|
+
{"value": "soup is good", "score": 0.1, "partition_id": "p1"},
|
|
227
|
+
{"value": "cats are cute", "score": 0.9, "partition_id": "p1"},
|
|
228
|
+
]
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
# Evaluate with partition_column and include_global (default)
|
|
232
|
+
result = partitioned_regression_model.evaluate(
|
|
233
|
+
eval_dataset_with_partition,
|
|
234
|
+
partition_column="partition_id",
|
|
235
|
+
partition_filter_mode="include_global",
|
|
236
|
+
)
|
|
237
|
+
assert result is not None
|
|
238
|
+
assert isinstance(result, RegressionMetrics)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def test_evaluate_with_partition_column_exclude_global(partitioned_regression_model: RegressionModel):
|
|
242
|
+
"""Test evaluate with partition_column and exclude_global mode"""
|
|
243
|
+
eval_dataset_with_partition = Dataset.from_list(
|
|
244
|
+
[
|
|
245
|
+
{"value": "soup is good", "score": 0.1, "partition_id": "p1"},
|
|
246
|
+
{"value": "cats are cute", "score": 0.9, "partition_id": "p1"},
|
|
247
|
+
]
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
# Evaluate with partition_column and exclude_global
|
|
251
|
+
result = partitioned_regression_model.evaluate(
|
|
252
|
+
eval_dataset_with_partition,
|
|
253
|
+
partition_column="partition_id",
|
|
254
|
+
partition_filter_mode="exclude_global",
|
|
255
|
+
)
|
|
256
|
+
assert result is not None
|
|
257
|
+
assert isinstance(result, RegressionMetrics)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def test_evaluate_with_partition_column_only_global(partitioned_regression_model: RegressionModel):
|
|
261
|
+
"""Test evaluate with partition_filter_mode only_global"""
|
|
262
|
+
eval_dataset_with_partition = Dataset.from_list(
|
|
263
|
+
[
|
|
264
|
+
{"value": "cats are independent animals", "score": 0.9, "partition_id": None},
|
|
265
|
+
{"value": "i love the beach", "score": 0.5, "partition_id": None},
|
|
266
|
+
]
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
# Evaluate with only_global mode
|
|
270
|
+
result = partitioned_regression_model.evaluate(
|
|
271
|
+
eval_dataset_with_partition,
|
|
272
|
+
partition_column="partition_id",
|
|
273
|
+
partition_filter_mode="only_global",
|
|
274
|
+
)
|
|
275
|
+
assert result is not None
|
|
276
|
+
assert isinstance(result, RegressionMetrics)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def test_evaluate_with_partition_column_ignore_partitions(partitioned_regression_model: RegressionModel):
|
|
280
|
+
"""Test evaluate with partition_filter_mode ignore_partitions"""
|
|
281
|
+
eval_dataset_with_partition = Dataset.from_list(
|
|
282
|
+
[
|
|
283
|
+
{"value": "soup is good", "score": 0.1, "partition_id": "p1"},
|
|
284
|
+
{"value": "cats are cute", "score": 0.9, "partition_id": "p2"},
|
|
285
|
+
]
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
# Evaluate with ignore_partitions mode
|
|
289
|
+
result = partitioned_regression_model.evaluate(
|
|
290
|
+
eval_dataset_with_partition,
|
|
291
|
+
partition_column="partition_id",
|
|
292
|
+
partition_filter_mode="ignore_partitions",
|
|
293
|
+
)
|
|
294
|
+
assert result is not None
|
|
295
|
+
assert isinstance(result, RegressionMetrics)
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
@pytest.mark.parametrize("data_type", ["dataset", "datasource"])
|
|
299
|
+
def test_evaluate_with_partition_column_datasource(partitioned_regression_model: RegressionModel, data_type):
|
|
300
|
+
"""Test evaluate with partition_column on a Datasource"""
|
|
301
|
+
# Create a test datasource with partition_id column
|
|
302
|
+
eval_data_with_partition = [
|
|
303
|
+
{"value": "soup is good", "score": 0.1, "partition_id": "p1"},
|
|
304
|
+
{"value": "cats are cute", "score": 0.9, "partition_id": "p1"},
|
|
305
|
+
{"value": "homemade soup recipes", "score": 0.1, "partition_id": "p2"},
|
|
306
|
+
{"value": "cats purr when happy", "score": 0.9, "partition_id": "p2"},
|
|
307
|
+
]
|
|
308
|
+
|
|
309
|
+
if data_type == "dataset":
|
|
310
|
+
eval_data = Dataset.from_list(eval_data_with_partition)
|
|
311
|
+
result = partitioned_regression_model.evaluate(
|
|
312
|
+
eval_data,
|
|
313
|
+
partition_column="partition_id",
|
|
314
|
+
partition_filter_mode="exclude_global",
|
|
315
|
+
)
|
|
316
|
+
else:
|
|
317
|
+
eval_datasource = Datasource.from_list("eval_datasource_with_partition_regression", eval_data_with_partition)
|
|
318
|
+
result = partitioned_regression_model.evaluate(
|
|
319
|
+
eval_datasource,
|
|
320
|
+
partition_column="partition_id",
|
|
321
|
+
partition_filter_mode="exclude_global",
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
assert result is not None
|
|
325
|
+
assert isinstance(result, RegressionMetrics)
|
|
326
|
+
assert isinstance(result.mae, float)
|
|
327
|
+
assert isinstance(result.mse, float)
|
|
328
|
+
|
|
329
|
+
|
|
196
330
|
def test_predict(regression_model: RegressionModel):
|
|
197
331
|
predictions = regression_model.predict(["Do you love soup?", "Are cats cute?"])
|
|
198
332
|
assert len(predictions) == 2
|
|
@@ -248,6 +382,85 @@ def test_predict_with_prompt(regression_model: RegressionModel):
|
|
|
248
382
|
assert 0 <= prediction_without_prompt.confidence <= 1
|
|
249
383
|
|
|
250
384
|
|
|
385
|
+
def test_predict_with_partition_id(partitioned_regression_model: RegressionModel):
|
|
386
|
+
"""Test predict with a specific partition_id"""
|
|
387
|
+
# Predict with partition_id p1 - should use memories from p1
|
|
388
|
+
prediction = partitioned_regression_model.predict("soup", partition_id="p1", partition_filter_mode="exclude_global")
|
|
389
|
+
assert prediction.score is not None
|
|
390
|
+
assert 0 <= prediction.confidence <= 1
|
|
391
|
+
|
|
392
|
+
# Predict with partition_id p2 - should use memories from p2
|
|
393
|
+
prediction_p2 = partitioned_regression_model.predict(
|
|
394
|
+
"cats", partition_id="p2", partition_filter_mode="exclude_global"
|
|
395
|
+
)
|
|
396
|
+
assert prediction_p2.score is not None
|
|
397
|
+
assert 0 <= prediction_p2.confidence <= 1
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
def test_predict_with_partition_id_include_global(partitioned_regression_model: RegressionModel):
|
|
401
|
+
"""Test predict with partition_id and include_global mode (default)"""
|
|
402
|
+
# Predict with partition_id p1 and include_global (default) - should include both p1 and global memories
|
|
403
|
+
prediction = partitioned_regression_model.predict("soup", partition_id="p1", partition_filter_mode="include_global")
|
|
404
|
+
assert prediction.score is not None
|
|
405
|
+
assert 0 <= prediction.confidence <= 1
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def test_predict_with_partition_id_exclude_global(partitioned_regression_model: RegressionModel):
|
|
409
|
+
"""Test predict with partition_id and exclude_global mode"""
|
|
410
|
+
# Predict with partition_id p1 and exclude_global - should only use p1 memories
|
|
411
|
+
prediction = partitioned_regression_model.predict("soup", partition_id="p1", partition_filter_mode="exclude_global")
|
|
412
|
+
assert prediction.score is not None
|
|
413
|
+
assert 0 <= prediction.confidence <= 1
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def test_predict_with_partition_id_only_global(partitioned_regression_model: RegressionModel):
|
|
417
|
+
"""Test predict with partition_filter_mode only_global"""
|
|
418
|
+
# Predict with only_global mode - should only use global memories
|
|
419
|
+
prediction = partitioned_regression_model.predict("cats", partition_filter_mode="only_global")
|
|
420
|
+
assert prediction.score is not None
|
|
421
|
+
assert 0 <= prediction.confidence <= 1
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def test_predict_with_partition_id_ignore_partitions(partitioned_regression_model: RegressionModel):
|
|
425
|
+
"""Test predict with partition_filter_mode ignore_partitions"""
|
|
426
|
+
# Predict with ignore_partitions mode - should ignore partition filtering
|
|
427
|
+
prediction = partitioned_regression_model.predict("soup", partition_filter_mode="ignore_partitions")
|
|
428
|
+
assert prediction.score is not None
|
|
429
|
+
assert 0 <= prediction.confidence <= 1
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
def test_predict_batch_with_partition_id(partitioned_regression_model: RegressionModel):
|
|
433
|
+
"""Test batch predict with partition_id"""
|
|
434
|
+
# Batch predict with partition_id p1
|
|
435
|
+
predictions = partitioned_regression_model.predict(
|
|
436
|
+
["soup is good", "cats are cute"],
|
|
437
|
+
partition_id="p1",
|
|
438
|
+
partition_filter_mode="exclude_global",
|
|
439
|
+
)
|
|
440
|
+
assert len(predictions) == 2
|
|
441
|
+
assert all(p.score is not None for p in predictions)
|
|
442
|
+
assert all(0 <= p.confidence <= 1 for p in predictions)
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
def test_predict_batch_with_list_of_partition_ids(partitioned_regression_model: RegressionModel):
|
|
446
|
+
"""Test batch predict with a list of partition_ids (one for each query input)"""
|
|
447
|
+
# Batch predict with a list of partition_ids - one for each input
|
|
448
|
+
# First input uses p1, second input uses p2
|
|
449
|
+
predictions = partitioned_regression_model.predict(
|
|
450
|
+
["soup is good", "cats are cute"],
|
|
451
|
+
partition_id=["p1", "p2"],
|
|
452
|
+
partition_filter_mode="exclude_global",
|
|
453
|
+
)
|
|
454
|
+
assert len(predictions) == 2
|
|
455
|
+
assert all(p.score is not None for p in predictions)
|
|
456
|
+
assert all(0 <= p.confidence <= 1 for p in predictions)
|
|
457
|
+
|
|
458
|
+
# Verify that predictions were made using the correct partitions
|
|
459
|
+
# Each prediction should use memories from its respective partition
|
|
460
|
+
assert predictions[0].input_value == "soup is good"
|
|
461
|
+
assert predictions[1].input_value == "cats are cute"
|
|
462
|
+
|
|
463
|
+
|
|
251
464
|
def test_record_prediction_feedback(regression_model: RegressionModel):
|
|
252
465
|
predictions = regression_model.predict(["This is excellent!", "This is terrible!"])
|
|
253
466
|
expected_scores = [0.9, 0.1]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
orca_sdk/__init__.py,sha256=xyjNwkLQXaX8A-UYgGwYDjv2btOXArT_yiMTfmW7KA8,1003
|
|
2
2
|
orca_sdk/_shared/__init__.py,sha256=3Kt0Hu3QLI5FEp9nqGTxqAm3hAoBJKcagfaGQZ-lbJQ,223
|
|
3
|
-
orca_sdk/_shared/metrics.py,sha256=
|
|
4
|
-
orca_sdk/_shared/metrics_test.py,sha256=
|
|
3
|
+
orca_sdk/_shared/metrics.py,sha256=a_FdsPGDjR3CMOEBaEhEBqMfWUg7sqz9Jeh26XzAeg0,19756
|
|
4
|
+
orca_sdk/_shared/metrics_test.py,sha256=n7eEAT8e6RqbI94ftEDljTBzOuh-YkFpXfF3DOoZA10,12905
|
|
5
5
|
orca_sdk/_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
orca_sdk/_utils/analysis_ui.py,sha256=nT-M_YcNRCVPQzvuqYNFKnNHhYkADYBvq1GlIUePrWw,9232
|
|
7
7
|
orca_sdk/_utils/analysis_ui_style.css,sha256=q_ba_-_KtgztepHg829zLzypaxKayl7ySC1-oYDzV3k,836
|
|
@@ -9,7 +9,7 @@ orca_sdk/_utils/auth.py,sha256=nC252O171_3_wn4KBAN7kg8GNvoZFiQ5Xtzkrm5dWDo,2645
|
|
|
9
9
|
orca_sdk/_utils/auth_test.py,sha256=ygVWv1Ex53LaxIP7p2hzPHl8l9qYyBD5IGmEFJMps6s,1056
|
|
10
10
|
orca_sdk/_utils/common.py,sha256=wUm2pNDWytEecC5WiDWd02-yCZw3Akx0bIutG4lHsFA,805
|
|
11
11
|
orca_sdk/_utils/data_parsing.py,sha256=gkAwWEC8qRt3vRUObe7n7Pr0azOayNwc2yFY04WFp7E,5220
|
|
12
|
-
orca_sdk/_utils/data_parsing_test.py,sha256=
|
|
12
|
+
orca_sdk/_utils/data_parsing_test.py,sha256=mJIPDOfs9fTsrQO_oMGonVAtNCA3_gcw_3qSmOX5Q4g,8978
|
|
13
13
|
orca_sdk/_utils/pagination.py,sha256=986z0QPZixrZeurJWorF6eMgnTRdDF84AagEA6qNbMw,4245
|
|
14
14
|
orca_sdk/_utils/pagination_test.py,sha256=BUylCrcHnwoKEBmMUzVr0lwLpA35ivcCwdBK4rMw9y8,4887
|
|
15
15
|
orca_sdk/_utils/prediction_result_ui.css,sha256=sqBlkRLnovb5X5EcUDdB6iGpH63nVRlTW4uAmXuD0WM,258
|
|
@@ -17,25 +17,25 @@ orca_sdk/_utils/prediction_result_ui.py,sha256=Ur_FY7dz3oWNmtPiP3Wl3yRlEMgK8q9Uf
|
|
|
17
17
|
orca_sdk/_utils/tqdm_file_reader.py,sha256=Lw7Cg1UgNuRUoN6jjqZb-IlV00H-kbRcrZLdudr1GxE,324
|
|
18
18
|
orca_sdk/_utils/value_parser.py,sha256=c3qMABCCDQcIjn9N1orYYnlRwDW9JWdGwW_2TDZPLdI,1286
|
|
19
19
|
orca_sdk/_utils/value_parser_test.py,sha256=OybsiC-Obi32RRi9NIuwrVBRAnlyPMV1xVAaevSrb7M,1079
|
|
20
|
-
orca_sdk/async_client.py,sha256=
|
|
21
|
-
orca_sdk/classification_model.py,sha256=
|
|
22
|
-
orca_sdk/classification_model_test.py,sha256=
|
|
23
|
-
orca_sdk/client.py,sha256=
|
|
24
|
-
orca_sdk/conftest.py,sha256=
|
|
20
|
+
orca_sdk/async_client.py,sha256=y2D3fPQZmbwmtYWAk5acJ45atSZen9MNfjP2tKjpP6Q,132737
|
|
21
|
+
orca_sdk/classification_model.py,sha256=4AcQvAm0EN7w0qx0WpgEs7VUoIIPTqIVE86wtkaIAYs,46249
|
|
22
|
+
orca_sdk/classification_model_test.py,sha256=vBn7KBb9-ACuJEdzW50n54Fn6Mh9iEYbn1197lE8-yI,36997
|
|
23
|
+
orca_sdk/client.py,sha256=oQd8Lm0agetLyAdVRP8IZqe6S5mjxhFSnbVHqhT7dmI,131798
|
|
24
|
+
orca_sdk/conftest.py,sha256=0O1VY-SPKNAvi9fBLdY1RMnYVgZvMjP92y99bNAqqiw,12461
|
|
25
25
|
orca_sdk/credentials.py,sha256=80_1r8n5jruEvN_E629SaRrRhKvF_NhWUEZyZzPXkqQ,6620
|
|
26
26
|
orca_sdk/credentials_test.py,sha256=TLbXJMz3IlThvtSrHeLM7jRsKnrncA_ahOTpHg15Ei4,4089
|
|
27
27
|
orca_sdk/datasource.py,sha256=6QaccghiyFEUSFcqnwjIJzpgIh9Id0snJk2EqViqPsU,22356
|
|
28
28
|
orca_sdk/datasource_test.py,sha256=sCk3IcQJbDut5oN4Wf7PXhTxyMwalxMuCXJekSxy9wk,16665
|
|
29
|
-
orca_sdk/embedding_model.py,sha256=
|
|
29
|
+
orca_sdk/embedding_model.py,sha256=4xxfo26b5X_YJtU8KyqoMmJQ6VgfHEcYftVSz-RfDng,27920
|
|
30
30
|
orca_sdk/embedding_model_test.py,sha256=-NItbNb3tTVj5jAvSi3WjV3FP448q08lmT5iObg9vwA,8133
|
|
31
31
|
orca_sdk/job.py,sha256=wHwVt-s7i-v8udhLGybB-90Kp4dwOLrY806bE4Tam5Q,13092
|
|
32
32
|
orca_sdk/job_test.py,sha256=nRSWxd_1UIfrj9oMVvrXjt6OBkBpddYAjb2y6P-DTUg,4327
|
|
33
|
-
orca_sdk/memoryset.py,sha256=
|
|
34
|
-
orca_sdk/memoryset_test.py,sha256=
|
|
35
|
-
orca_sdk/regression_model.py,sha256=
|
|
36
|
-
orca_sdk/regression_model_test.py,sha256=
|
|
33
|
+
orca_sdk/memoryset.py,sha256=OtIZH14bN7tejevdsHJpBeje5Ovc58vtkw1inRMWdw4,117709
|
|
34
|
+
orca_sdk/memoryset_test.py,sha256=YrMP_Z7BPhKAIZq1FKar83dNzR_2b56A89pnEiUbRrs,46509
|
|
35
|
+
orca_sdk/regression_model.py,sha256=vXdY2Fbfc0MyECUR3fa_IR-nETPrDN7VFAdjvsgHPrs,31382
|
|
36
|
+
orca_sdk/regression_model_test.py,sha256=DfWLkqxB835jjwM-sj1uxQ6Yz_ZBMnt8EHjdfnHsRnU,25103
|
|
37
37
|
orca_sdk/telemetry.py,sha256=ZyCMiyyo_SchjadWZH55TlLrC4Ucq5S316NbW26LL4Y,27834
|
|
38
38
|
orca_sdk/telemetry_test.py,sha256=eT66C5lFdNg-pQdo2I__BP7Tn5fTc9aTkVo9ZhWwhU0,5519
|
|
39
|
-
orca_sdk-0.1.
|
|
40
|
-
orca_sdk-0.1.
|
|
41
|
-
orca_sdk-0.1.
|
|
39
|
+
orca_sdk-0.1.6.dist-info/METADATA,sha256=85QDZDP9Uxda4oZ3BMPP_kI5T4GPy1mFMYtWh1-nI54,3659
|
|
40
|
+
orca_sdk-0.1.6.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
41
|
+
orca_sdk-0.1.6.dist-info/RECORD,,
|
|
File without changes
|