diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 2635f9da..060b9499 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.2.0-alpha.69" + ".": "0.2.0-alpha.70" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b8ba6d73..288ae0af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 0.2.0-alpha.70 (2025-07-15) + +Full Changelog: [v0.2.0-alpha.69...v0.2.0-alpha.70](https://github.com/openlayer-ai/openlayer-python/compare/v0.2.0-alpha.69...v0.2.0-alpha.70) + +### Features + +* clean up environment call outs ([57e6088](https://github.com/openlayer-ai/openlayer-python/commit/57e6088bf5615a33655cc0cdaf652e99024ad70b)) + + +### Bug Fixes + +* **client:** don't send Content-Type header on GET requests ([f8aaafa](https://github.com/openlayer-ai/openlayer-python/commit/f8aaafab8099d2142c6a3a599fc2d09202b56ef7)) +* print successful data streaming ([496f9c4](https://github.com/openlayer-ai/openlayer-python/commit/496f9c48d061db0f68308d2f5959f55fa7cec878)) + ## 0.2.0-alpha.69 (2025-07-11) Full Changelog: [v0.2.0-alpha.68...v0.2.0-alpha.69](https://github.com/openlayer-ai/openlayer-python/compare/v0.2.0-alpha.68...v0.2.0-alpha.69) diff --git a/README.md b/README.md index 00345595..58e65627 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,6 @@ pip install --pre openlayer[aiohttp] Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`: ```python -import os import asyncio from openlayer import DefaultAioHttpClient from openlayer import AsyncOpenlayer @@ -123,7 +122,7 @@ from openlayer import AsyncOpenlayer async def main() -> None: async with AsyncOpenlayer( - api_key=os.environ.get("OPENLAYER_API_KEY"), # This is the default and can be omitted + api_key="My API Key", http_client=DefaultAioHttpClient(), ) as client: response = await client.inference_pipelines.data.stream( diff --git a/pyproject.toml b/pyproject.toml index 5f8a9b03..49b0140d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openlayer" -version = "0.2.0-alpha.69" +version = "0.2.0-alpha.70" description = "The official Python library for the openlayer API" dynamic = ["readme"] license = "Apache-2.0" @@ -45,7 +45,7 @@ Homepage = "https://github.com/openlayer-ai/openlayer-python" Repository = "https://github.com/openlayer-ai/openlayer-python" [project.optional-dependencies] -aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.6"] +aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.8"] [tool.rye] managed = true diff --git a/src/openlayer/_base_client.py b/src/openlayer/_base_client.py index e73f4f31..bea13ab1 100644 --- a/src/openlayer/_base_client.py +++ b/src/openlayer/_base_client.py @@ -529,6 +529,15 @@ def _build_request( # work around https://github.com/encode/httpx/discussions/2880 kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")} + is_body_allowed = options.method.lower() != "get" + + if is_body_allowed: + kwargs["json"] = json_data if is_given(json_data) else None + kwargs["files"] = files + else: + headers.pop("Content-Type", None) + kwargs.pop("data", None) + # TODO: report this error to httpx return self._client.build_request( # pyright: ignore[reportUnknownMemberType] headers=headers, @@ -540,8 +549,6 @@ def _build_request( # so that passing a `TypedDict` doesn't cause an error. # https://github.com/microsoft/pyright/issues/3526#event-6715453066 params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None, - json=json_data if is_given(json_data) else None, - files=files, **kwargs, ) diff --git a/src/openlayer/_version.py b/src/openlayer/_version.py index 790d0fb0..e1049f30 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.69" # x-release-please-version +__version__ = "0.2.0-alpha.70" # x-release-please-version diff --git a/src/openlayer/lib/tracing/tracer.py b/src/openlayer/lib/tracing/tracer.py index 1824df97..83af81fb 100644 --- a/src/openlayer/lib/tracing/tracer.py +++ b/src/openlayer/lib/tracing/tracer.py @@ -474,11 +474,15 @@ def _handle_trace_completion( ) client = _get_client() if client: - client.inference_pipelines.data.stream( + response = client.inference_pipelines.data.stream( inference_pipeline_id=inference_pipeline_id, rows=[trace_data], config=config, ) + print( + "Successfully streamed data to Openlayer. Response:", + response.to_json(), + ) except Exception as err: # pylint: disable=broad-except logger.error(traceback.format_exc()) logger.error( diff --git a/tests/test_client.py b/tests/test_client.py index 24766be2..00de783e 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -473,7 +473,7 @@ def test_request_extra_query(self) -> None: def test_multipart_repeating_array(self, client: Openlayer) -> None: request = client._build_request( FinalRequestOptions.construct( - method="get", + method="post", url="/foo", headers={"Content-Type": "multipart/form-data; boundary=6b7ba517decee4a450543ea6ae821c82"}, json_data={"array": ["foo", "bar"]}, @@ -1355,7 +1355,7 @@ def test_request_extra_query(self) -> None: def test_multipart_repeating_array(self, async_client: AsyncOpenlayer) -> None: request = async_client._build_request( FinalRequestOptions.construct( - method="get", + method="post", url="/foo", headers={"Content-Type": "multipart/form-data; boundary=6b7ba517decee4a450543ea6ae821c82"}, json_data={"array": ["foo", "bar"]},