Skip to content

release: 0.2.0-alpha.65 #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.2.0-alpha.64"
".": "0.2.0-alpha.65"
}
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ 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.65 (2025-06-19)

Full Changelog: [v0.2.0-alpha.64...v0.2.0-alpha.65](https://github.com/openlayer-ai/openlayer-python/compare/v0.2.0-alpha.64...v0.2.0-alpha.65)

### Bug Fixes

* **tests:** fix: tests which call HTTP endpoints directly with the example parameters ([ab7ef6b](https://github.com/openlayer-ai/openlayer-python/commit/ab7ef6b12437afc6bc07b1839cdd5fb70d4c3628))


### Chores

* **ci:** enable for pull requests ([07c86b5](https://github.com/openlayer-ai/openlayer-python/commit/07c86b5080d0c910e373b6f50b966ea56794e734))
* **internal:** update conftest.py ([af83c82](https://github.com/openlayer-ai/openlayer-python/commit/af83c828c31f99537e8b57074a325d0ec8dec13e))
* **readme:** update badges ([2c30786](https://github.com/openlayer-ai/openlayer-python/commit/2c30786b6870f003f4c6c2a9f68136eff15d2ebf))
* **tests:** add tests for httpx client instantiation & proxies ([55a2e38](https://github.com/openlayer-ai/openlayer-python/commit/55a2e38b32dd755ac27b36c7b1ebffe0ef41d3f2))


### Documentation

* **client:** fix httpx.Timeout documentation reference ([ad5d7c0](https://github.com/openlayer-ai/openlayer-python/commit/ad5d7c000f6ffb885d176192a98a740ff1251bd4))

## 0.2.0-alpha.64 (2025-06-16)

Full Changelog: [v0.2.0-alpha.63...v0.2.0-alpha.64](https://github.com/openlayer-ai/openlayer-python/compare/v0.2.0-alpha.63...v0.2.0-alpha.64)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Openlayer Python API library

[![PyPI version](https://img.shields.io/pypi/v/openlayer.svg)](https://pypi.org/project/openlayer/)
[![PyPI version](<https://img.shields.io/pypi/v/openlayer.svg?label=pypi%20(stable)>)](https://pypi.org/project/openlayer/)

The Openlayer Python library provides convenient access to the Openlayer REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
Expand Down Expand Up @@ -227,7 +227,7 @@ client.with_options(max_retries=5).inference_pipelines.data.stream(
### Timeouts

By default requests time out after 1 minute. You can configure this with a `timeout` option,
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:

```python
from openlayer import Openlayer
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openlayer"
version = "0.2.0-alpha.64"
version = "0.2.0-alpha.65"
description = "The official Python library for the openlayer API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/openlayer/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "openlayer"
__version__ = "0.2.0-alpha.64" # x-release-please-version
__version__ = "0.2.0-alpha.65" # x-release-please-version
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

import os
Expand Down
231 changes: 106 additions & 125 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@

from openlayer import Openlayer, AsyncOpenlayer, APIResponseValidationError
from openlayer._types import Omit
from openlayer._utils import maybe_transform
from openlayer._models import BaseModel, FinalRequestOptions
from openlayer._constants import RAW_RESPONSE_HEADER
from openlayer._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError
from openlayer._base_client import (
DEFAULT_TIMEOUT,
HTTPX_DEFAULT_TIMEOUT,
BaseClient,
DefaultHttpxClient,
DefaultAsyncHttpxClient,
make_request_options,
)
from openlayer.types.inference_pipelines.data_stream_params import DataStreamParams

from .utils import update_env

Expand Down Expand Up @@ -722,82 +721,49 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str

@mock.patch("openlayer._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None:
def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, client: Openlayer) -> None:
respx_mock.post("/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream").mock(
side_effect=httpx.TimeoutException("Test timeout error")
)

with pytest.raises(APITimeoutError):
self.client.post(
"/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream",
body=cast(
object,
maybe_transform(
dict(
config={
"input_variable_names": ["user_query"],
"output_column_name": "output",
"num_of_token_column_name": "tokens",
"cost_column_name": "cost",
"timestamp_column_name": "timestamp",
},
rows=[
{
"user_query": "what is the meaning of life?",
"output": "42",
"tokens": 7,
"cost": 0.02,
"timestamp": 1610000000,
}
],
),
DataStreamParams,
),
),
cast_to=httpx.Response,
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
)
client.inference_pipelines.data.with_streaming_response.stream(
inference_pipeline_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
config={"output_column_name": "output"},
rows=[
{
"user_query": "bar",
"output": "bar",
"tokens": "bar",
"cost": "bar",
"timestamp": "bar",
}
],
).__enter__()

assert _get_open_connections(self.client) == 0

@mock.patch("openlayer._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> None:
def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client: Openlayer) -> None:
respx_mock.post("/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream").mock(
return_value=httpx.Response(500)
)

with pytest.raises(APIStatusError):
self.client.post(
"/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream",
body=cast(
object,
maybe_transform(
dict(
config={
"input_variable_names": ["user_query"],
"output_column_name": "output",
"num_of_token_column_name": "tokens",
"cost_column_name": "cost",
"timestamp_column_name": "timestamp",
},
rows=[
{
"user_query": "what is the meaning of life?",
"output": "42",
"tokens": 7,
"cost": 0.02,
"timestamp": 1610000000,
}
],
),
DataStreamParams,
),
),
cast_to=httpx.Response,
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
)

client.inference_pipelines.data.with_streaming_response.stream(
inference_pipeline_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
config={"output_column_name": "output"},
rows=[
{
"user_query": "bar",
"output": "bar",
"tokens": "bar",
"cost": "bar",
"timestamp": "bar",
}
],
).__enter__()
assert _get_open_connections(self.client) == 0

@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
Expand Down Expand Up @@ -921,6 +887,28 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:

assert response.http_request.headers.get("x-stainless-retry-count") == "42"

def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None:
# Test that the proxy environment variables are set correctly
monkeypatch.setenv("HTTPS_PROXY", "https://example.org")

client = DefaultHttpxClient()

mounts = tuple(client._mounts.items())
assert len(mounts) == 1
assert mounts[0][0].pattern == "https://"

@pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning")
def test_default_client_creation(self) -> None:
# Ensure that the client can be initialized without any exceptions
DefaultHttpxClient(
verify=True,
cert=None,
trust_env=True,
http1=True,
http2=False,
limits=httpx.Limits(max_connections=100, max_keepalive_connections=20),
)

@pytest.mark.respx(base_url=base_url)
def test_follow_redirects(self, respx_mock: MockRouter) -> None:
# Test that the default follow_redirects=True allows following redirects
Expand Down Expand Up @@ -1628,82 +1616,53 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte

@mock.patch("openlayer._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None:
async def test_retrying_timeout_errors_doesnt_leak(
self, respx_mock: MockRouter, async_client: AsyncOpenlayer
) -> None:
respx_mock.post("/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream").mock(
side_effect=httpx.TimeoutException("Test timeout error")
)

with pytest.raises(APITimeoutError):
await self.client.post(
"/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream",
body=cast(
object,
maybe_transform(
dict(
config={
"input_variable_names": ["user_query"],
"output_column_name": "output",
"num_of_token_column_name": "tokens",
"cost_column_name": "cost",
"timestamp_column_name": "timestamp",
},
rows=[
{
"user_query": "what is the meaning of life?",
"output": "42",
"tokens": 7,
"cost": 0.02,
"timestamp": 1610000000,
}
],
),
DataStreamParams,
),
),
cast_to=httpx.Response,
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
)
await async_client.inference_pipelines.data.with_streaming_response.stream(
inference_pipeline_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
config={"output_column_name": "output"},
rows=[
{
"user_query": "bar",
"output": "bar",
"tokens": "bar",
"cost": "bar",
"timestamp": "bar",
}
],
).__aenter__()

assert _get_open_connections(self.client) == 0

@mock.patch("openlayer._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> None:
async def test_retrying_status_errors_doesnt_leak(
self, respx_mock: MockRouter, async_client: AsyncOpenlayer
) -> None:
respx_mock.post("/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream").mock(
return_value=httpx.Response(500)
)

with pytest.raises(APIStatusError):
await self.client.post(
"/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream",
body=cast(
object,
maybe_transform(
dict(
config={
"input_variable_names": ["user_query"],
"output_column_name": "output",
"num_of_token_column_name": "tokens",
"cost_column_name": "cost",
"timestamp_column_name": "timestamp",
},
rows=[
{
"user_query": "what is the meaning of life?",
"output": "42",
"tokens": 7,
"cost": 0.02,
"timestamp": 1610000000,
}
],
),
DataStreamParams,
),
),
cast_to=httpx.Response,
options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
)

await async_client.inference_pipelines.data.with_streaming_response.stream(
inference_pipeline_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
config={"output_column_name": "output"},
rows=[
{
"user_query": "bar",
"output": "bar",
"tokens": "bar",
"cost": "bar",
"timestamp": "bar",
}
],
).__aenter__()
assert _get_open_connections(self.client) == 0

@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
Expand Down Expand Up @@ -1875,6 +1834,28 @@ async def test_main() -> None:

time.sleep(0.1)

async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None:
# Test that the proxy environment variables are set correctly
monkeypatch.setenv("HTTPS_PROXY", "https://example.org")

client = DefaultAsyncHttpxClient()

mounts = tuple(client._mounts.items())
assert len(mounts) == 1
assert mounts[0][0].pattern == "https://"

@pytest.mark.filterwarnings("ignore:.*deprecated.*:DeprecationWarning")
async def test_default_client_creation(self) -> None:
# Ensure that the client can be initialized without any exceptions
DefaultAsyncHttpxClient(
verify=True,
cert=None,
trust_env=True,
http1=True,
http2=False,
limits=httpx.Limits(max_connections=100, max_keepalive_connections=20),
)

@pytest.mark.respx(base_url=base_url)
async def test_follow_redirects(self, respx_mock: MockRouter) -> None:
# Test that the default follow_redirects=True allows following redirects
Expand Down