Skip to content

Commit a8f3d82

Browse files
author
Stainless Bot
committed
feat: improvement: include method to update batch of inferences
1 parent 39fbda1 commit a8f3d82

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/openlayer/lib/data/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
"""Data upload functions."""
22

3-
__all__ = ["StorageType", "upload_reference_dataframe", "upload_batch_inferences"]
3+
__all__ = [
4+
"StorageType",
5+
"upload_reference_dataframe",
6+
"upload_batch_inferences",
7+
"update_batch_inferences",
8+
]
49

510
from ._upload import StorageType
11+
from .batch_inferences import update_batch_inferences, upload_batch_inferences
612
from .reference_dataset import upload_reference_dataframe
7-
from .batch_inferences import upload_batch_inferences

src/openlayer/lib/data/batch_inferences.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import tempfile
66
import time
77
from typing import Optional
8-
import httpx
98

9+
import httpx
1010
import pandas as pd
1111

1212
from ... import Openlayer
@@ -22,6 +22,7 @@ def upload_batch_inferences(
2222
dataset_df: pd.DataFrame,
2323
config: data_stream_params.Config,
2424
storage_type: Optional[StorageType] = None,
25+
merge: bool = False,
2526
) -> None:
2627
"""Uploads a batch of inferences to the Openlayer platform."""
2728
uploader = _upload.Uploader(client, storage_type)
@@ -61,6 +62,26 @@ def upload_batch_inferences(
6162
cast_to=httpx.Response,
6263
body={
6364
"storageUri": presigned_url_response.storage_uri,
64-
"performDataMerge": False,
65+
"performDataMerge": merge,
6566
},
6667
)
68+
69+
70+
def update_batch_inferences(
71+
client: Openlayer,
72+
inference_pipeline_id: str,
73+
dataset_df: pd.DataFrame,
74+
config: data_stream_params.Config,
75+
storage_type: Optional[StorageType] = None,
76+
) -> None:
77+
"""Updates a batch of inferences on the Openlayer platform."""
78+
if config["inference_id_column_name"] is None:
79+
raise ValueError("inference_id_column_name must be set in config")
80+
upload_batch_inferences(
81+
client=client,
82+
inference_pipeline_id=inference_pipeline_id,
83+
dataset_df=dataset_df,
84+
config=config,
85+
storage_type=storage_type,
86+
merge=True,
87+
)

0 commit comments

Comments
 (0)