From 73c30676b1e49e2355cffd232305c5aab1a0b309 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:58:06 +0000 Subject: [PATCH 1/6] chore(internal): version bump (#284) --- scripts/mock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mock b/scripts/mock index f5861576..fe89a1d0 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" &> .prism.log & # Wait for server to come online echo -n "Waiting for server" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" + npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" fi From 3c0fcbbe9199b68ef5bc92247df751bfd4ae3649 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:58:27 +0000 Subject: [PATCH 2/6] chore(tests): update prism version (#285) --- scripts/mock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mock b/scripts/mock index fe89a1d0..f5861576 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" &> .prism.log & # Wait for server to come online echo -n "Waiting for server" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" + npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" fi From 39fbda1bcaacbd8546926e7d32b7fc2ae1ad058e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:02:53 +0000 Subject: [PATCH 3/6] chore(internal): add type construction helper (#287) --- src/openlayer/_models.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/openlayer/_models.py b/src/openlayer/_models.py index eb7ce3bd..5148d5a7 100644 --- a/src/openlayer/_models.py +++ b/src/openlayer/_models.py @@ -406,6 +406,15 @@ def build( return cast(_BaseModelT, construct_type(type_=base_model_cls, value=kwargs)) +def construct_type_unchecked(*, value: object, type_: type[_T]) -> _T: + """Loose coercion to the expected type with construction of nested values. + + Note: the returned value from this function is not guaranteed to match the + given type. + """ + return cast(_T, construct_type(value=value, type_=type_)) + + def construct_type(*, value: object, type_: object) -> object: """Loose coercion to the expected type with construction of nested values. From a8f3d8246c75ff8ebff8f5e92212044fd3433d47 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Wed, 31 Jul 2024 17:10:18 +0000 Subject: [PATCH 4/6] feat: improvement: include method to update batch of inferences --- src/openlayer/lib/data/__init__.py | 9 ++++++-- src/openlayer/lib/data/batch_inferences.py | 25 ++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/openlayer/lib/data/__init__.py b/src/openlayer/lib/data/__init__.py index 4df22112..89cdc091 100644 --- a/src/openlayer/lib/data/__init__.py +++ b/src/openlayer/lib/data/__init__.py @@ -1,7 +1,12 @@ """Data upload functions.""" -__all__ = ["StorageType", "upload_reference_dataframe", "upload_batch_inferences"] +__all__ = [ + "StorageType", + "upload_reference_dataframe", + "upload_batch_inferences", + "update_batch_inferences", +] from ._upload import StorageType +from .batch_inferences import update_batch_inferences, upload_batch_inferences from .reference_dataset import upload_reference_dataframe -from .batch_inferences import upload_batch_inferences diff --git a/src/openlayer/lib/data/batch_inferences.py b/src/openlayer/lib/data/batch_inferences.py index 99699c14..6b1eeffa 100644 --- a/src/openlayer/lib/data/batch_inferences.py +++ b/src/openlayer/lib/data/batch_inferences.py @@ -5,8 +5,8 @@ import tempfile import time from typing import Optional -import httpx +import httpx import pandas as pd from ... import Openlayer @@ -22,6 +22,7 @@ def upload_batch_inferences( dataset_df: pd.DataFrame, config: data_stream_params.Config, storage_type: Optional[StorageType] = None, + merge: bool = False, ) -> None: """Uploads a batch of inferences to the Openlayer platform.""" uploader = _upload.Uploader(client, storage_type) @@ -61,6 +62,26 @@ def upload_batch_inferences( cast_to=httpx.Response, body={ "storageUri": presigned_url_response.storage_uri, - "performDataMerge": False, + "performDataMerge": merge, }, ) + + +def update_batch_inferences( + client: Openlayer, + inference_pipeline_id: str, + dataset_df: pd.DataFrame, + config: data_stream_params.Config, + storage_type: Optional[StorageType] = None, +) -> None: + """Updates a batch of inferences on the Openlayer platform.""" + if config["inference_id_column_name"] is None: + raise ValueError("inference_id_column_name must be set in config") + upload_batch_inferences( + client=client, + inference_pipeline_id=inference_pipeline_id, + dataset_df=dataset_df, + config=config, + storage_type=storage_type, + merge=True, + ) From a4d126f2c0b3bdf67fefbb06fb3ffa9107ea1387 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Wed, 31 Jul 2024 17:10:19 +0000 Subject: [PATCH 5/6] feat: improvement: allow specifying dataset as path for uploads --- src/openlayer/lib/data/batch_inferences.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/openlayer/lib/data/batch_inferences.py b/src/openlayer/lib/data/batch_inferences.py index 6b1eeffa..f796a466 100644 --- a/src/openlayer/lib/data/batch_inferences.py +++ b/src/openlayer/lib/data/batch_inferences.py @@ -19,12 +19,18 @@ def upload_batch_inferences( client: Openlayer, inference_pipeline_id: str, - dataset_df: pd.DataFrame, config: data_stream_params.Config, + dataset_df: Optional[pd.DataFrame] = None, + dataset_path: Optional[str] = None, storage_type: Optional[StorageType] = None, merge: bool = False, ) -> None: """Uploads a batch of inferences to the Openlayer platform.""" + if dataset_df is None and dataset_path is None: + raise ValueError("Either dataset_df or dataset_path must be provided.") + if dataset_df is not None and dataset_path is not None: + raise ValueError("Only one of dataset_df or dataset_path should be provided.") + uploader = _upload.Uploader(client, storage_type) object_name = f"batch_data_{time.time()}_{inference_pipeline_id}.tar.gz" @@ -35,8 +41,11 @@ def upload_batch_inferences( # Write dataset and config to temp directory with tempfile.TemporaryDirectory() as tmp_dir: - temp_file_path = f"{tmp_dir}/dataset.csv" - dataset_df.to_csv(temp_file_path, index=False) + if dataset_df is not None: + temp_file_path = f"{tmp_dir}/dataset.csv" + dataset_df.to_csv(temp_file_path, index=False) + else: + temp_file_path = dataset_path # Copy relevant files to tmp dir config["label"] = "production" @@ -47,7 +56,11 @@ def upload_batch_inferences( tar_file_path = os.path.join(tmp_dir, object_name) with tarfile.open(tar_file_path, mode="w:gz") as tar: - tar.add(tmp_dir, arcname=os.path.basename("monitoring_data")) + tar.add(temp_file_path, arcname=os.path.basename("dataset.csv")) + tar.add( + f"{tmp_dir}/dataset_config.yaml", + arcname=os.path.basename("dataset_config.yaml"), + ) # Upload to storage uploader.upload( From cb511cfe8d8d10033ea68e0665076572ce8ddac7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 31 Jul 2024 17:10:35 +0000 Subject: [PATCH 6/6] release: 0.2.0-alpha.15 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 16 ++++++++++++++++ pyproject.toml | 2 +- src/openlayer/_version.py | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 929f7775..a72db4d7 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.2.0-alpha.14" + ".": "0.2.0-alpha.15" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a999c6a..cf1967af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Removed * Deprecated and removed `publish_ground_truths` method. Use `update_data` instead. +## 0.2.0-alpha.15 (2024-07-31) + +Full Changelog: [v0.2.0-alpha.14...v0.2.0-alpha.15](https://github.com/openlayer-ai/openlayer-python/compare/v0.2.0-alpha.14...v0.2.0-alpha.15) + +### Features + +* improvement: allow specifying dataset as path for uploads ([a4d126f](https://github.com/openlayer-ai/openlayer-python/commit/a4d126f2c0b3bdf67fefbb06fb3ffa9107ea1387)) +* improvement: include method to update batch of inferences ([a8f3d82](https://github.com/openlayer-ai/openlayer-python/commit/a8f3d8246c75ff8ebff8f5e92212044fd3433d47)) + + +### Chores + +* **internal:** add type construction helper ([#287](https://github.com/openlayer-ai/openlayer-python/issues/287)) ([39fbda1](https://github.com/openlayer-ai/openlayer-python/commit/39fbda1bcaacbd8546926e7d32b7fc2ae1ad058e)) +* **internal:** version bump ([#284](https://github.com/openlayer-ai/openlayer-python/issues/284)) ([73c3067](https://github.com/openlayer-ai/openlayer-python/commit/73c30676b1e49e2355cffd232305c5aab1a0b309)) +* **tests:** update prism version ([#285](https://github.com/openlayer-ai/openlayer-python/issues/285)) ([3c0fcbb](https://github.com/openlayer-ai/openlayer-python/commit/3c0fcbbe9199b68ef5bc92247df751bfd4ae3649)) + ## 0.2.0-alpha.14 (2024-07-29) Full Changelog: [v0.2.0-alpha.13...v0.2.0-alpha.14](https://github.com/openlayer-ai/openlayer-python/compare/v0.2.0-alpha.13...v0.2.0-alpha.14) diff --git a/pyproject.toml b/pyproject.toml index 1f142618..18050322 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openlayer" -version = "0.2.0-alpha.14" +version = "0.2.0-alpha.15" description = "The official Python library for the openlayer API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/openlayer/_version.py b/src/openlayer/_version.py index 4e11865a..b6450f0c 100644 --- a/src/openlayer/_version.py +++ b/src/openlayer/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "openlayer" -__version__ = "0.2.0-alpha.14" # x-release-please-version +__version__ = "0.2.0-alpha.15" # x-release-please-version