diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 48cc0f71..b47733a9 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -32,7 +32,7 @@ $ pip install -r requirements-dev.lock
## Modifying/Adding code
Most of the SDK is generated code, and any modified code will be overridden on the next generation. The
-`src/openlayer-test/lib/` and `examples/` directories are exceptions and will never be overridden.
+`src/openlayer/lib/` and `examples/` directories are exceptions and will never be overridden.
## Adding and running examples
diff --git a/README.md b/README.md
index c7ceb214..108252df 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Openlayer Python API library
-[](https://pypi.org/project/openlayer-test/)
+[](https://pypi.org/project/openlayer/)
The Openlayer Python library provides convenient access to the Openlayer REST API from any Python 3.7+
application. The library includes type definitions for all request params and response fields,
@@ -16,7 +16,7 @@ The REST API documentation can be found [on openlayer.com](https://openlayer.com
```sh
# install from PyPI
-pip install --pre openlayer-test
+pip install --pre openlayer
```
## Usage
@@ -25,7 +25,7 @@ The full API of this library can be found in [api.md](api.md).
```python
import os
-from openlayer-test import Openlayer
+from openlayer import Openlayer
client = Openlayer(
# This is the default and can be omitted
@@ -41,13 +41,15 @@ data_stream_response = client.inference_pipelines.data.stream(
"cost_column_name": "cost",
"timestamp_column_name": "timestamp",
},
- rows=[{
- "user_query": "what's the meaning of life?",
- "output": "42",
- "tokens": 7,
- "cost": 0.02,
- "timestamp": 1620000000,
- }],
+ rows=[
+ {
+ "user_query": "what's the meaning of life?",
+ "output": "42",
+ "tokens": 7,
+ "cost": 0.02,
+ "timestamp": 1620000000,
+ }
+ ],
)
print(data_stream_response.success)
```
@@ -64,32 +66,36 @@ Simply import `AsyncOpenlayer` instead of `Openlayer` and use `await` with each
```python
import os
import asyncio
-from openlayer-test import AsyncOpenlayer
+from openlayer import AsyncOpenlayer
client = AsyncOpenlayer(
# This is the default and can be omitted
api_key=os.environ.get("OPENLAYER_API_KEY"),
)
+
async def main() -> None:
- data_stream_response = await client.inference_pipelines.data.stream(
- "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- 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's the meaning of life?",
- "output": "42",
- "tokens": 7,
- "cost": 0.02,
- "timestamp": 1620000000,
- }],
- )
- print(data_stream_response.success)
+ data_stream_response = await client.inference_pipelines.data.stream(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ 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's the meaning of life?",
+ "output": "42",
+ "tokens": 7,
+ "cost": 0.02,
+ "timestamp": 1620000000,
+ }
+ ],
+ )
+ print(data_stream_response.success)
+
asyncio.run(main())
```
@@ -107,16 +113,16 @@ Typed requests and responses provide autocomplete and documentation within your
## Handling errors
-When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `openlayer-test.APIConnectionError` is raised.
+When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `openlayer.APIConnectionError` is raised.
When the API returns a non-success status code (that is, 4xx or 5xx
-response), a subclass of `openlayer-test.APIStatusError` is raised, containing `status_code` and `response` properties.
+response), a subclass of `openlayer.APIStatusError` is raised, containing `status_code` and `response` properties.
-All errors inherit from `openlayer-test.APIError`.
+All errors inherit from `openlayer.APIError`.
```python
-import openlayer-test
-from openlayer-test import Openlayer
+import openlayer
+from openlayer import Openlayer
client = Openlayer()
@@ -130,20 +136,22 @@ try:
"cost_column_name": "cost",
"timestamp_column_name": "timestamp",
},
- rows=[{
- "user_query": "what's the meaning of life?",
- "output": "42",
- "tokens": 7,
- "cost": 0.02,
- "timestamp": 1620000000,
- }],
+ rows=[
+ {
+ "user_query": "what's the meaning of life?",
+ "output": "42",
+ "tokens": 7,
+ "cost": 0.02,
+ "timestamp": 1620000000,
+ }
+ ],
)
-except openlayer-test.APIConnectionError as e:
+except openlayer.APIConnectionError as e:
print("The server could not be reached")
- print(e.__cause__) # an underlying Exception, likely raised within httpx.
-except openlayer-test.RateLimitError as e:
+ print(e.__cause__) # an underlying Exception, likely raised within httpx.
+except openlayer.RateLimitError as e:
print("A 429 status code was received; we should back off a bit.")
-except openlayer-test.APIStatusError as e:
+except openlayer.APIStatusError as e:
print("Another non-200-range status code was received")
print(e.status_code)
print(e.response)
@@ -171,7 +179,7 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
You can use the `max_retries` option to configure or disable retry settings:
```python
-from openlayer-test import Openlayer
+from openlayer import Openlayer
# Configure the default for all requests:
client = Openlayer(
@@ -180,7 +188,7 @@ client = Openlayer(
)
# Or, configure per-request:
-client.with_options(max_retries = 5).inference_pipelines.data.stream(
+client.with_options(max_retries=5).inference_pipelines.data.stream(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
config={
"input_variable_names": ["user_query"],
@@ -189,13 +197,15 @@ client.with_options(max_retries = 5).inference_pipelines.data.stream(
"cost_column_name": "cost",
"timestamp_column_name": "timestamp",
},
- rows=[{
- "user_query": "what's the meaning of life?",
- "output": "42",
- "tokens": 7,
- "cost": 0.02,
- "timestamp": 1620000000,
- }],
+ rows=[
+ {
+ "user_query": "what's the meaning of life?",
+ "output": "42",
+ "tokens": 7,
+ "cost": 0.02,
+ "timestamp": 1620000000,
+ }
+ ],
)
```
@@ -205,7 +215,7 @@ By default requests time out after 1 minute. You can configure this with a `time
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
```python
-from openlayer-test import Openlayer
+from openlayer import Openlayer
# Configure the default for all requests:
client = Openlayer(
@@ -219,7 +229,7 @@ client = Openlayer(
)
# Override per-request:
-client.with_options(timeout = 5.0).inference_pipelines.data.stream(
+client.with_options(timeout=5.0).inference_pipelines.data.stream(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
config={
"input_variable_names": ["user_query"],
@@ -228,13 +238,15 @@ client.with_options(timeout = 5.0).inference_pipelines.data.stream(
"cost_column_name": "cost",
"timestamp_column_name": "timestamp",
},
- rows=[{
- "user_query": "what's the meaning of life?",
- "output": "42",
- "tokens": 7,
- "cost": 0.02,
- "timestamp": 1620000000,
- }],
+ rows=[
+ {
+ "user_query": "what's the meaning of life?",
+ "output": "42",
+ "tokens": 7,
+ "cost": 0.02,
+ "timestamp": 1620000000,
+ }
+ ],
)
```
@@ -271,7 +283,7 @@ if response.my_field is None:
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,
```py
-from openlayer-test import Openlayer
+from openlayer import Openlayer
client = Openlayer()
response = client.inference_pipelines.data.with_raw_response.stream(
@@ -297,9 +309,9 @@ data = response.parse() # get the object that `inference_pipelines.data.stream(
print(data.success)
```
-These methods return an [`APIResponse`](https://github.com/openlayer-ai/openlayer-python/tree/main/src/openlayer-test/_response.py) object.
+These methods return an [`APIResponse`](https://github.com/openlayer-ai/openlayer-python/tree/main/src/openlayer/_response.py) object.
-The async client returns an [`AsyncAPIResponse`](https://github.com/openlayer-ai/openlayer-python/tree/main/src/openlayer-test/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
+The async client returns an [`AsyncAPIResponse`](https://github.com/openlayer-ai/openlayer-python/tree/main/src/openlayer/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
#### `.with_streaming_response`
@@ -317,18 +329,20 @@ with client.inference_pipelines.data.with_streaming_response.stream(
"cost_column_name": "cost",
"timestamp_column_name": "timestamp",
},
- rows=[{
- "user_query": "what's the meaning of life?",
- "output": "42",
- "tokens": 7,
- "cost": 0.02,
- "timestamp": 1620000000,
- }],
-) as response :
- print(response.headers.get('X-My-Header'))
+ rows=[
+ {
+ "user_query": "what's the meaning of life?",
+ "output": "42",
+ "tokens": 7,
+ "cost": 0.02,
+ "timestamp": 1620000000,
+ }
+ ],
+) as response:
+ print(response.headers.get("X-My-Header"))
for line in response.iter_lines():
- print(line)
+ print(line)
```
The context manager is required so that the response will reliably be closed.
@@ -377,12 +391,15 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
- Additional [advanced](https://www.python-httpx.org/advanced/#client-instances) functionality
```python
-from openlayer-test import Openlayer, DefaultHttpxClient
+from openlayer import Openlayer, DefaultHttpxClient
client = Openlayer(
# Or use the `OPENLAYER_BASE_URL` env var
base_url="http://my.test.server.example.com:8083",
- http_client=DefaultHttpxClient(proxies="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),
+ http_client=DefaultHttpxClient(
+ proxies="http://my.test.proxy.example.com",
+ transport=httpx.HTTPTransport(local_address="0.0.0.0"),
+ ),
)
```
diff --git a/api.md b/api.md
index 5949d339..6a11c669 100644
--- a/api.md
+++ b/api.md
@@ -3,36 +3,36 @@
Types:
```python
-from openlayer-test.types import ProjectListResponse
+from openlayer.types import ProjectListResponse
```
Methods:
-- client.projects.list(\*\*params) -> ProjectListResponse
+- client.projects.list(\*\*params) -> ProjectListResponse
## Commits
Types:
```python
-from openlayer-test.types.projects import CommitListResponse
+from openlayer.types.projects import CommitListResponse
```
Methods:
-- client.projects.commits.list(id, \*\*params) -> CommitListResponse
+- client.projects.commits.list(id, \*\*params) -> CommitListResponse
## InferencePipelines
Types:
```python
-from openlayer-test.types.projects import InferencePipelineListResponse
+from openlayer.types.projects import InferencePipelineListResponse
```
Methods:
-- client.projects.inference_pipelines.list(id, \*\*params) -> InferencePipelineListResponse
+- client.projects.inference_pipelines.list(id, \*\*params) -> InferencePipelineListResponse
# Commits
@@ -41,12 +41,12 @@ Methods:
Types:
```python
-from openlayer-test.types.commits import TestResultListResponse
+from openlayer.types.commits import TestResultListResponse
```
Methods:
-- client.commits.test_results.list(id, \*\*params) -> TestResultListResponse
+- client.commits.test_results.list(id, \*\*params) -> TestResultListResponse
# InferencePipelines
@@ -55,21 +55,21 @@ Methods:
Types:
```python
-from openlayer-test.types.inference_pipelines import DataStreamResponse
+from openlayer.types.inference_pipelines import DataStreamResponse
```
Methods:
-- client.inference_pipelines.data.stream(id, \*\*params) -> DataStreamResponse
+- client.inference_pipelines.data.stream(id, \*\*params) -> DataStreamResponse
## TestResults
Types:
```python
-from openlayer-test.types.inference_pipelines import TestResultListResponse
+from openlayer.types.inference_pipelines import TestResultListResponse
```
Methods:
-- client.inference_pipelines.test_results.list(id, \*\*params) -> TestResultListResponse
+- client.inference_pipelines.test_results.list(id, \*\*params) -> TestResultListResponse
diff --git a/mypy.ini b/mypy.ini
index bccb2c92..20794fe4 100644
--- a/mypy.ini
+++ b/mypy.ini
@@ -5,7 +5,7 @@ show_error_codes = True
# Exclude _files.py because mypy isn't smart enough to apply
# the correct type narrowing and as this is an internal module
# it's fine to just use Pyright.
-exclude = ^(src/openlayer-test/_files\.py|_dev/.*\.py)$
+exclude = ^(src/openlayer/_files\.py|_dev/.*\.py)$
strict_equality = True
implicit_reexport = True
diff --git a/pyproject.toml b/pyproject.toml
index e4c448f0..80e547bc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,5 +1,5 @@
[project]
-name = "openlayer-test"
+name = "openlayer"
version = "0.1.0-alpha.4"
description = "The official Python library for the openlayer API"
dynamic = ["readme"]
@@ -84,7 +84,7 @@ typecheck = { chain = [
"typecheck:mypy"
]}
"typecheck:pyright" = "pyright"
-"typecheck:verify-types" = "pyright --verifytypes openlayer-test --ignoreexternal"
+"typecheck:verify-types" = "pyright --verifytypes openlayer --ignoreexternal"
"typecheck:mypy" = "mypy ."
[build-system]
@@ -97,7 +97,7 @@ include = [
]
[tool.hatch.build.targets.wheel]
-packages = ["src/openlayer-test"]
+packages = ["src/openlayer"]
[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/markdown"
@@ -187,7 +187,7 @@ length-sort = true
length-sort-straight = true
combine-as-imports = true
extra-standard-library = ["typing_extensions"]
-known-first-party = ["openlayer-test", "tests"]
+known-first-party = ["openlayer", "tests"]
[tool.ruff.per-file-ignores]
"bin/**.py" = ["T201", "T203"]
diff --git a/release-please-config.json b/release-please-config.json
index b474b872..83a417a7 100644
--- a/release-please-config.json
+++ b/release-please-config.json
@@ -61,6 +61,6 @@
],
"release-type": "python",
"extra-files": [
- "src/openlayer-test/_version.py"
+ "src/openlayer/_version.py"
]
}
\ No newline at end of file
diff --git a/requirements-dev.lock b/requirements-dev.lock
index 6a8433ee..26451e23 100644
--- a/requirements-dev.lock
+++ b/requirements-dev.lock
@@ -12,7 +12,7 @@ annotated-types==0.6.0
# via pydantic
anyio==4.1.0
# via httpx
- # via openlayer-test
+ # via openlayer
argcomplete==3.1.2
# via nox
attrs==23.1.0
@@ -26,7 +26,7 @@ dirty-equals==0.6.0
distlib==0.3.7
# via virtualenv
distro==1.8.0
- # via openlayer-test
+ # via openlayer
exceptiongroup==1.1.3
# via anyio
filelock==3.12.4
@@ -36,7 +36,7 @@ h11==0.14.0
httpcore==1.0.2
# via httpx
httpx==0.25.2
- # via openlayer-test
+ # via openlayer
# via respx
idna==3.4
# via anyio
@@ -60,7 +60,7 @@ pluggy==1.3.0
py==1.11.0
# via pytest
pydantic==2.7.1
- # via openlayer-test
+ # via openlayer
pydantic-core==2.18.2
# via pydantic
pyright==1.1.364
@@ -80,14 +80,14 @@ six==1.16.0
sniffio==1.3.0
# via anyio
# via httpx
- # via openlayer-test
+ # via openlayer
time-machine==2.9.0
tomli==2.0.1
# via mypy
# via pytest
typing-extensions==4.8.0
# via mypy
- # via openlayer-test
+ # via openlayer
# via pydantic
# via pydantic-core
virtualenv==20.24.5
diff --git a/requirements.lock b/requirements.lock
index 4e5a36e4..04f85d2e 100644
--- a/requirements.lock
+++ b/requirements.lock
@@ -12,12 +12,12 @@ annotated-types==0.6.0
# via pydantic
anyio==4.1.0
# via httpx
- # via openlayer-test
+ # via openlayer
certifi==2023.7.22
# via httpcore
# via httpx
distro==1.8.0
- # via openlayer-test
+ # via openlayer
exceptiongroup==1.1.3
# via anyio
h11==0.14.0
@@ -25,19 +25,19 @@ h11==0.14.0
httpcore==1.0.2
# via httpx
httpx==0.25.2
- # via openlayer-test
+ # via openlayer
idna==3.4
# via anyio
# via httpx
pydantic==2.7.1
- # via openlayer-test
+ # via openlayer
pydantic-core==2.18.2
# via pydantic
sniffio==1.3.0
# via anyio
# via httpx
- # via openlayer-test
+ # via openlayer
typing-extensions==4.8.0
- # via openlayer-test
+ # via openlayer
# via pydantic
# via pydantic-core
diff --git a/scripts/lint b/scripts/lint
index 4595e5de..763eb089 100755
--- a/scripts/lint
+++ b/scripts/lint
@@ -8,5 +8,5 @@ echo "==> Running lints"
rye run lint
echo "==> Making sure it imports"
-rye run python -c 'import openlayer-test'
+rye run python -c 'import openlayer'
diff --git a/src/openlayer-test/__init__.py b/src/openlayer/__init__.py
similarity index 89%
rename from src/openlayer-test/__init__.py
rename to src/openlayer/__init__.py
index d7221ba8..e2047e6c 100644
--- a/src/openlayer-test/__init__.py
+++ b/src/openlayer/__init__.py
@@ -1,41 +1,41 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from . import types
-from ._version import __version__, __title__
+from ._types import NOT_GIVEN, NoneType, NotGiven, Transport, ProxiesTypes
+from ._utils import file_from_path
from ._client import (
+ Client,
+ Stream,
Timeout,
+ Openlayer,
Transport,
- RequestOptions,
- Client,
AsyncClient,
- Stream,
AsyncStream,
- Openlayer,
AsyncOpenlayer,
+ RequestOptions,
)
+from ._models import BaseModel
+from ._version import __title__, __version__
+from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse
+from ._constants import DEFAULT_TIMEOUT, DEFAULT_MAX_RETRIES, DEFAULT_CONNECTION_LIMITS
from ._exceptions import (
- OpenlayerError,
APIError,
+ ConflictError,
+ NotFoundError,
APIStatusError,
+ OpenlayerError,
+ RateLimitError,
APITimeoutError,
- APIConnectionError,
- APIResponseValidationError,
BadRequestError,
+ APIConnectionError,
AuthenticationError,
+ InternalServerError,
PermissionDeniedError,
- NotFoundError,
- ConflictError,
UnprocessableEntityError,
- RateLimitError,
- InternalServerError,
+ APIResponseValidationError,
)
-from ._types import NoneType, Transport, ProxiesTypes, NotGiven, NOT_GIVEN
-from ._utils import file_from_path
-from ._models import BaseModel
-from ._constants import DEFAULT_TIMEOUT, DEFAULT_MAX_RETRIES, DEFAULT_CONNECTION_LIMITS
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
from ._utils._logs import setup_logging as _setup_logging
-from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse
__all__ = [
"types",
@@ -82,12 +82,12 @@
# Update the __module__ attribute for exported symbols so that
# error messages point to this module instead of the module
# it was originally defined in, e.g.
-# openlayer-test._exceptions.NotFoundError -> openlayer-test.NotFoundError
+# openlayer._exceptions.NotFoundError -> openlayer.NotFoundError
__locals = locals()
for __name in __all__:
if not __name.startswith("__"):
try:
- setattr(__locals[__name], "__module__", "openlayer-test")
+ __locals[__name].__module__ = "openlayer"
except (TypeError, AttributeError):
# Some of our exported symbols are builtins which we can't set attributes for.
pass
diff --git a/src/openlayer-test/_base_client.py b/src/openlayer/_base_client.py
similarity index 99%
rename from src/openlayer-test/_base_client.py
rename to src/openlayer/_base_client.py
index 21bfa7c4..e56f38d8 100644
--- a/src/openlayer-test/_base_client.py
+++ b/src/openlayer/_base_client.py
@@ -60,7 +60,7 @@
RequestOptions,
ModelBuilderProtocol,
)
-from ._utils import is_dict, is_given, is_mapping, is_list, lru_cache
+from ._utils import is_dict, is_list, is_given, lru_cache, is_mapping
from ._compat import model_copy, model_dump
from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
from ._response import (
@@ -69,17 +69,16 @@
AsyncAPIResponse,
extract_response_type,
)
-from ._legacy_response import LegacyAPIResponse
from ._constants import (
- DEFAULT_CONNECTION_LIMITS,
- DEFAULT_MAX_RETRIES,
DEFAULT_TIMEOUT,
- INITIAL_RETRY_DELAY,
MAX_RETRY_DELAY,
+ DEFAULT_MAX_RETRIES,
+ INITIAL_RETRY_DELAY,
RAW_RESPONSE_HEADER,
OVERRIDE_CAST_TO_HEADER,
+ DEFAULT_CONNECTION_LIMITS,
)
-from ._streaming import Stream, AsyncStream, SSEDecoder, SSEBytesDecoder
+from ._streaming import Stream, SSEDecoder, AsyncStream, SSEBytesDecoder
from ._exceptions import (
APIStatusError,
APITimeoutError,
@@ -362,7 +361,7 @@ def __init__(
if max_retries is None: # pyright: ignore[reportUnnecessaryComparison]
raise TypeError(
- "max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `openlayer-test.DEFAULT_MAX_RETRIES`"
+ "max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `openlayer.DEFAULT_MAX_RETRIES`"
)
def _enforce_trailing_slash(self, url: URL) -> URL:
diff --git a/src/openlayer-test/_client.py b/src/openlayer/_client.py
similarity index 95%
rename from src/openlayer-test/_client.py
rename to src/openlayer/_client.py
index bd87c234..4188cb39 100644
--- a/src/openlayer-test/_client.py
+++ b/src/openlayer/_client.py
@@ -2,68 +2,36 @@
from __future__ import annotations
-import httpx
-
import os
-
-from ._streaming import AsyncStream as AsyncStream, Stream as Stream
-
-from typing_extensions import override, Self
-
-from typing import Any
-
-from ._exceptions import APIStatusError
-
-from ._utils import get_async_library
-
-from . import _exceptions
-
-import os
-import asyncio
-import warnings
-from typing import Optional, Union, Dict, Any, Mapping, overload, cast
-from typing_extensions import Literal
+from typing import Any, Union, Mapping
+from typing_extensions import Self, override
import httpx
-from ._version import __version__
+from . import resources, _exceptions
from ._qs import Querystring
-from .types import shared_params
-from ._utils import (
- extract_files,
- maybe_transform,
- required_args,
- deepcopy_minimal,
- maybe_coerce_integer,
- maybe_coerce_float,
- maybe_coerce_boolean,
- is_given,
-)
from ._types import (
+ NOT_GIVEN,
Omit,
- NotGiven,
+ Headers,
Timeout,
+ NotGiven,
Transport,
ProxiesTypes,
RequestOptions,
- Headers,
- NoneType,
- Query,
- Body,
- NOT_GIVEN,
)
+from ._utils import (
+ is_given,
+ get_async_library,
+)
+from ._version import __version__
+from ._streaming import Stream as Stream, AsyncStream as AsyncStream
+from ._exceptions import APIStatusError
from ._base_client import (
- DEFAULT_CONNECTION_LIMITS,
- DEFAULT_TIMEOUT,
DEFAULT_MAX_RETRIES,
- ResponseT,
- SyncHttpxClientWrapper,
- AsyncHttpxClientWrapper,
SyncAPIClient,
AsyncAPIClient,
- make_request_options,
)
-from . import resources
__all__ = [
"Timeout",
diff --git a/src/openlayer-test/_compat.py b/src/openlayer/_compat.py
similarity index 100%
rename from src/openlayer-test/_compat.py
rename to src/openlayer/_compat.py
diff --git a/src/openlayer-test/_constants.py b/src/openlayer/_constants.py
similarity index 100%
rename from src/openlayer-test/_constants.py
rename to src/openlayer/_constants.py
diff --git a/src/openlayer-test/_exceptions.py b/src/openlayer/_exceptions.py
similarity index 100%
rename from src/openlayer-test/_exceptions.py
rename to src/openlayer/_exceptions.py
index 97e1e31b..9d25d579 100644
--- a/src/openlayer-test/_exceptions.py
+++ b/src/openlayer/_exceptions.py
@@ -2,10 +2,10 @@
from __future__ import annotations
-import httpx
-
from typing_extensions import Literal
+import httpx
+
__all__ = [
"BadRequestError",
"AuthenticationError",
diff --git a/src/openlayer-test/_files.py b/src/openlayer/_files.py
similarity index 100%
rename from src/openlayer-test/_files.py
rename to src/openlayer/_files.py
diff --git a/src/openlayer-test/_models.py b/src/openlayer/_models.py
similarity index 100%
rename from src/openlayer-test/_models.py
rename to src/openlayer/_models.py
diff --git a/src/openlayer-test/_qs.py b/src/openlayer/_qs.py
similarity index 100%
rename from src/openlayer-test/_qs.py
rename to src/openlayer/_qs.py
diff --git a/src/openlayer-test/_resource.py b/src/openlayer/_resource.py
similarity index 99%
rename from src/openlayer-test/_resource.py
rename to src/openlayer/_resource.py
index 3f287aa6..eebef711 100644
--- a/src/openlayer-test/_resource.py
+++ b/src/openlayer/_resource.py
@@ -3,9 +3,10 @@
from __future__ import annotations
import time
-import anyio
from typing import TYPE_CHECKING
+import anyio
+
if TYPE_CHECKING:
from ._client import Openlayer, AsyncOpenlayer
diff --git a/src/openlayer-test/_response.py b/src/openlayer/_response.py
similarity index 98%
rename from src/openlayer-test/_response.py
rename to src/openlayer/_response.py
index 8cb9ca86..39a5a83e 100644
--- a/src/openlayer-test/_response.py
+++ b/src/openlayer/_response.py
@@ -18,7 +18,7 @@
cast,
overload,
)
-from typing_extensions import Awaitable, ParamSpec, TypeGuard, override, get_origin
+from typing_extensions import Awaitable, ParamSpec, override, get_origin
import anyio
import httpx
@@ -26,7 +26,6 @@
from ._types import NoneType
from ._utils import is_given, extract_type_arg, is_annotated_type, extract_type_var_from_base
-from ._streaming import extract_stream_chunk_type
from ._models import BaseModel, is_basemodel
from ._constants import RAW_RESPONSE_HEADER, OVERRIDE_CAST_TO_HEADER
from ._streaming import Stream, AsyncStream, is_stream_class_type, extract_stream_chunk_type
@@ -204,9 +203,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
return cast(R, response)
if inspect.isclass(origin) and not issubclass(origin, BaseModel) and issubclass(origin, pydantic.BaseModel):
- raise TypeError(
- "Pydantic models must subclass our base model type, e.g. `from openlayer-test import BaseModel`"
- )
+ raise TypeError("Pydantic models must subclass our base model type, e.g. `from openlayer import BaseModel`")
if (
cast_to is not object
@@ -274,7 +271,7 @@ def parse(self, *, to: type[_T] | None = None) -> R | _T:
the `to` argument, e.g.
```py
- from openlayer-test import BaseModel
+ from openlayer import BaseModel
class MyModel(BaseModel):
@@ -378,7 +375,7 @@ async def parse(self, *, to: type[_T] | None = None) -> R | _T:
the `to` argument, e.g.
```py
- from openlayer-test import BaseModel
+ from openlayer import BaseModel
class MyModel(BaseModel):
@@ -549,7 +546,7 @@ async def stream_to_file(
class MissingStreamClassError(TypeError):
def __init__(self) -> None:
super().__init__(
- "The `stream` argument was set to `True` but the `stream_cls` argument was not given. See `openlayer-test._streaming` for reference",
+ "The `stream` argument was set to `True` but the `stream_cls` argument was not given. See `openlayer._streaming` for reference",
)
diff --git a/src/openlayer-test/_streaming.py b/src/openlayer/_streaming.py
similarity index 98%
rename from src/openlayer-test/_streaming.py
rename to src/openlayer/_streaming.py
index a13c3850..8eb34af1 100644
--- a/src/openlayer-test/_streaming.py
+++ b/src/openlayer/_streaming.py
@@ -9,9 +9,7 @@
import httpx
-from ._utils import is_mapping, is_dict, extract_type_var_from_base
-from ._exceptions import APIError
-from ._response import APIResponse, AsyncAPIResponse
+from ._utils import extract_type_var_from_base
if TYPE_CHECKING:
from ._client import Openlayer, AsyncOpenlayer
diff --git a/src/openlayer-test/_types.py b/src/openlayer/_types.py
similarity index 97%
rename from src/openlayer-test/_types.py
rename to src/openlayer/_types.py
index f58e2736..1dee84b9 100644
--- a/src/openlayer-test/_types.py
+++ b/src/openlayer/_types.py
@@ -1,7 +1,6 @@
from __future__ import annotations
from os import PathLike
-from abc import ABC, abstractmethod
from typing import (
IO,
TYPE_CHECKING,
@@ -14,10 +13,8 @@
Mapping,
TypeVar,
Callable,
- Iterator,
Optional,
Sequence,
- AsyncIterator,
)
from typing_extensions import Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
@@ -28,7 +25,6 @@
if TYPE_CHECKING:
from ._models import BaseModel
from ._response import APIResponse, AsyncAPIResponse
- from ._legacy_response import HttpxBinaryResponseContent
Transport = BaseTransport
AsyncTransport = AsyncBaseTransport
@@ -85,7 +81,7 @@
# This unfortunately means that you will either have
# to import this type and pass it explicitly:
#
-# from openlayer-test import NoneType
+# from openlayer import NoneType
# client.get('/foo', cast_to=NoneType)
#
# or build it yourself:
diff --git a/src/openlayer-test/_utils/__init__.py b/src/openlayer/_utils/__init__.py
similarity index 100%
rename from src/openlayer-test/_utils/__init__.py
rename to src/openlayer/_utils/__init__.py
diff --git a/src/openlayer-test/_utils/_logs.py b/src/openlayer/_utils/_logs.py
similarity index 75%
rename from src/openlayer-test/_utils/_logs.py
rename to src/openlayer/_utils/_logs.py
index 15effa81..84e87cf4 100644
--- a/src/openlayer-test/_utils/_logs.py
+++ b/src/openlayer/_utils/_logs.py
@@ -1,12 +1,12 @@
import os
import logging
-logger: logging.Logger = logging.getLogger("openlayer-test")
+logger: logging.Logger = logging.getLogger("openlayer")
httpx_logger: logging.Logger = logging.getLogger("httpx")
def _basic_config() -> None:
- # e.g. [2023-10-05 14:12:26 - openlayer-test._base_client:818 - DEBUG] HTTP Request: POST http://127.0.0.1:4010/foo/bar "200 OK"
+ # e.g. [2023-10-05 14:12:26 - openlayer._base_client:818 - DEBUG] HTTP Request: POST http://127.0.0.1:4010/foo/bar "200 OK"
logging.basicConfig(
format="[%(asctime)s - %(name)s:%(lineno)d - %(levelname)s] %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
diff --git a/src/openlayer-test/_utils/_proxy.py b/src/openlayer/_utils/_proxy.py
similarity index 100%
rename from src/openlayer-test/_utils/_proxy.py
rename to src/openlayer/_utils/_proxy.py
diff --git a/src/openlayer-test/_utils/_streams.py b/src/openlayer/_utils/_streams.py
similarity index 100%
rename from src/openlayer-test/_utils/_streams.py
rename to src/openlayer/_utils/_streams.py
diff --git a/src/openlayer-test/_utils/_sync.py b/src/openlayer/_utils/_sync.py
similarity index 100%
rename from src/openlayer-test/_utils/_sync.py
rename to src/openlayer/_utils/_sync.py
diff --git a/src/openlayer-test/_utils/_transform.py b/src/openlayer/_utils/_transform.py
similarity index 100%
rename from src/openlayer-test/_utils/_transform.py
rename to src/openlayer/_utils/_transform.py
diff --git a/src/openlayer-test/_utils/_typing.py b/src/openlayer/_utils/_typing.py
similarity index 100%
rename from src/openlayer-test/_utils/_typing.py
rename to src/openlayer/_utils/_typing.py
diff --git a/src/openlayer-test/_utils/_utils.py b/src/openlayer/_utils/_utils.py
similarity index 100%
rename from src/openlayer-test/_utils/_utils.py
rename to src/openlayer/_utils/_utils.py
diff --git a/src/openlayer-test/_version.py b/src/openlayer/_version.py
similarity index 83%
rename from src/openlayer-test/_version.py
rename to src/openlayer/_version.py
index 7f41c4d4..597e782e 100644
--- a/src/openlayer-test/_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-test"
+__title__ = "openlayer"
__version__ = "0.1.0-alpha.4" # x-release-please-version
diff --git a/src/openlayer-test/py.typed b/src/openlayer/py.typed
similarity index 100%
rename from src/openlayer-test/py.typed
rename to src/openlayer/py.typed
diff --git a/src/openlayer-test/resources/projects/__init__.py b/src/openlayer/resources/__init__.py
similarity index 87%
rename from src/openlayer-test/resources/projects/__init__.py
rename to src/openlayer/resources/__init__.py
index a2bd727c..28cab671 100644
--- a/src/openlayer-test/resources/projects/__init__.py
+++ b/src/openlayer/resources/__init__.py
@@ -1,28 +1,37 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from .commits import CommitsResource, AsyncCommitsResource
from .commits import (
+ CommitsResource,
+ AsyncCommitsResource,
CommitsResourceWithRawResponse,
AsyncCommitsResourceWithRawResponse,
CommitsResourceWithStreamingResponse,
AsyncCommitsResourceWithStreamingResponse,
)
-from .inference_pipelines import InferencePipelinesResource, AsyncInferencePipelinesResource
-from .inference_pipelines import (
- InferencePipelinesResourceWithRawResponse,
- AsyncInferencePipelinesResourceWithRawResponse,
- InferencePipelinesResourceWithStreamingResponse,
- AsyncInferencePipelinesResourceWithStreamingResponse,
-)
-from .projects import ProjectsResource, AsyncProjectsResource
from .projects import (
+ ProjectsResource,
+ AsyncProjectsResource,
ProjectsResourceWithRawResponse,
AsyncProjectsResourceWithRawResponse,
ProjectsResourceWithStreamingResponse,
AsyncProjectsResourceWithStreamingResponse,
)
+from .inference_pipelines import (
+ InferencePipelinesResource,
+ AsyncInferencePipelinesResource,
+ InferencePipelinesResourceWithRawResponse,
+ AsyncInferencePipelinesResourceWithRawResponse,
+ InferencePipelinesResourceWithStreamingResponse,
+ AsyncInferencePipelinesResourceWithStreamingResponse,
+)
__all__ = [
+ "ProjectsResource",
+ "AsyncProjectsResource",
+ "ProjectsResourceWithRawResponse",
+ "AsyncProjectsResourceWithRawResponse",
+ "ProjectsResourceWithStreamingResponse",
+ "AsyncProjectsResourceWithStreamingResponse",
"CommitsResource",
"AsyncCommitsResource",
"CommitsResourceWithRawResponse",
@@ -35,10 +44,4 @@
"AsyncInferencePipelinesResourceWithRawResponse",
"InferencePipelinesResourceWithStreamingResponse",
"AsyncInferencePipelinesResourceWithStreamingResponse",
- "ProjectsResource",
- "AsyncProjectsResource",
- "ProjectsResourceWithRawResponse",
- "AsyncProjectsResourceWithRawResponse",
- "ProjectsResourceWithStreamingResponse",
- "AsyncProjectsResourceWithStreamingResponse",
]
diff --git a/src/openlayer-test/resources/commits/__init__.py b/src/openlayer/resources/commits/__init__.py
similarity index 88%
rename from src/openlayer-test/resources/commits/__init__.py
rename to src/openlayer/resources/commits/__init__.py
index 19d177aa..7ff3a88a 100644
--- a/src/openlayer-test/resources/commits/__init__.py
+++ b/src/openlayer/resources/commits/__init__.py
@@ -1,19 +1,21 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from .test_results import TestResultsResource, AsyncTestResultsResource
-from .test_results import (
- TestResultsResourceWithRawResponse,
- AsyncTestResultsResourceWithRawResponse,
- TestResultsResourceWithStreamingResponse,
- AsyncTestResultsResourceWithStreamingResponse,
-)
-from .commits import CommitsResource, AsyncCommitsResource
from .commits import (
+ CommitsResource,
+ AsyncCommitsResource,
CommitsResourceWithRawResponse,
AsyncCommitsResourceWithRawResponse,
CommitsResourceWithStreamingResponse,
AsyncCommitsResourceWithStreamingResponse,
)
+from .test_results import (
+ TestResultsResource,
+ AsyncTestResultsResource,
+ TestResultsResourceWithRawResponse,
+ AsyncTestResultsResourceWithRawResponse,
+ TestResultsResourceWithStreamingResponse,
+ AsyncTestResultsResourceWithStreamingResponse,
+)
__all__ = [
"TestResultsResource",
diff --git a/src/openlayer-test/resources/commits/commits.py b/src/openlayer/resources/commits/commits.py
similarity index 81%
rename from src/openlayer-test/resources/commits/commits.py
rename to src/openlayer/resources/commits/commits.py
index aa687549..e9c62f89 100644
--- a/src/openlayer-test/resources/commits/commits.py
+++ b/src/openlayer/resources/commits/commits.py
@@ -2,25 +2,8 @@
from __future__ import annotations
-from .test_results import TestResultsResource, AsyncTestResultsResource
-
from ..._compat import cached_property
-
-import warnings
-from typing import TYPE_CHECKING, Optional, Union, List, Dict, Any, Mapping, cast, overload
-from typing_extensions import Literal
-from ..._utils import extract_files, maybe_transform, required_args, deepcopy_minimal, strip_not_given
-from ..._types import NotGiven, Timeout, Headers, NoneType, Query, Body, NOT_GIVEN, FileTypes, BinaryResponseContent
from ..._resource import SyncAPIResource, AsyncAPIResource
-from ..._base_client import (
- SyncAPIClient,
- AsyncAPIClient,
- _merge_mappings,
- AsyncPaginator,
- make_request_options,
- HttpxBinaryResponseContent,
-)
-from ...types import shared_params
from .test_results import (
TestResultsResource,
AsyncTestResultsResource,
diff --git a/src/openlayer-test/resources/commits/test_results.py b/src/openlayer/resources/commits/test_results.py
similarity index 93%
rename from src/openlayer-test/resources/commits/test_results.py
rename to src/openlayer/resources/commits/test_results.py
index 2521d532..f7aa939a 100644
--- a/src/openlayer-test/resources/commits/test_results.py
+++ b/src/openlayer/resources/commits/test_results.py
@@ -2,39 +2,28 @@
from __future__ import annotations
+from typing_extensions import Literal
+
import httpx
+from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ..._utils import (
+ maybe_transform,
+ async_maybe_transform,
+)
from ..._compat import cached_property
-
-from ...types.commits.test_result_list_response import TestResultListResponse
-
-from ..._utils import maybe_transform, async_maybe_transform
-
-from typing_extensions import Literal
-
+from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
to_raw_response_wrapper,
- async_to_raw_response_wrapper,
to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
-
-import warnings
-from typing import TYPE_CHECKING, Optional, Union, List, Dict, Any, Mapping, cast, overload
-from typing_extensions import Literal
-from ..._utils import extract_files, maybe_transform, required_args, deepcopy_minimal, strip_not_given
-from ..._types import NotGiven, Timeout, Headers, NoneType, Query, Body, NOT_GIVEN, FileTypes, BinaryResponseContent
-from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._base_client import (
- SyncAPIClient,
- AsyncAPIClient,
- _merge_mappings,
- AsyncPaginator,
make_request_options,
- HttpxBinaryResponseContent,
)
-from ...types import shared_params
from ...types.commits import test_result_list_params
+from ...types.commits.test_result_list_response import TestResultListResponse
__all__ = ["TestResultsResource", "AsyncTestResultsResource"]
diff --git a/src/openlayer-test/resources/inference_pipelines/__init__.py b/src/openlayer/resources/inference_pipelines/__init__.py
similarity index 87%
rename from src/openlayer-test/resources/inference_pipelines/__init__.py
rename to src/openlayer/resources/inference_pipelines/__init__.py
index 4d323c24..fada9d79 100644
--- a/src/openlayer-test/resources/inference_pipelines/__init__.py
+++ b/src/openlayer/resources/inference_pipelines/__init__.py
@@ -1,21 +1,24 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from .data import DataResource, AsyncDataResource
from .data import (
+ DataResource,
+ AsyncDataResource,
DataResourceWithRawResponse,
AsyncDataResourceWithRawResponse,
DataResourceWithStreamingResponse,
AsyncDataResourceWithStreamingResponse,
)
-from .test_results import TestResultsResource, AsyncTestResultsResource
from .test_results import (
+ TestResultsResource,
+ AsyncTestResultsResource,
TestResultsResourceWithRawResponse,
AsyncTestResultsResourceWithRawResponse,
TestResultsResourceWithStreamingResponse,
AsyncTestResultsResourceWithStreamingResponse,
)
-from .inference_pipelines import InferencePipelinesResource, AsyncInferencePipelinesResource
from .inference_pipelines import (
+ InferencePipelinesResource,
+ AsyncInferencePipelinesResource,
InferencePipelinesResourceWithRawResponse,
AsyncInferencePipelinesResourceWithRawResponse,
InferencePipelinesResourceWithStreamingResponse,
diff --git a/src/openlayer-test/resources/inference_pipelines/data.py b/src/openlayer/resources/inference_pipelines/data.py
similarity index 89%
rename from src/openlayer-test/resources/inference_pipelines/data.py
rename to src/openlayer/resources/inference_pipelines/data.py
index cf52cf95..00199059 100644
--- a/src/openlayer-test/resources/inference_pipelines/data.py
+++ b/src/openlayer/resources/inference_pipelines/data.py
@@ -2,41 +2,28 @@
from __future__ import annotations
+from typing import Dict, Iterable
+
import httpx
+from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ..._utils import (
+ maybe_transform,
+ async_maybe_transform,
+)
from ..._compat import cached_property
-
-from ...types.inference_pipelines.data_stream_response import DataStreamResponse
-
-from ..._utils import maybe_transform, async_maybe_transform
-
-from typing import Iterable, Dict
-
+from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
to_raw_response_wrapper,
- async_to_raw_response_wrapper,
to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
-
-from ...types.inference_pipelines import data_stream_params
-
-import warnings
-from typing import TYPE_CHECKING, Optional, Union, List, Dict, Any, Mapping, cast, overload
-from typing_extensions import Literal
-from ..._utils import extract_files, maybe_transform, required_args, deepcopy_minimal, strip_not_given
-from ..._types import NotGiven, Timeout, Headers, NoneType, Query, Body, NOT_GIVEN, FileTypes, BinaryResponseContent
-from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._base_client import (
- SyncAPIClient,
- AsyncAPIClient,
- _merge_mappings,
- AsyncPaginator,
make_request_options,
- HttpxBinaryResponseContent,
)
-from ...types import shared_params
from ...types.inference_pipelines import data_stream_params
+from ...types.inference_pipelines.data_stream_response import DataStreamResponse
__all__ = ["DataResource", "AsyncDataResource"]
diff --git a/src/openlayer-test/resources/inference_pipelines/inference_pipelines.py b/src/openlayer/resources/inference_pipelines/inference_pipelines.py
similarity index 85%
rename from src/openlayer-test/resources/inference_pipelines/inference_pipelines.py
rename to src/openlayer/resources/inference_pipelines/inference_pipelines.py
index 58d706d4..10853fe5 100644
--- a/src/openlayer-test/resources/inference_pipelines/inference_pipelines.py
+++ b/src/openlayer/resources/inference_pipelines/inference_pipelines.py
@@ -2,27 +2,6 @@
from __future__ import annotations
-from .data import DataResource, AsyncDataResource
-
-from ..._compat import cached_property
-
-from .test_results import TestResultsResource, AsyncTestResultsResource
-
-import warnings
-from typing import TYPE_CHECKING, Optional, Union, List, Dict, Any, Mapping, cast, overload
-from typing_extensions import Literal
-from ..._utils import extract_files, maybe_transform, required_args, deepcopy_minimal, strip_not_given
-from ..._types import NotGiven, Timeout, Headers, NoneType, Query, Body, NOT_GIVEN, FileTypes, BinaryResponseContent
-from ..._resource import SyncAPIResource, AsyncAPIResource
-from ..._base_client import (
- SyncAPIClient,
- AsyncAPIClient,
- _merge_mappings,
- AsyncPaginator,
- make_request_options,
- HttpxBinaryResponseContent,
-)
-from ...types import shared_params
from .data import (
DataResource,
AsyncDataResource,
@@ -31,6 +10,8 @@
DataResourceWithStreamingResponse,
AsyncDataResourceWithStreamingResponse,
)
+from ..._compat import cached_property
+from ..._resource import SyncAPIResource, AsyncAPIResource
from .test_results import (
TestResultsResource,
AsyncTestResultsResource,
diff --git a/src/openlayer-test/resources/inference_pipelines/test_results.py b/src/openlayer/resources/inference_pipelines/test_results.py
similarity index 93%
rename from src/openlayer-test/resources/inference_pipelines/test_results.py
rename to src/openlayer/resources/inference_pipelines/test_results.py
index 361681c9..fd63ee8a 100644
--- a/src/openlayer-test/resources/inference_pipelines/test_results.py
+++ b/src/openlayer/resources/inference_pipelines/test_results.py
@@ -2,39 +2,28 @@
from __future__ import annotations
+from typing_extensions import Literal
+
import httpx
+from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ..._utils import (
+ maybe_transform,
+ async_maybe_transform,
+)
from ..._compat import cached_property
-
-from ...types.inference_pipelines.test_result_list_response import TestResultListResponse
-
-from ..._utils import maybe_transform, async_maybe_transform
-
-from typing_extensions import Literal
-
+from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
to_raw_response_wrapper,
- async_to_raw_response_wrapper,
to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
-
-import warnings
-from typing import TYPE_CHECKING, Optional, Union, List, Dict, Any, Mapping, cast, overload
-from typing_extensions import Literal
-from ..._utils import extract_files, maybe_transform, required_args, deepcopy_minimal, strip_not_given
-from ..._types import NotGiven, Timeout, Headers, NoneType, Query, Body, NOT_GIVEN, FileTypes, BinaryResponseContent
-from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._base_client import (
- SyncAPIClient,
- AsyncAPIClient,
- _merge_mappings,
- AsyncPaginator,
make_request_options,
- HttpxBinaryResponseContent,
)
-from ...types import shared_params
from ...types.inference_pipelines import test_result_list_params
+from ...types.inference_pipelines.test_result_list_response import TestResultListResponse
__all__ = ["TestResultsResource", "AsyncTestResultsResource"]
diff --git a/src/openlayer-test/resources/__init__.py b/src/openlayer/resources/projects/__init__.py
similarity index 87%
rename from src/openlayer-test/resources/__init__.py
rename to src/openlayer/resources/projects/__init__.py
index ff23e20e..47503c6d 100644
--- a/src/openlayer-test/resources/__init__.py
+++ b/src/openlayer/resources/projects/__init__.py
@@ -1,21 +1,24 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from .projects import ProjectsResource, AsyncProjectsResource
-from .projects import (
- ProjectsResourceWithRawResponse,
- AsyncProjectsResourceWithRawResponse,
- ProjectsResourceWithStreamingResponse,
- AsyncProjectsResourceWithStreamingResponse,
-)
-from .commits import CommitsResource, AsyncCommitsResource
from .commits import (
+ CommitsResource,
+ AsyncCommitsResource,
CommitsResourceWithRawResponse,
AsyncCommitsResourceWithRawResponse,
CommitsResourceWithStreamingResponse,
AsyncCommitsResourceWithStreamingResponse,
)
-from .inference_pipelines import InferencePipelinesResource, AsyncInferencePipelinesResource
+from .projects import (
+ ProjectsResource,
+ AsyncProjectsResource,
+ ProjectsResourceWithRawResponse,
+ AsyncProjectsResourceWithRawResponse,
+ ProjectsResourceWithStreamingResponse,
+ AsyncProjectsResourceWithStreamingResponse,
+)
from .inference_pipelines import (
+ InferencePipelinesResource,
+ AsyncInferencePipelinesResource,
InferencePipelinesResourceWithRawResponse,
AsyncInferencePipelinesResourceWithRawResponse,
InferencePipelinesResourceWithStreamingResponse,
@@ -23,12 +26,6 @@
)
__all__ = [
- "ProjectsResource",
- "AsyncProjectsResource",
- "ProjectsResourceWithRawResponse",
- "AsyncProjectsResourceWithRawResponse",
- "ProjectsResourceWithStreamingResponse",
- "AsyncProjectsResourceWithStreamingResponse",
"CommitsResource",
"AsyncCommitsResource",
"CommitsResourceWithRawResponse",
@@ -41,4 +38,10 @@
"AsyncInferencePipelinesResourceWithRawResponse",
"InferencePipelinesResourceWithStreamingResponse",
"AsyncInferencePipelinesResourceWithStreamingResponse",
+ "ProjectsResource",
+ "AsyncProjectsResource",
+ "ProjectsResourceWithRawResponse",
+ "AsyncProjectsResourceWithRawResponse",
+ "ProjectsResourceWithStreamingResponse",
+ "AsyncProjectsResourceWithStreamingResponse",
]
diff --git a/src/openlayer-test/resources/projects/commits.py b/src/openlayer/resources/projects/commits.py
similarity index 91%
rename from src/openlayer-test/resources/projects/commits.py
rename to src/openlayer/resources/projects/commits.py
index 44b92c22..0252f17f 100644
--- a/src/openlayer-test/resources/projects/commits.py
+++ b/src/openlayer/resources/projects/commits.py
@@ -4,35 +4,24 @@
import httpx
+from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ..._utils import (
+ maybe_transform,
+ async_maybe_transform,
+)
from ..._compat import cached_property
-
-from ...types.projects.commit_list_response import CommitListResponse
-
-from ..._utils import maybe_transform, async_maybe_transform
-
+from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
to_raw_response_wrapper,
- async_to_raw_response_wrapper,
to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
-
-import warnings
-from typing import TYPE_CHECKING, Optional, Union, List, Dict, Any, Mapping, cast, overload
-from typing_extensions import Literal
-from ..._utils import extract_files, maybe_transform, required_args, deepcopy_minimal, strip_not_given
-from ..._types import NotGiven, Timeout, Headers, NoneType, Query, Body, NOT_GIVEN, FileTypes, BinaryResponseContent
-from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._base_client import (
- SyncAPIClient,
- AsyncAPIClient,
- _merge_mappings,
- AsyncPaginator,
make_request_options,
- HttpxBinaryResponseContent,
)
-from ...types import shared_params
from ...types.projects import commit_list_params
+from ...types.projects.commit_list_response import CommitListResponse
__all__ = ["CommitsResource", "AsyncCommitsResource"]
diff --git a/src/openlayer-test/resources/projects/inference_pipelines.py b/src/openlayer/resources/projects/inference_pipelines.py
similarity index 91%
rename from src/openlayer-test/resources/projects/inference_pipelines.py
rename to src/openlayer/resources/projects/inference_pipelines.py
index ccbc6f83..31b195f1 100644
--- a/src/openlayer-test/resources/projects/inference_pipelines.py
+++ b/src/openlayer/resources/projects/inference_pipelines.py
@@ -4,35 +4,24 @@
import httpx
+from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ..._utils import (
+ maybe_transform,
+ async_maybe_transform,
+)
from ..._compat import cached_property
-
-from ...types.projects.inference_pipeline_list_response import InferencePipelineListResponse
-
-from ..._utils import maybe_transform, async_maybe_transform
-
+from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
to_raw_response_wrapper,
- async_to_raw_response_wrapper,
to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
-
-import warnings
-from typing import TYPE_CHECKING, Optional, Union, List, Dict, Any, Mapping, cast, overload
-from typing_extensions import Literal
-from ..._utils import extract_files, maybe_transform, required_args, deepcopy_minimal, strip_not_given
-from ..._types import NotGiven, Timeout, Headers, NoneType, Query, Body, NOT_GIVEN, FileTypes, BinaryResponseContent
-from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._base_client import (
- SyncAPIClient,
- AsyncAPIClient,
- _merge_mappings,
- AsyncPaginator,
make_request_options,
- HttpxBinaryResponseContent,
)
-from ...types import shared_params
from ...types.projects import inference_pipeline_list_params
+from ...types.projects.inference_pipeline_list_response import InferencePipelineListResponse
__all__ = ["InferencePipelinesResource", "AsyncInferencePipelinesResource"]
diff --git a/src/openlayer-test/resources/projects/projects.py b/src/openlayer/resources/projects/projects.py
similarity index 92%
rename from src/openlayer-test/resources/projects/projects.py
rename to src/openlayer/resources/projects/projects.py
index 5dbe69af..fb5ab1ac 100644
--- a/src/openlayer-test/resources/projects/projects.py
+++ b/src/openlayer/resources/projects/projects.py
@@ -2,42 +2,10 @@
from __future__ import annotations
-import httpx
-
-from .commits import CommitsResource, AsyncCommitsResource
-
-from ..._compat import cached_property
-
-from .inference_pipelines import InferencePipelinesResource, AsyncInferencePipelinesResource
-
-from ...types.project_list_response import ProjectListResponse
-
-from ..._utils import maybe_transform, async_maybe_transform
-
from typing_extensions import Literal
-from ..._response import (
- to_raw_response_wrapper,
- async_to_raw_response_wrapper,
- to_streamed_response_wrapper,
- async_to_streamed_response_wrapper,
-)
+import httpx
-import warnings
-from typing import TYPE_CHECKING, Optional, Union, List, Dict, Any, Mapping, cast, overload
-from typing_extensions import Literal
-from ..._utils import extract_files, maybe_transform, required_args, deepcopy_minimal, strip_not_given
-from ..._types import NotGiven, Timeout, Headers, NoneType, Query, Body, NOT_GIVEN, FileTypes, BinaryResponseContent
-from ..._resource import SyncAPIResource, AsyncAPIResource
-from ..._base_client import (
- SyncAPIClient,
- AsyncAPIClient,
- _merge_mappings,
- AsyncPaginator,
- make_request_options,
- HttpxBinaryResponseContent,
-)
-from ...types import shared_params
from ...types import project_list_params
from .commits import (
CommitsResource,
@@ -47,6 +15,22 @@
CommitsResourceWithStreamingResponse,
AsyncCommitsResourceWithStreamingResponse,
)
+from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ..._utils import (
+ maybe_transform,
+ async_maybe_transform,
+)
+from ..._compat import cached_property
+from ..._resource import SyncAPIResource, AsyncAPIResource
+from ..._response import (
+ to_raw_response_wrapper,
+ to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
+ async_to_streamed_response_wrapper,
+)
+from ..._base_client import (
+ make_request_options,
+)
from .inference_pipelines import (
InferencePipelinesResource,
AsyncInferencePipelinesResource,
@@ -55,6 +39,7 @@
InferencePipelinesResourceWithStreamingResponse,
AsyncInferencePipelinesResourceWithStreamingResponse,
)
+from ...types.project_list_response import ProjectListResponse
__all__ = ["ProjectsResource", "AsyncProjectsResource"]
diff --git a/src/openlayer-test/types/__init__.py b/src/openlayer/types/__init__.py
similarity index 100%
rename from src/openlayer-test/types/__init__.py
rename to src/openlayer/types/__init__.py
index b816f73b..5fee6060 100644
--- a/src/openlayer-test/types/__init__.py
+++ b/src/openlayer/types/__init__.py
@@ -2,5 +2,5 @@
from __future__ import annotations
-from .project_list_response import ProjectListResponse as ProjectListResponse
from .project_list_params import ProjectListParams as ProjectListParams
+from .project_list_response import ProjectListResponse as ProjectListResponse
diff --git a/src/openlayer-test/types/commits/__init__.py b/src/openlayer/types/commits/__init__.py
similarity index 100%
rename from src/openlayer-test/types/commits/__init__.py
rename to src/openlayer/types/commits/__init__.py
index 14ec8a6d..3208a274 100644
--- a/src/openlayer-test/types/commits/__init__.py
+++ b/src/openlayer/types/commits/__init__.py
@@ -2,5 +2,5 @@
from __future__ import annotations
-from .test_result_list_response import TestResultListResponse as TestResultListResponse
from .test_result_list_params import TestResultListParams as TestResultListParams
+from .test_result_list_response import TestResultListResponse as TestResultListResponse
diff --git a/src/openlayer-test/types/commits/test_result_list_params.py b/src/openlayer/types/commits/test_result_list_params.py
similarity index 77%
rename from src/openlayer-test/types/commits/test_result_list_params.py
rename to src/openlayer/types/commits/test_result_list_params.py
index 7ed3cef4..d158bba3 100644
--- a/src/openlayer-test/types/commits/test_result_list_params.py
+++ b/src/openlayer/types/commits/test_result_list_params.py
@@ -2,16 +2,10 @@
from __future__ import annotations
-from typing_extensions import TypedDict, Annotated, Literal
+from typing_extensions import Literal, Annotated, TypedDict
from ..._utils import PropertyInfo
-from typing import List, Union, Dict, Optional
-from typing_extensions import Literal, TypedDict, Required, Annotated
-from ..._types import FileTypes
-from ..._utils import PropertyInfo
-from ...types import shared_params
-
__all__ = ["TestResultListParams"]
diff --git a/src/openlayer-test/types/inference_pipelines/test_result_list_response.py b/src/openlayer/types/commits/test_result_list_response.py
similarity index 96%
rename from src/openlayer-test/types/inference_pipelines/test_result_list_response.py
rename to src/openlayer/types/commits/test_result_list_response.py
index 9f5290ed..b099bfe0 100644
--- a/src/openlayer-test/types/inference_pipelines/test_result_list_response.py
+++ b/src/openlayer/types/commits/test_result_list_response.py
@@ -1,17 +1,12 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from ..._models import BaseModel
-
-from typing import Optional, List, Union
-
+from typing import List, Union, Optional
from datetime import datetime
-
from typing_extensions import Literal
-from typing import Optional, Union, List, Dict, Any
-from typing_extensions import Literal
from pydantic import Field as FieldInfo
-from ...types import shared
+
+from ..._models import BaseModel
__all__ = ["TestResultListResponse", "_Meta", "Item", "ItemGoal", "ItemGoalThreshold"]
diff --git a/src/openlayer-test/types/inference_pipelines/__init__.py b/src/openlayer/types/inference_pipelines/__init__.py
similarity index 100%
rename from src/openlayer-test/types/inference_pipelines/__init__.py
rename to src/openlayer/types/inference_pipelines/__init__.py
index 736dd193..69717a48 100644
--- a/src/openlayer-test/types/inference_pipelines/__init__.py
+++ b/src/openlayer/types/inference_pipelines/__init__.py
@@ -2,7 +2,7 @@
from __future__ import annotations
-from .data_stream_response import DataStreamResponse as DataStreamResponse
from .data_stream_params import DataStreamParams as DataStreamParams
-from .test_result_list_response import TestResultListResponse as TestResultListResponse
+from .data_stream_response import DataStreamResponse as DataStreamResponse
from .test_result_list_params import TestResultListParams as TestResultListParams
+from .test_result_list_response import TestResultListResponse as TestResultListResponse
diff --git a/src/openlayer-test/types/inference_pipelines/data_stream_params.py b/src/openlayer/types/inference_pipelines/data_stream_params.py
similarity index 95%
rename from src/openlayer-test/types/inference_pipelines/data_stream_params.py
rename to src/openlayer/types/inference_pipelines/data_stream_params.py
index 078a5297..b452cb35 100644
--- a/src/openlayer-test/types/inference_pipelines/data_stream_params.py
+++ b/src/openlayer/types/inference_pipelines/data_stream_params.py
@@ -2,17 +2,10 @@
from __future__ import annotations
-from typing_extensions import TypedDict, Required, Annotated
+from typing import Dict, List, Union, Iterable, Optional
+from typing_extensions import Required, Annotated, TypedDict
-from typing import Iterable, Dict, List, Optional, Union
-
-from ..._utils import PropertyInfo
-
-from typing import List, Union, Dict, Optional
-from typing_extensions import Literal, TypedDict, Required, Annotated
-from ..._types import FileTypes
from ..._utils import PropertyInfo
-from ...types import shared_params
__all__ = [
"DataStreamParams",
diff --git a/src/openlayer-test/types/inference_pipelines/data_stream_response.py b/src/openlayer/types/inference_pipelines/data_stream_response.py
similarity index 61%
rename from src/openlayer-test/types/inference_pipelines/data_stream_response.py
rename to src/openlayer/types/inference_pipelines/data_stream_response.py
index 4c408a1e..3863d3ff 100644
--- a/src/openlayer-test/types/inference_pipelines/data_stream_response.py
+++ b/src/openlayer/types/inference_pipelines/data_stream_response.py
@@ -1,13 +1,8 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from ..._models import BaseModel
-
from typing_extensions import Literal
-from typing import Optional, Union, List, Dict, Any
-from typing_extensions import Literal
-from pydantic import Field as FieldInfo
-from ...types import shared
+from ..._models import BaseModel
__all__ = ["DataStreamResponse"]
diff --git a/src/openlayer-test/types/inference_pipelines/test_result_list_params.py b/src/openlayer/types/inference_pipelines/test_result_list_params.py
similarity index 77%
rename from src/openlayer-test/types/inference_pipelines/test_result_list_params.py
rename to src/openlayer/types/inference_pipelines/test_result_list_params.py
index 7ed3cef4..d158bba3 100644
--- a/src/openlayer-test/types/inference_pipelines/test_result_list_params.py
+++ b/src/openlayer/types/inference_pipelines/test_result_list_params.py
@@ -2,16 +2,10 @@
from __future__ import annotations
-from typing_extensions import TypedDict, Annotated, Literal
+from typing_extensions import Literal, Annotated, TypedDict
from ..._utils import PropertyInfo
-from typing import List, Union, Dict, Optional
-from typing_extensions import Literal, TypedDict, Required, Annotated
-from ..._types import FileTypes
-from ..._utils import PropertyInfo
-from ...types import shared_params
-
__all__ = ["TestResultListParams"]
diff --git a/src/openlayer-test/types/commits/test_result_list_response.py b/src/openlayer/types/inference_pipelines/test_result_list_response.py
similarity index 96%
rename from src/openlayer-test/types/commits/test_result_list_response.py
rename to src/openlayer/types/inference_pipelines/test_result_list_response.py
index 9f5290ed..b099bfe0 100644
--- a/src/openlayer-test/types/commits/test_result_list_response.py
+++ b/src/openlayer/types/inference_pipelines/test_result_list_response.py
@@ -1,17 +1,12 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from ..._models import BaseModel
-
-from typing import Optional, List, Union
-
+from typing import List, Union, Optional
from datetime import datetime
-
from typing_extensions import Literal
-from typing import Optional, Union, List, Dict, Any
-from typing_extensions import Literal
from pydantic import Field as FieldInfo
-from ...types import shared
+
+from ..._models import BaseModel
__all__ = ["TestResultListResponse", "_Meta", "Item", "ItemGoal", "ItemGoalThreshold"]
diff --git a/src/openlayer-test/types/project_list_params.py b/src/openlayer/types/project_list_params.py
similarity index 71%
rename from src/openlayer-test/types/project_list_params.py
rename to src/openlayer/types/project_list_params.py
index 361dd31d..6cff1bed 100644
--- a/src/openlayer-test/types/project_list_params.py
+++ b/src/openlayer/types/project_list_params.py
@@ -2,16 +2,10 @@
from __future__ import annotations
-from typing_extensions import TypedDict, Annotated, Literal
+from typing_extensions import Literal, Annotated, TypedDict
from .._utils import PropertyInfo
-from typing import List, Union, Dict, Optional
-from typing_extensions import Literal, TypedDict, Required, Annotated
-from .._types import FileTypes
-from .._utils import PropertyInfo
-from ..types import shared_params
-
__all__ = ["ProjectListParams"]
diff --git a/src/openlayer-test/types/project_list_response.py b/src/openlayer/types/project_list_response.py
similarity index 96%
rename from src/openlayer-test/types/project_list_response.py
rename to src/openlayer/types/project_list_response.py
index e2a57673..3bc1c5a9 100644
--- a/src/openlayer-test/types/project_list_response.py
+++ b/src/openlayer/types/project_list_response.py
@@ -1,17 +1,12 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from .._models import BaseModel
-
+from typing import List, Optional
from datetime import datetime
-
-from typing import Optional, List
-
from typing_extensions import Literal
-from typing import Optional, Union, List, Dict, Any
-from typing_extensions import Literal
from pydantic import Field as FieldInfo
-from ..types import shared
+
+from .._models import BaseModel
__all__ = ["ProjectListResponse", "_Meta", "Item", "ItemLinks", "ItemGitRepo"]
diff --git a/src/openlayer-test/types/projects/__init__.py b/src/openlayer/types/projects/__init__.py
similarity index 100%
rename from src/openlayer-test/types/projects/__init__.py
rename to src/openlayer/types/projects/__init__.py
index d1e6a640..4ab9cf2b 100644
--- a/src/openlayer-test/types/projects/__init__.py
+++ b/src/openlayer/types/projects/__init__.py
@@ -2,7 +2,7 @@
from __future__ import annotations
-from .commit_list_response import CommitListResponse as CommitListResponse
from .commit_list_params import CommitListParams as CommitListParams
-from .inference_pipeline_list_response import InferencePipelineListResponse as InferencePipelineListResponse
+from .commit_list_response import CommitListResponse as CommitListResponse
from .inference_pipeline_list_params import InferencePipelineListParams as InferencePipelineListParams
+from .inference_pipeline_list_response import InferencePipelineListResponse as InferencePipelineListResponse
diff --git a/src/openlayer-test/types/projects/commit_list_params.py b/src/openlayer/types/projects/commit_list_params.py
similarity index 60%
rename from src/openlayer-test/types/projects/commit_list_params.py
rename to src/openlayer/types/projects/commit_list_params.py
index 63653434..45e9fcaa 100644
--- a/src/openlayer-test/types/projects/commit_list_params.py
+++ b/src/openlayer/types/projects/commit_list_params.py
@@ -2,16 +2,10 @@
from __future__ import annotations
-from typing_extensions import TypedDict, Annotated
+from typing_extensions import Annotated, TypedDict
from ..._utils import PropertyInfo
-from typing import List, Union, Dict, Optional
-from typing_extensions import Literal, TypedDict, Required, Annotated
-from ..._types import FileTypes
-from ..._utils import PropertyInfo
-from ...types import shared_params
-
__all__ = ["CommitListParams"]
diff --git a/src/openlayer-test/types/projects/commit_list_response.py b/src/openlayer/types/projects/commit_list_response.py
similarity index 96%
rename from src/openlayer-test/types/projects/commit_list_response.py
rename to src/openlayer/types/projects/commit_list_response.py
index de2c6e6c..d89b9006 100644
--- a/src/openlayer-test/types/projects/commit_list_response.py
+++ b/src/openlayer/types/projects/commit_list_response.py
@@ -1,17 +1,12 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from ..._models import BaseModel
-
-from typing import Optional, List
-
+from typing import List, Optional
from datetime import datetime
-
from typing_extensions import Literal
-from typing import Optional, Union, List, Dict, Any
-from typing_extensions import Literal
from pydantic import Field as FieldInfo
-from ...types import shared
+
+from ..._models import BaseModel
__all__ = ["CommitListResponse", "_Meta", "Item", "ItemCommit", "ItemLinks"]
diff --git a/src/openlayer-test/types/projects/inference_pipeline_list_params.py b/src/openlayer/types/projects/inference_pipeline_list_params.py
similarity index 64%
rename from src/openlayer-test/types/projects/inference_pipeline_list_params.py
rename to src/openlayer/types/projects/inference_pipeline_list_params.py
index 74281e5b..ed30e375 100644
--- a/src/openlayer-test/types/projects/inference_pipeline_list_params.py
+++ b/src/openlayer/types/projects/inference_pipeline_list_params.py
@@ -2,16 +2,10 @@
from __future__ import annotations
-from typing_extensions import TypedDict, Annotated
+from typing_extensions import Annotated, TypedDict
from ..._utils import PropertyInfo
-from typing import List, Union, Dict, Optional
-from typing_extensions import Literal, TypedDict, Required, Annotated
-from ..._types import FileTypes
-from ..._utils import PropertyInfo
-from ...types import shared_params
-
__all__ = ["InferencePipelineListParams"]
diff --git a/src/openlayer-test/types/projects/inference_pipeline_list_response.py b/src/openlayer/types/projects/inference_pipeline_list_response.py
similarity index 94%
rename from src/openlayer-test/types/projects/inference_pipeline_list_response.py
rename to src/openlayer/types/projects/inference_pipeline_list_response.py
index 7e3f0da2..66c9d1b9 100644
--- a/src/openlayer-test/types/projects/inference_pipeline_list_response.py
+++ b/src/openlayer/types/projects/inference_pipeline_list_response.py
@@ -1,17 +1,12 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from ..._models import BaseModel
-
+from typing import List, Optional
from datetime import datetime
-
-from typing import Optional, List
-
from typing_extensions import Literal
-from typing import Optional, Union, List, Dict, Any
-from typing_extensions import Literal
from pydantic import Field as FieldInfo
-from ...types import shared
+
+from ..._models import BaseModel
__all__ = ["InferencePipelineListResponse", "_Meta", "Item", "ItemLinks"]
diff --git a/tests/api_resources/commits/test_test_results.py b/tests/api_resources/commits/test_test_results.py
index f8005a0f..e22aff80 100644
--- a/tests/api_resources/commits/test_test_results.py
+++ b/tests/api_resources/commits/test_test_results.py
@@ -2,34 +2,27 @@
from __future__ import annotations
-from openlayer-test import Openlayer, AsyncOpenlayer
-
-from openlayer-test.types.commits import TestResultListResponse
-
+import os
from typing import Any, cast
-import os
import pytest
-import httpx
-from typing_extensions import get_args
-from typing import Optional
-from respx import MockRouter
-from openlayer-test import Openlayer, AsyncOpenlayer
+
+from openlayer import Openlayer, AsyncOpenlayer
from tests.utils import assert_matches_type
-from openlayer-test.types.commits import test_result_list_params
+from openlayer.types.commits import TestResultListResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-class TestTestResults:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=['loose', 'strict'])
+class TestTestResults:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
def test_method_list(self, client: Openlayer) -> None:
test_result = client.commits.test_results.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Openlayer) -> None:
@@ -41,49 +34,49 @@ def test_method_list_with_all_params(self, client: Openlayer) -> None:
status="passing",
type="integrity",
)
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
@parametrize
def test_raw_response_list(self, client: Openlayer) -> None:
-
response = client.commits.test_results.with_raw_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
assert response.is_closed is True
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
test_result = response.parse()
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Openlayer) -> None:
with client.commits.test_results.with_streaming_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- ) as response :
+ ) as response:
assert not response.is_closed
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
test_result = response.parse()
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_path_params_list(self, client: Openlayer) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- client.commits.test_results.with_raw_response.list(
- "",
- )
-class TestAsyncTestResults:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=['loose', 'strict'])
+ client.commits.test_results.with_raw_response.list(
+ "",
+ )
+class TestAsyncTestResults:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
@parametrize
async def test_method_list(self, async_client: AsyncOpenlayer) -> None:
test_result = await async_client.commits.test_results.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncOpenlayer) -> None:
@@ -95,36 +88,35 @@ async def test_method_list_with_all_params(self, async_client: AsyncOpenlayer) -
status="passing",
type="integrity",
)
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncOpenlayer) -> None:
-
response = await async_client.commits.test_results.with_raw_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
assert response.is_closed is True
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
test_result = await response.parse()
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncOpenlayer) -> None:
async with async_client.commits.test_results.with_streaming_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- ) as response :
+ ) as response:
assert not response.is_closed
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
test_result = await response.parse()
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_path_params_list(self, async_client: AsyncOpenlayer) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- await async_client.commits.test_results.with_raw_response.list(
- "",
- )
\ No newline at end of file
+ await async_client.commits.test_results.with_raw_response.list(
+ "",
+ )
diff --git a/tests/api_resources/inference_pipelines/test_data.py b/tests/api_resources/inference_pipelines/test_data.py
index 3fe72f9c..1e070c1b 100644
--- a/tests/api_resources/inference_pipelines/test_data.py
+++ b/tests/api_resources/inference_pipelines/test_data.py
@@ -2,44 +2,37 @@
from __future__ import annotations
-from openlayer-test import Openlayer, AsyncOpenlayer
-
-from openlayer-test.types.inference_pipelines import DataStreamResponse
-
+import os
from typing import Any, cast
-import os
import pytest
-import httpx
-from typing_extensions import get_args
-from typing import Optional
-from respx import MockRouter
-from openlayer-test import Openlayer, AsyncOpenlayer
+
+from openlayer import Openlayer, AsyncOpenlayer
from tests.utils import assert_matches_type
-from openlayer-test.types.inference_pipelines import data_stream_params
+from openlayer.types.inference_pipelines import DataStreamResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-class TestData:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=['loose', 'strict'])
+class TestData:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
def test_method_stream(self, client: Openlayer) -> None:
data = client.inference_pipelines.data.stream(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- config={
- "output_column_name": "output"
- },
- rows=[{
- "user_query": "bar",
- "output": "bar",
- "tokens": "bar",
- "cost": "bar",
- "timestamp": "bar",
- }],
+ config={"output_column_name": "output"},
+ rows=[
+ {
+ "user_query": "bar",
+ "output": "bar",
+ "tokens": "bar",
+ "cost": "bar",
+ "timestamp": "bar",
+ }
+ ],
)
- assert_matches_type(DataStreamResponse, data, path=['response'])
+ assert_matches_type(DataStreamResponse, data, path=["response"])
@parametrize
def test_method_stream_with_all_params(self, client: Openlayer) -> None:
@@ -55,104 +48,108 @@ def test_method_stream_with_all_params(self, client: Openlayer) -> None:
"latency_column_name": "latency",
"metadata": {},
"output_column_name": "output",
- "prompt": [{
- "role": "user",
- "content": "{{ user_query }}",
- }],
+ "prompt": [
+ {
+ "role": "user",
+ "content": "{{ user_query }}",
+ }
+ ],
"question_column_name": "question",
"timestamp_column_name": "timestamp",
},
- rows=[{
- "user_query": "bar",
- "output": "bar",
- "tokens": "bar",
- "cost": "bar",
- "timestamp": "bar",
- }],
+ rows=[
+ {
+ "user_query": "bar",
+ "output": "bar",
+ "tokens": "bar",
+ "cost": "bar",
+ "timestamp": "bar",
+ }
+ ],
)
- assert_matches_type(DataStreamResponse, data, path=['response'])
+ assert_matches_type(DataStreamResponse, data, path=["response"])
@parametrize
def test_raw_response_stream(self, client: Openlayer) -> None:
-
response = client.inference_pipelines.data.with_raw_response.stream(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- config={
- "output_column_name": "output"
- },
- rows=[{
- "user_query": "bar",
- "output": "bar",
- "tokens": "bar",
- "cost": "bar",
- "timestamp": "bar",
- }],
+ config={"output_column_name": "output"},
+ rows=[
+ {
+ "user_query": "bar",
+ "output": "bar",
+ "tokens": "bar",
+ "cost": "bar",
+ "timestamp": "bar",
+ }
+ ],
)
assert response.is_closed is True
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
data = response.parse()
- assert_matches_type(DataStreamResponse, data, path=['response'])
+ assert_matches_type(DataStreamResponse, data, path=["response"])
@parametrize
def test_streaming_response_stream(self, client: Openlayer) -> None:
with client.inference_pipelines.data.with_streaming_response.stream(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- config={
- "output_column_name": "output"
- },
- rows=[{
- "user_query": "bar",
- "output": "bar",
- "tokens": "bar",
- "cost": "bar",
- "timestamp": "bar",
- }],
- ) as response :
+ config={"output_column_name": "output"},
+ rows=[
+ {
+ "user_query": "bar",
+ "output": "bar",
+ "tokens": "bar",
+ "cost": "bar",
+ "timestamp": "bar",
+ }
+ ],
+ ) as response:
assert not response.is_closed
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
data = response.parse()
- assert_matches_type(DataStreamResponse, data, path=['response'])
+ assert_matches_type(DataStreamResponse, data, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_path_params_stream(self, client: Openlayer) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- client.inference_pipelines.data.with_raw_response.stream(
- "",
- config={
- "output_column_name": "output"
- },
- rows=[{
- "user_query": "bar",
- "output": "bar",
- "tokens": "bar",
- "cost": "bar",
- "timestamp": "bar",
- }],
- )
-class TestAsyncData:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=['loose', 'strict'])
+ client.inference_pipelines.data.with_raw_response.stream(
+ "",
+ config={"output_column_name": "output"},
+ rows=[
+ {
+ "user_query": "bar",
+ "output": "bar",
+ "tokens": "bar",
+ "cost": "bar",
+ "timestamp": "bar",
+ }
+ ],
+ )
+class TestAsyncData:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
@parametrize
async def test_method_stream(self, async_client: AsyncOpenlayer) -> None:
data = await async_client.inference_pipelines.data.stream(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- config={
- "output_column_name": "output"
- },
- rows=[{
- "user_query": "bar",
- "output": "bar",
- "tokens": "bar",
- "cost": "bar",
- "timestamp": "bar",
- }],
+ config={"output_column_name": "output"},
+ rows=[
+ {
+ "user_query": "bar",
+ "output": "bar",
+ "tokens": "bar",
+ "cost": "bar",
+ "timestamp": "bar",
+ }
+ ],
)
- assert_matches_type(DataStreamResponse, data, path=['response'])
+ assert_matches_type(DataStreamResponse, data, path=["response"])
@parametrize
async def test_method_stream_with_all_params(self, async_client: AsyncOpenlayer) -> None:
@@ -168,81 +165,84 @@ async def test_method_stream_with_all_params(self, async_client: AsyncOpenlayer)
"latency_column_name": "latency",
"metadata": {},
"output_column_name": "output",
- "prompt": [{
- "role": "user",
- "content": "{{ user_query }}",
- }],
+ "prompt": [
+ {
+ "role": "user",
+ "content": "{{ user_query }}",
+ }
+ ],
"question_column_name": "question",
"timestamp_column_name": "timestamp",
},
- rows=[{
- "user_query": "bar",
- "output": "bar",
- "tokens": "bar",
- "cost": "bar",
- "timestamp": "bar",
- }],
+ rows=[
+ {
+ "user_query": "bar",
+ "output": "bar",
+ "tokens": "bar",
+ "cost": "bar",
+ "timestamp": "bar",
+ }
+ ],
)
- assert_matches_type(DataStreamResponse, data, path=['response'])
+ assert_matches_type(DataStreamResponse, data, path=["response"])
@parametrize
async def test_raw_response_stream(self, async_client: AsyncOpenlayer) -> None:
-
response = await async_client.inference_pipelines.data.with_raw_response.stream(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- config={
- "output_column_name": "output"
- },
- rows=[{
- "user_query": "bar",
- "output": "bar",
- "tokens": "bar",
- "cost": "bar",
- "timestamp": "bar",
- }],
+ config={"output_column_name": "output"},
+ rows=[
+ {
+ "user_query": "bar",
+ "output": "bar",
+ "tokens": "bar",
+ "cost": "bar",
+ "timestamp": "bar",
+ }
+ ],
)
assert response.is_closed is True
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
data = await response.parse()
- assert_matches_type(DataStreamResponse, data, path=['response'])
+ assert_matches_type(DataStreamResponse, data, path=["response"])
@parametrize
async def test_streaming_response_stream(self, async_client: AsyncOpenlayer) -> None:
async with async_client.inference_pipelines.data.with_streaming_response.stream(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- config={
- "output_column_name": "output"
- },
- rows=[{
- "user_query": "bar",
- "output": "bar",
- "tokens": "bar",
- "cost": "bar",
- "timestamp": "bar",
- }],
- ) as response :
+ config={"output_column_name": "output"},
+ rows=[
+ {
+ "user_query": "bar",
+ "output": "bar",
+ "tokens": "bar",
+ "cost": "bar",
+ "timestamp": "bar",
+ }
+ ],
+ ) as response:
assert not response.is_closed
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
data = await response.parse()
- assert_matches_type(DataStreamResponse, data, path=['response'])
+ assert_matches_type(DataStreamResponse, data, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_path_params_stream(self, async_client: AsyncOpenlayer) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- await async_client.inference_pipelines.data.with_raw_response.stream(
- "",
- config={
- "output_column_name": "output"
- },
- rows=[{
- "user_query": "bar",
- "output": "bar",
- "tokens": "bar",
- "cost": "bar",
- "timestamp": "bar",
- }],
- )
\ No newline at end of file
+ await async_client.inference_pipelines.data.with_raw_response.stream(
+ "",
+ config={"output_column_name": "output"},
+ rows=[
+ {
+ "user_query": "bar",
+ "output": "bar",
+ "tokens": "bar",
+ "cost": "bar",
+ "timestamp": "bar",
+ }
+ ],
+ )
diff --git a/tests/api_resources/inference_pipelines/test_test_results.py b/tests/api_resources/inference_pipelines/test_test_results.py
index 081159a6..2098230a 100644
--- a/tests/api_resources/inference_pipelines/test_test_results.py
+++ b/tests/api_resources/inference_pipelines/test_test_results.py
@@ -2,34 +2,27 @@
from __future__ import annotations
-from openlayer-test import Openlayer, AsyncOpenlayer
-
-from openlayer-test.types.inference_pipelines import TestResultListResponse
-
+import os
from typing import Any, cast
-import os
import pytest
-import httpx
-from typing_extensions import get_args
-from typing import Optional
-from respx import MockRouter
-from openlayer-test import Openlayer, AsyncOpenlayer
+
+from openlayer import Openlayer, AsyncOpenlayer
from tests.utils import assert_matches_type
-from openlayer-test.types.inference_pipelines import test_result_list_params
+from openlayer.types.inference_pipelines import TestResultListResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-class TestTestResults:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=['loose', 'strict'])
+class TestTestResults:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
def test_method_list(self, client: Openlayer) -> None:
test_result = client.inference_pipelines.test_results.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Openlayer) -> None:
@@ -41,49 +34,49 @@ def test_method_list_with_all_params(self, client: Openlayer) -> None:
status="passing",
type="integrity",
)
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
@parametrize
def test_raw_response_list(self, client: Openlayer) -> None:
-
response = client.inference_pipelines.test_results.with_raw_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
assert response.is_closed is True
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
test_result = response.parse()
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Openlayer) -> None:
with client.inference_pipelines.test_results.with_streaming_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- ) as response :
+ ) as response:
assert not response.is_closed
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
test_result = response.parse()
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_path_params_list(self, client: Openlayer) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- client.inference_pipelines.test_results.with_raw_response.list(
- "",
- )
-class TestAsyncTestResults:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=['loose', 'strict'])
+ client.inference_pipelines.test_results.with_raw_response.list(
+ "",
+ )
+class TestAsyncTestResults:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
@parametrize
async def test_method_list(self, async_client: AsyncOpenlayer) -> None:
test_result = await async_client.inference_pipelines.test_results.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncOpenlayer) -> None:
@@ -95,36 +88,35 @@ async def test_method_list_with_all_params(self, async_client: AsyncOpenlayer) -
status="passing",
type="integrity",
)
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncOpenlayer) -> None:
-
response = await async_client.inference_pipelines.test_results.with_raw_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
assert response.is_closed is True
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
test_result = await response.parse()
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncOpenlayer) -> None:
async with async_client.inference_pipelines.test_results.with_streaming_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- ) as response :
+ ) as response:
assert not response.is_closed
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
test_result = await response.parse()
- assert_matches_type(TestResultListResponse, test_result, path=['response'])
+ assert_matches_type(TestResultListResponse, test_result, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_path_params_list(self, async_client: AsyncOpenlayer) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- await async_client.inference_pipelines.test_results.with_raw_response.list(
- "",
- )
\ No newline at end of file
+ await async_client.inference_pipelines.test_results.with_raw_response.list(
+ "",
+ )
diff --git a/tests/api_resources/projects/test_commits.py b/tests/api_resources/projects/test_commits.py
index 0fc0e3f6..ab353674 100644
--- a/tests/api_resources/projects/test_commits.py
+++ b/tests/api_resources/projects/test_commits.py
@@ -2,34 +2,27 @@
from __future__ import annotations
-from openlayer-test import Openlayer, AsyncOpenlayer
-
-from openlayer-test.types.projects import CommitListResponse
-
+import os
from typing import Any, cast
-import os
import pytest
-import httpx
-from typing_extensions import get_args
-from typing import Optional
-from respx import MockRouter
-from openlayer-test import Openlayer, AsyncOpenlayer
+
+from openlayer import Openlayer, AsyncOpenlayer
from tests.utils import assert_matches_type
-from openlayer-test.types.projects import commit_list_params
+from openlayer.types.projects import CommitListResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-class TestCommits:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=['loose', 'strict'])
+class TestCommits:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
def test_method_list(self, client: Openlayer) -> None:
commit = client.projects.commits.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
- assert_matches_type(CommitListResponse, commit, path=['response'])
+ assert_matches_type(CommitListResponse, commit, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Openlayer) -> None:
@@ -38,49 +31,49 @@ def test_method_list_with_all_params(self, client: Openlayer) -> None:
page=1,
per_page=1,
)
- assert_matches_type(CommitListResponse, commit, path=['response'])
+ assert_matches_type(CommitListResponse, commit, path=["response"])
@parametrize
def test_raw_response_list(self, client: Openlayer) -> None:
-
response = client.projects.commits.with_raw_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
assert response.is_closed is True
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
commit = response.parse()
- assert_matches_type(CommitListResponse, commit, path=['response'])
+ assert_matches_type(CommitListResponse, commit, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Openlayer) -> None:
with client.projects.commits.with_streaming_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- ) as response :
+ ) as response:
assert not response.is_closed
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
commit = response.parse()
- assert_matches_type(CommitListResponse, commit, path=['response'])
+ assert_matches_type(CommitListResponse, commit, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_path_params_list(self, client: Openlayer) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- client.projects.commits.with_raw_response.list(
- "",
- )
-class TestAsyncCommits:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=['loose', 'strict'])
+ client.projects.commits.with_raw_response.list(
+ "",
+ )
+class TestAsyncCommits:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
@parametrize
async def test_method_list(self, async_client: AsyncOpenlayer) -> None:
commit = await async_client.projects.commits.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
- assert_matches_type(CommitListResponse, commit, path=['response'])
+ assert_matches_type(CommitListResponse, commit, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncOpenlayer) -> None:
@@ -89,36 +82,35 @@ async def test_method_list_with_all_params(self, async_client: AsyncOpenlayer) -
page=1,
per_page=1,
)
- assert_matches_type(CommitListResponse, commit, path=['response'])
+ assert_matches_type(CommitListResponse, commit, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncOpenlayer) -> None:
-
response = await async_client.projects.commits.with_raw_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
assert response.is_closed is True
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
commit = await response.parse()
- assert_matches_type(CommitListResponse, commit, path=['response'])
+ assert_matches_type(CommitListResponse, commit, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncOpenlayer) -> None:
async with async_client.projects.commits.with_streaming_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- ) as response :
+ ) as response:
assert not response.is_closed
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
commit = await response.parse()
- assert_matches_type(CommitListResponse, commit, path=['response'])
+ assert_matches_type(CommitListResponse, commit, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_path_params_list(self, async_client: AsyncOpenlayer) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- await async_client.projects.commits.with_raw_response.list(
- "",
- )
\ No newline at end of file
+ await async_client.projects.commits.with_raw_response.list(
+ "",
+ )
diff --git a/tests/api_resources/projects/test_inference_pipelines.py b/tests/api_resources/projects/test_inference_pipelines.py
index 45de3a34..c676d606 100644
--- a/tests/api_resources/projects/test_inference_pipelines.py
+++ b/tests/api_resources/projects/test_inference_pipelines.py
@@ -2,34 +2,27 @@
from __future__ import annotations
-from openlayer-test import Openlayer, AsyncOpenlayer
-
-from openlayer-test.types.projects import InferencePipelineListResponse
-
+import os
from typing import Any, cast
-import os
import pytest
-import httpx
-from typing_extensions import get_args
-from typing import Optional
-from respx import MockRouter
-from openlayer-test import Openlayer, AsyncOpenlayer
+
+from openlayer import Openlayer, AsyncOpenlayer
from tests.utils import assert_matches_type
-from openlayer-test.types.projects import inference_pipeline_list_params
+from openlayer.types.projects import InferencePipelineListResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-class TestInferencePipelines:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=['loose', 'strict'])
+class TestInferencePipelines:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
def test_method_list(self, client: Openlayer) -> None:
inference_pipeline = client.projects.inference_pipelines.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
- assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=['response'])
+ assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Openlayer) -> None:
@@ -39,49 +32,49 @@ def test_method_list_with_all_params(self, client: Openlayer) -> None:
page=1,
per_page=1,
)
- assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=['response'])
+ assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=["response"])
@parametrize
def test_raw_response_list(self, client: Openlayer) -> None:
-
response = client.projects.inference_pipelines.with_raw_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
assert response.is_closed is True
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
inference_pipeline = response.parse()
- assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=['response'])
+ assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Openlayer) -> None:
with client.projects.inference_pipelines.with_streaming_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- ) as response :
+ ) as response:
assert not response.is_closed
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
inference_pipeline = response.parse()
- assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=['response'])
+ assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_path_params_list(self, client: Openlayer) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- client.projects.inference_pipelines.with_raw_response.list(
- "",
- )
-class TestAsyncInferencePipelines:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=['loose', 'strict'])
+ client.projects.inference_pipelines.with_raw_response.list(
+ "",
+ )
+class TestAsyncInferencePipelines:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
@parametrize
async def test_method_list(self, async_client: AsyncOpenlayer) -> None:
inference_pipeline = await async_client.projects.inference_pipelines.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
- assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=['response'])
+ assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncOpenlayer) -> None:
@@ -91,36 +84,35 @@ async def test_method_list_with_all_params(self, async_client: AsyncOpenlayer) -
page=1,
per_page=1,
)
- assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=['response'])
+ assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncOpenlayer) -> None:
-
response = await async_client.projects.inference_pipelines.with_raw_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
assert response.is_closed is True
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
inference_pipeline = await response.parse()
- assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=['response'])
+ assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncOpenlayer) -> None:
async with async_client.projects.inference_pipelines.with_streaming_response.list(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
- ) as response :
+ ) as response:
assert not response.is_closed
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
inference_pipeline = await response.parse()
- assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=['response'])
+ assert_matches_type(InferencePipelineListResponse, inference_pipeline, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_path_params_list(self, async_client: AsyncOpenlayer) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
- await async_client.projects.inference_pipelines.with_raw_response.list(
- "",
- )
\ No newline at end of file
+ await async_client.projects.inference_pipelines.with_raw_response.list(
+ "",
+ )
diff --git a/tests/api_resources/test_projects.py b/tests/api_resources/test_projects.py
index b2530e89..a955b36d 100644
--- a/tests/api_resources/test_projects.py
+++ b/tests/api_resources/test_projects.py
@@ -2,32 +2,25 @@
from __future__ import annotations
-from openlayer-test import Openlayer, AsyncOpenlayer
-
-from openlayer-test.types import ProjectListResponse
-
+import os
from typing import Any, cast
-import os
import pytest
-import httpx
-from typing_extensions import get_args
-from typing import Optional
-from respx import MockRouter
-from openlayer-test import Openlayer, AsyncOpenlayer
+
+from openlayer import Openlayer, AsyncOpenlayer
from tests.utils import assert_matches_type
-from openlayer-test.types import project_list_params
+from openlayer.types import ProjectListResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-class TestProjects:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=['loose', 'strict'])
+class TestProjects:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
def test_method_list(self, client: Openlayer) -> None:
project = client.projects.list()
- assert_matches_type(ProjectListResponse, project, path=['response'])
+ assert_matches_type(ProjectListResponse, project, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Openlayer) -> None:
@@ -37,36 +30,36 @@ def test_method_list_with_all_params(self, client: Openlayer) -> None:
per_page=1,
task_type="llm-base",
)
- assert_matches_type(ProjectListResponse, project, path=['response'])
+ assert_matches_type(ProjectListResponse, project, path=["response"])
@parametrize
def test_raw_response_list(self, client: Openlayer) -> None:
-
response = client.projects.with_raw_response.list()
assert response.is_closed is True
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
project = response.parse()
- assert_matches_type(ProjectListResponse, project, path=['response'])
+ assert_matches_type(ProjectListResponse, project, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Openlayer) -> None:
- with client.projects.with_streaming_response.list() as response :
+ with client.projects.with_streaming_response.list() as response:
assert not response.is_closed
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
project = response.parse()
- assert_matches_type(ProjectListResponse, project, path=['response'])
+ assert_matches_type(ProjectListResponse, project, path=["response"])
assert cast(Any, response.is_closed) is True
-class TestAsyncProjects:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=['loose', 'strict'])
+class TestAsyncProjects:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
@parametrize
async def test_method_list(self, async_client: AsyncOpenlayer) -> None:
project = await async_client.projects.list()
- assert_matches_type(ProjectListResponse, project, path=['response'])
+ assert_matches_type(ProjectListResponse, project, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncOpenlayer) -> None:
@@ -76,25 +69,24 @@ async def test_method_list_with_all_params(self, async_client: AsyncOpenlayer) -
per_page=1,
task_type="llm-base",
)
- assert_matches_type(ProjectListResponse, project, path=['response'])
+ assert_matches_type(ProjectListResponse, project, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncOpenlayer) -> None:
-
response = await async_client.projects.with_raw_response.list()
assert response.is_closed is True
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
project = await response.parse()
- assert_matches_type(ProjectListResponse, project, path=['response'])
+ assert_matches_type(ProjectListResponse, project, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncOpenlayer) -> None:
- async with async_client.projects.with_streaming_response.list() as response :
+ async with async_client.projects.with_streaming_response.list() as response:
assert not response.is_closed
- assert response.http_request.headers.get('X-Stainless-Lang') == 'python'
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
project = await response.parse()
- assert_matches_type(ProjectListResponse, project, path=['response'])
+ assert_matches_type(ProjectListResponse, project, path=["response"])
- assert cast(Any, response.is_closed) is True
\ No newline at end of file
+ assert cast(Any, response.is_closed) is True
diff --git a/tests/conftest.py b/tests/conftest.py
index 232d3fe2..0857c182 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,22 +1,20 @@
from __future__ import annotations
+import os
import asyncio
import logging
-from typing import Iterator
+from typing import TYPE_CHECKING, Iterator, AsyncIterator
import pytest
-import os
-from typing import TYPE_CHECKING, AsyncIterator
-
-from openlayer-test import Openlayer, AsyncOpenlayer
+from openlayer import Openlayer, AsyncOpenlayer
if TYPE_CHECKING:
- from _pytest.fixtures import FixtureRequest
+ from _pytest.fixtures import FixtureRequest
pytest.register_assert_rewrite("tests.utils")
-logging.getLogger("openlayer-test").setLevel(logging.DEBUG)
+logging.getLogger("openlayer").setLevel(logging.DEBUG)
@pytest.fixture(scope="session")
@@ -30,20 +28,22 @@ def event_loop() -> Iterator[asyncio.AbstractEventLoop]:
api_key = "My API Key"
+
@pytest.fixture(scope="session")
def client(request: FixtureRequest) -> Iterator[Openlayer]:
- strict = getattr(request, 'param', True)
+ strict = getattr(request, "param", True)
if not isinstance(strict, bool):
- raise TypeError(f'Unexpected fixture parameter type {type(strict)}, expected {bool}')
+ raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
- with Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client :
+ with Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client:
yield client
+
@pytest.fixture(scope="session")
async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncOpenlayer]:
- strict = getattr(request, 'param', True)
+ strict = getattr(request, "param", True)
if not isinstance(strict, bool):
- raise TypeError(f'Unexpected fixture parameter type {type(strict)}, expected {bool}')
+ raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
- async with AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client :
+ async with AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client:
yield client
diff --git a/tests/test_client.py b/tests/test_client.py
index 6ce88083..bc8b3c26 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -2,51 +2,48 @@
from __future__ import annotations
-import httpx
-
-from openlayer-test import Openlayer, AsyncOpenlayer
-
-from openlayer-test._exceptions import APITimeoutError, APIStatusError, APIResponseValidationError
-
-from typing import Any, cast
-
-from pydantic import ValidationError
-
-import asyncio
import gc
-import inspect
-import json
import os
+import json
+import asyncio
+import inspect
import tracemalloc
-from typing import Dict, Any, Union, cast
+from typing import Any, Union, cast
from unittest import mock
import httpx
import pytest
from respx import MockRouter
+from pydantic import ValidationError
+
+from openlayer import Openlayer, AsyncOpenlayer, APIResponseValidationError
+from openlayer._types import Omit
+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,
+ make_request_options,
+)
-from openlayer-test import Openlayer, AsyncOpenlayer, APIResponseValidationError
-from openlayer-test._models import FinalRequestOptions, BaseModel
-from openlayer-test._types import NOT_GIVEN, Headers, NotGiven, Query, Body, Timeout, Omit
-from openlayer-test._base_client import DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, RequestOptions, make_request_options
-from openlayer-test._streaming import Stream, AsyncStream
-from openlayer-test._constants import RAW_RESPONSE_HEADER
-from openlayer-test._response import APIResponse, AsyncAPIResponse
from .utils import update_env
-from typing import cast
-from typing import cast
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
api_key = "My API Key"
+
def _get_params(client: BaseClient[Any, Any]) -> dict[str, str]:
- request = client._build_request(FinalRequestOptions(method="get", url='/foo'))
- url = httpx.URL(request.url)
- return dict(url.params)
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
+ url = httpx.URL(request.url)
+ return dict(url.params)
+
def _low_retry_timeout(*_args: Any, **_kwargs: Any) -> float:
return 0.1
+
def _get_open_connections(client: Openlayer | AsyncOpenlayer) -> int:
transport = client._client._transport
assert isinstance(transport, httpx.HTTPTransport) or isinstance(transport, httpx.AsyncHTTPTransport)
@@ -54,6 +51,7 @@ def _get_open_connections(client: Openlayer | AsyncOpenlayer) -> int:
pool = transport._pool
return len(pool._requests)
+
class TestOpenlayer:
client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True)
@@ -68,7 +66,9 @@ def test_raw_response(self, respx_mock: MockRouter) -> None:
@pytest.mark.respx(base_url=base_url)
def test_raw_response_for_binary(self, respx_mock: MockRouter) -> None:
- respx_mock.post("/foo").mock(return_value=httpx.Response(200, headers={'Content-Type':'application/binary'}, content='{"foo": "bar"}'))
+ respx_mock.post("/foo").mock(
+ return_value=httpx.Response(200, headers={"Content-Type": "application/binary"}, content='{"foo": "bar"}')
+ )
response = self.client.post("/foo", cast_to=httpx.Response)
assert response.status_code == 200
@@ -100,58 +100,58 @@ def test_copy_default_options(self) -> None:
assert isinstance(self.client.timeout, httpx.Timeout)
def test_copy_default_headers(self) -> None:
- client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={
- "X-Foo": "bar"
- })
- assert client.default_headers['X-Foo'] == 'bar'
+ client = Openlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"}
+ )
+ assert client.default_headers["X-Foo"] == "bar"
# does not override the already given value when not specified
copied = client.copy()
- assert copied.default_headers['X-Foo'] == 'bar'
+ assert copied.default_headers["X-Foo"] == "bar"
# merges already given headers
- copied = client.copy(default_headers={'X-Bar': 'stainless'})
- assert copied.default_headers['X-Foo'] == 'bar'
- assert copied.default_headers['X-Bar'] == 'stainless'
+ copied = client.copy(default_headers={"X-Bar": "stainless"})
+ assert copied.default_headers["X-Foo"] == "bar"
+ assert copied.default_headers["X-Bar"] == "stainless"
# uses new values for any already given headers
- copied = client.copy(default_headers={'X-Foo': 'stainless'})
- assert copied.default_headers['X-Foo'] == 'stainless'
+ copied = client.copy(default_headers={"X-Foo": "stainless"})
+ assert copied.default_headers["X-Foo"] == "stainless"
# set_default_headers
# completely overrides already set values
copied = client.copy(set_default_headers={})
- assert copied.default_headers.get('X-Foo') is None
+ assert copied.default_headers.get("X-Foo") is None
- copied = client.copy(set_default_headers={'X-Bar': 'Robert'})
- assert copied.default_headers['X-Bar'] == 'Robert'
+ copied = client.copy(set_default_headers={"X-Bar": "Robert"})
+ assert copied.default_headers["X-Bar"] == "Robert"
with pytest.raises(
- ValueError,
- match='`default_headers` and `set_default_headers` arguments are mutually exclusive',
+ ValueError,
+ match="`default_headers` and `set_default_headers` arguments are mutually exclusive",
):
- client.copy(set_default_headers={}, default_headers={'X-Foo': 'Bar'})
+ client.copy(set_default_headers={}, default_headers={"X-Foo": "Bar"})
def test_copy_default_query(self) -> None:
- client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={
- "foo": "bar"
- })
- assert _get_params(client)['foo'] == 'bar'
+ client = Openlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"foo": "bar"}
+ )
+ assert _get_params(client)["foo"] == "bar"
# does not override the already given value when not specified
copied = client.copy()
- assert _get_params(copied)['foo'] == 'bar'
+ assert _get_params(copied)["foo"] == "bar"
# merges already given params
- copied = client.copy(default_query={'bar': 'stainless'})
+ copied = client.copy(default_query={"bar": "stainless"})
params = _get_params(copied)
- assert params['foo'] == 'bar'
- assert params['bar'] == 'stainless'
+ assert params["foo"] == "bar"
+ assert params["bar"] == "stainless"
# uses new values for any already given headers
- copied = client.copy(default_query={'foo': 'stainless'})
- assert _get_params(copied)['foo'] == 'stainless'
+ copied = client.copy(default_query={"foo": "stainless"})
+ assert _get_params(copied)["foo"] == "stainless"
# set_default_query
@@ -159,21 +159,21 @@ def test_copy_default_query(self) -> None:
copied = client.copy(set_default_query={})
assert _get_params(copied) == {}
- copied = client.copy(set_default_query={'bar': 'Robert'})
- assert _get_params(copied)['bar'] == 'Robert'
+ copied = client.copy(set_default_query={"bar": "Robert"})
+ assert _get_params(copied)["bar"] == "Robert"
with pytest.raises(
- ValueError,
- # TODO: update
- match='`default_query` and `set_default_query` arguments are mutually exclusive',
+ ValueError,
+ # TODO: update
+ match="`default_query` and `set_default_query` arguments are mutually exclusive",
):
- client.copy(set_default_query={}, default_query={'foo': 'Bar'})
+ client.copy(set_default_query={}, default_query={"foo": "Bar"})
def test_copy_signature(self) -> None:
# ensure the same parameters that can be passed to the client are defined in the `.copy()` method
init_signature = inspect.signature(
- # mypy doesn't like that we access the `__init__` property.
- self.client.__init__, # type: ignore[misc]
+ # mypy doesn't like that we access the `__init__` property.
+ self.client.__init__, # type: ignore[misc]
)
copy_signature = inspect.signature(self.client.copy)
exclude_params = {"transport", "proxies", "_strict_response_validation"}
@@ -225,10 +225,10 @@ def add_leak(leaks: list[tracemalloc.StatisticDiff], diff: tracemalloc.Statistic
# to_raw_response_wrapper leaks through the @functools.wraps() decorator.
#
# removing the decorator fixes the leak for reasons we don't understand.
- "openlayer-test/_legacy_response.py",
- "openlayer-test/_response.py",
+ "openlayer/_legacy_response.py",
+ "openlayer/_response.py",
# pydantic.BaseModel.model_dump || pydantic.BaseModel.dict leak memory for some reason.
- "openlayer-test/_compat.py",
+ "openlayer/_compat.py",
# Standard library leaks we don't care about.
"/logging/__init__.py",
]
@@ -259,7 +259,9 @@ def test_request_timeout(self) -> None:
assert timeout == httpx.Timeout(100.0)
def test_client_timeout_option(self) -> None:
- client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, timeout=httpx.Timeout(0))
+ client = Openlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, timeout=httpx.Timeout(0)
+ )
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
@@ -268,70 +270,88 @@ def test_client_timeout_option(self) -> None:
def test_http_client_timeout_option(self) -> None:
# custom timeout given to the httpx client should be used
with httpx.Client(timeout=None) as http_client:
- client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client)
+ client = Openlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
+ )
- request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
- timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
- assert timeout == httpx.Timeout(None)
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
+ timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
+ assert timeout == httpx.Timeout(None)
# no timeout given to the httpx client should not use the httpx default
with httpx.Client() as http_client:
- client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client)
+ client = Openlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
+ )
- request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
- timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
- assert timeout == DEFAULT_TIMEOUT
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
+ timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
+ assert timeout == DEFAULT_TIMEOUT
# explicitly passing the default timeout currently results in it being ignored
with httpx.Client(timeout=HTTPX_DEFAULT_TIMEOUT) as http_client:
- client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client)
+ client = Openlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
+ )
- request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
- timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
- assert timeout == DEFAULT_TIMEOUT # our default
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
+ timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
+ assert timeout == DEFAULT_TIMEOUT # our default
async def test_invalid_http_client(self) -> None:
- with pytest.raises(TypeError, match='Invalid `http_client` arg') :
- async with httpx.AsyncClient() as http_client :
- Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=cast(Any, http_client))
+ with pytest.raises(TypeError, match="Invalid `http_client` arg"):
+ async with httpx.AsyncClient() as http_client:
+ Openlayer(
+ base_url=base_url,
+ api_key=api_key,
+ _strict_response_validation=True,
+ http_client=cast(Any, http_client),
+ )
def test_default_headers_option(self) -> None:
- client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={
- "X-Foo": "bar"
- })
- request = client._build_request(FinalRequestOptions(method="get", url='/foo'))
- assert request.headers.get('x-foo') == 'bar'
- assert request.headers.get('x-stainless-lang') == 'python'
-
- client2 = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={
- "X-Foo": "stainless",
- "X-Stainless-Lang": "my-overriding-header",
- })
- request = client2._build_request(FinalRequestOptions(method="get", url='/foo'))
- assert request.headers.get('x-foo') == 'stainless'
- assert request.headers.get('x-stainless-lang') == 'my-overriding-header'
+ client = Openlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"}
+ )
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
+ assert request.headers.get("x-foo") == "bar"
+ assert request.headers.get("x-stainless-lang") == "python"
+
+ client2 = Openlayer(
+ base_url=base_url,
+ api_key=api_key,
+ _strict_response_validation=True,
+ default_headers={
+ "X-Foo": "stainless",
+ "X-Stainless-Lang": "my-overriding-header",
+ },
+ )
+ request = client2._build_request(FinalRequestOptions(method="get", url="/foo"))
+ assert request.headers.get("x-foo") == "stainless"
+ assert request.headers.get("x-stainless-lang") == "my-overriding-header"
def test_validate_headers(self) -> None:
client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True)
- request = client._build_request(FinalRequestOptions(method="get", url='/foo'))
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
assert request.headers.get("Authorization") == f"Bearer {api_key}"
client2 = Openlayer(base_url=base_url, api_key=None, _strict_response_validation=True)
with pytest.raises(
TypeError,
- match="Could not resolve authentication method. Expected the api_key to be set. Or for the `Authorization` headers to be explicitly omitted"
+ match="Could not resolve authentication method. Expected the api_key to be set. Or for the `Authorization` headers to be explicitly omitted",
):
- client2._build_request(FinalRequestOptions(method="get", url='/foo'))
+ client2._build_request(FinalRequestOptions(method="get", url="/foo"))
- request2 = client2._build_request(FinalRequestOptions(method="get", url='/foo', headers={"Authorization": Omit()}))
+ request2 = client2._build_request(
+ FinalRequestOptions(method="get", url="/foo", headers={"Authorization": Omit()})
+ )
assert request2.headers.get("Authorization") is None
def test_default_query_option(self) -> None:
- client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={
- "query_param": "bar"
- })
- request = client._build_request(FinalRequestOptions(method="get", url='/foo'))
+ client = Openlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"query_param": "bar"}
+ )
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
url = httpx.URL(request.url)
assert dict(url.params) == {"query_param": "bar"}
@@ -343,7 +363,7 @@ def test_default_query_option(self) -> None:
)
)
url = httpx.URL(request.url)
- assert dict(url.params) == {'foo': 'baz', "query_param": "overriden"}
+ assert dict(url.params) == {"foo": "baz", "query_param": "overriden"}
def test_request_extra_json(self) -> None:
request = self.client._build_request(
@@ -426,7 +446,7 @@ def test_request_extra_query(self) -> None:
),
)
params = dict(request.url.params)
- assert params == {'bar': '1', 'foo': '2'}
+ assert params == {"bar": "1", "foo": "2"}
# `extra_query` takes priority over `query` when keys clash
request = self.client._build_request(
@@ -440,7 +460,7 @@ def test_request_extra_query(self) -> None:
),
)
params = dict(request.url.params)
- assert params == {'foo': '2'}
+ assert params == {"foo": "2"}
def test_multipart_repeating_array(self, client: Openlayer) -> None:
request = client._build_request(
@@ -479,27 +499,29 @@ class Model1(BaseModel):
class Model2(BaseModel):
foo: str
- respx_mock.get('/foo').mock(return_value=httpx.Response(200, json={'foo': 'bar'}))
+ respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
response = self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2]))
assert isinstance(response, Model2)
- assert response.foo == 'bar'
+ assert response.foo == "bar"
+
@pytest.mark.respx(base_url=base_url)
def test_union_response_different_types(self, respx_mock: MockRouter) -> None:
"""Union of objects with the same field name using a different type"""
+
class Model1(BaseModel):
foo: int
class Model2(BaseModel):
foo: str
- respx_mock.get('/foo').mock(return_value=httpx.Response(200, json={'foo': 'bar'}))
+ respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
response = self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2]))
assert isinstance(response, Model2)
- assert response.foo == 'bar'
+ assert response.foo == "bar"
- respx_mock.get('/foo').mock(return_value=httpx.Response(200, json={'foo': 1}))
+ respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": 1}))
response = self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2]))
assert isinstance(response, Model1)
@@ -510,6 +532,7 @@ def test_non_application_json_content_type_for_json_data(self, respx_mock: MockR
"""
Response that sets Content-Type to something other than application/json but returns json data
"""
+
class Model(BaseModel):
foo: int
@@ -534,11 +557,23 @@ def test_base_url_setter(self) -> None:
assert client.base_url == "https://example.com/from_setter/"
def test_base_url_env(self) -> None:
- with update_env(OPENLAYER_BASE_URL='http://localhost:5000/from/env'):
- client = Openlayer(api_key=api_key, _strict_response_validation=True)
- assert client.base_url == 'http://localhost:5000/from/env/'
+ with update_env(OPENLAYER_BASE_URL="http://localhost:5000/from/env"):
+ client = Openlayer(api_key=api_key, _strict_response_validation=True)
+ assert client.base_url == "http://localhost:5000/from/env/"
- @pytest.mark.parametrize("client", [Openlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True), Openlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True, http_client=httpx.Client())], ids = ["standard", "custom http client"])
+ @pytest.mark.parametrize(
+ "client",
+ [
+ Openlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True),
+ Openlayer(
+ base_url="http://localhost:5000/custom/path/",
+ api_key=api_key,
+ _strict_response_validation=True,
+ http_client=httpx.Client(),
+ ),
+ ],
+ ids=["standard", "custom http client"],
+ )
def test_base_url_trailing_slash(self, client: Openlayer) -> None:
request = client._build_request(
FinalRequestOptions(
@@ -549,7 +584,19 @@ def test_base_url_trailing_slash(self, client: Openlayer) -> None:
)
assert request.url == "http://localhost:5000/custom/path/foo"
- @pytest.mark.parametrize("client", [Openlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True), Openlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True, http_client=httpx.Client())], ids = ["standard", "custom http client"])
+ @pytest.mark.parametrize(
+ "client",
+ [
+ Openlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True),
+ Openlayer(
+ base_url="http://localhost:5000/custom/path/",
+ api_key=api_key,
+ _strict_response_validation=True,
+ http_client=httpx.Client(),
+ ),
+ ],
+ ids=["standard", "custom http client"],
+ )
def test_base_url_no_trailing_slash(self, client: Openlayer) -> None:
request = client._build_request(
FinalRequestOptions(
@@ -560,7 +607,19 @@ def test_base_url_no_trailing_slash(self, client: Openlayer) -> None:
)
assert request.url == "http://localhost:5000/custom/path/foo"
- @pytest.mark.parametrize("client", [Openlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True), Openlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True, http_client=httpx.Client())], ids = ["standard", "custom http client"])
+ @pytest.mark.parametrize(
+ "client",
+ [
+ Openlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True),
+ Openlayer(
+ base_url="http://localhost:5000/custom/path/",
+ api_key=api_key,
+ _strict_response_validation=True,
+ http_client=httpx.Client(),
+ ),
+ ],
+ ids=["standard", "custom http client"],
+ )
def test_absolute_request_url(self, client: Openlayer) -> None:
request = client._build_request(
FinalRequestOptions(
@@ -585,9 +644,9 @@ def test_copied_client_does_not_close_http(self) -> None:
def test_client_context_manager(self) -> None:
client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True)
with client as c2:
- assert c2 is client
- assert not c2.is_closed()
- assert not client.is_closed()
+ assert c2 is client
+ assert not c2.is_closed()
+ assert not client.is_closed()
assert client.is_closed()
@pytest.mark.respx(base_url=base_url)
@@ -604,7 +663,7 @@ class Model(BaseModel):
def test_client_max_retries_validation(self) -> None:
with pytest.raises(TypeError, match=r"max_retries cannot be None"):
- Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, max_retries=cast(Any, None))
+ Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, max_retries=cast(Any, None))
@pytest.mark.respx(base_url=base_url)
def test_received_text_for_expected_json(self, respx_mock: MockRouter) -> None:
@@ -616,7 +675,7 @@ class Model(BaseModel):
strict_client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True)
with pytest.raises(APIResponseValidationError):
- strict_client.get("/foo", cast_to=Model)
+ strict_client.get("/foo", cast_to=Model)
client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=False)
@@ -624,25 +683,25 @@ class Model(BaseModel):
assert isinstance(response, str) # type: ignore[unreachable]
@pytest.mark.parametrize(
- "remaining_retries,retry_after,timeout",
- [
- [ 3, "20", 20 ],
- [ 3, "0", 0.5 ],
- [ 3, "-10", 0.5 ],
- [ 3, "60", 60 ],
- [ 3, "61", 0.5 ],
- [ 3, "Fri, 29 Sep 2023 16:26:57 GMT", 20 ],
- [ 3, "Fri, 29 Sep 2023 16:26:37 GMT", 0.5 ],
- [ 3, "Fri, 29 Sep 2023 16:26:27 GMT", 0.5 ],
- [ 3, "Fri, 29 Sep 2023 16:27:37 GMT", 60 ],
- [ 3, "Fri, 29 Sep 2023 16:27:38 GMT", 0.5 ],
- [ 3, "99999999999999999999999999999999999", 0.5 ],
- [ 3, "Zun, 29 Sep 2023 16:26:27 GMT", 0.5 ],
- [ 3, "", 0.5 ],
- [ 2, "", 0.5 * 2.0 ],
- [ 1, "", 0.5 * 4.0 ],
- ],
- )
+ "remaining_retries,retry_after,timeout",
+ [
+ [3, "20", 20],
+ [3, "0", 0.5],
+ [3, "-10", 0.5],
+ [3, "60", 60],
+ [3, "61", 0.5],
+ [3, "Fri, 29 Sep 2023 16:26:57 GMT", 20],
+ [3, "Fri, 29 Sep 2023 16:26:37 GMT", 0.5],
+ [3, "Fri, 29 Sep 2023 16:26:27 GMT", 0.5],
+ [3, "Fri, 29 Sep 2023 16:27:37 GMT", 60],
+ [3, "Fri, 29 Sep 2023 16:27:38 GMT", 0.5],
+ [3, "99999999999999999999999999999999999", 0.5],
+ [3, "Zun, 29 Sep 2023 16:26:27 GMT", 0.5],
+ [3, "", 0.5],
+ [2, "", 0.5 * 2.0],
+ [1, "", 0.5 * 4.0],
+ ],
+ )
@mock.patch("time.time", mock.MagicMock(return_value=1696004797))
def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str, timeout: float) -> None:
client = Openlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True)
@@ -650,51 +709,83 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str
headers = httpx.Headers({"retry-after": retry_after})
options = FinalRequestOptions(method="get", url="/foo", max_retries=3)
calculated = client._calculate_retry_timeout(remaining_retries, options, headers)
- assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType]
+ assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType]
- @mock.patch("openlayer-test._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
+ @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:
- respx_mock.post("/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream").mock(side_effect=httpx.TimeoutException("Test timeout error"))
+ 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, 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's the meaning of life?",
- "output": "42",
- "tokens": 7,
- "cost": 0.02,
- "timestamp": 1620000000,
- }])), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}})
+ self.client.post(
+ "/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream",
+ body=cast(
+ object,
+ 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's the meaning of life?",
+ "output": "42",
+ "tokens": 7,
+ "cost": 0.02,
+ "timestamp": 1620000000,
+ }
+ ],
+ ),
+ ),
+ cast_to=httpx.Response,
+ options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
+ )
assert _get_open_connections(self.client) == 0
- @mock.patch("openlayer-test._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
+ @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:
- respx_mock.post("/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream").mock(return_value=httpx.Response(500))
+ 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, 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's the meaning of life?",
- "output": "42",
- "tokens": 7,
- "cost": 0.02,
- "timestamp": 1620000000,
- }])), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}})
+ self.client.post(
+ "/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream",
+ body=cast(
+ object,
+ 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's the meaning of life?",
+ "output": "42",
+ "tokens": 7,
+ "cost": 0.02,
+ "timestamp": 1620000000,
+ }
+ ],
+ ),
+ ),
+ cast_to=httpx.Response,
+ options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
+ )
assert _get_open_connections(self.client) == 0
+
+
class TestAsyncOpenlayer:
client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True)
@@ -711,7 +802,9 @@ async def test_raw_response(self, respx_mock: MockRouter) -> None:
@pytest.mark.respx(base_url=base_url)
@pytest.mark.asyncio
async def test_raw_response_for_binary(self, respx_mock: MockRouter) -> None:
- respx_mock.post("/foo").mock(return_value=httpx.Response(200, headers={'Content-Type':'application/binary'}, content='{"foo": "bar"}'))
+ respx_mock.post("/foo").mock(
+ return_value=httpx.Response(200, headers={"Content-Type": "application/binary"}, content='{"foo": "bar"}')
+ )
response = await self.client.post("/foo", cast_to=httpx.Response)
assert response.status_code == 200
@@ -743,58 +836,58 @@ def test_copy_default_options(self) -> None:
assert isinstance(self.client.timeout, httpx.Timeout)
def test_copy_default_headers(self) -> None:
- client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={
- "X-Foo": "bar"
- })
- assert client.default_headers['X-Foo'] == 'bar'
+ client = AsyncOpenlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"}
+ )
+ assert client.default_headers["X-Foo"] == "bar"
# does not override the already given value when not specified
copied = client.copy()
- assert copied.default_headers['X-Foo'] == 'bar'
+ assert copied.default_headers["X-Foo"] == "bar"
# merges already given headers
- copied = client.copy(default_headers={'X-Bar': 'stainless'})
- assert copied.default_headers['X-Foo'] == 'bar'
- assert copied.default_headers['X-Bar'] == 'stainless'
+ copied = client.copy(default_headers={"X-Bar": "stainless"})
+ assert copied.default_headers["X-Foo"] == "bar"
+ assert copied.default_headers["X-Bar"] == "stainless"
# uses new values for any already given headers
- copied = client.copy(default_headers={'X-Foo': 'stainless'})
- assert copied.default_headers['X-Foo'] == 'stainless'
+ copied = client.copy(default_headers={"X-Foo": "stainless"})
+ assert copied.default_headers["X-Foo"] == "stainless"
# set_default_headers
# completely overrides already set values
copied = client.copy(set_default_headers={})
- assert copied.default_headers.get('X-Foo') is None
+ assert copied.default_headers.get("X-Foo") is None
- copied = client.copy(set_default_headers={'X-Bar': 'Robert'})
- assert copied.default_headers['X-Bar'] == 'Robert'
+ copied = client.copy(set_default_headers={"X-Bar": "Robert"})
+ assert copied.default_headers["X-Bar"] == "Robert"
with pytest.raises(
- ValueError,
- match='`default_headers` and `set_default_headers` arguments are mutually exclusive',
+ ValueError,
+ match="`default_headers` and `set_default_headers` arguments are mutually exclusive",
):
- client.copy(set_default_headers={}, default_headers={'X-Foo': 'Bar'})
+ client.copy(set_default_headers={}, default_headers={"X-Foo": "Bar"})
def test_copy_default_query(self) -> None:
- client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={
- "foo": "bar"
- })
- assert _get_params(client)['foo'] == 'bar'
+ client = AsyncOpenlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"foo": "bar"}
+ )
+ assert _get_params(client)["foo"] == "bar"
# does not override the already given value when not specified
copied = client.copy()
- assert _get_params(copied)['foo'] == 'bar'
+ assert _get_params(copied)["foo"] == "bar"
# merges already given params
- copied = client.copy(default_query={'bar': 'stainless'})
+ copied = client.copy(default_query={"bar": "stainless"})
params = _get_params(copied)
- assert params['foo'] == 'bar'
- assert params['bar'] == 'stainless'
+ assert params["foo"] == "bar"
+ assert params["bar"] == "stainless"
# uses new values for any already given headers
- copied = client.copy(default_query={'foo': 'stainless'})
- assert _get_params(copied)['foo'] == 'stainless'
+ copied = client.copy(default_query={"foo": "stainless"})
+ assert _get_params(copied)["foo"] == "stainless"
# set_default_query
@@ -802,21 +895,21 @@ def test_copy_default_query(self) -> None:
copied = client.copy(set_default_query={})
assert _get_params(copied) == {}
- copied = client.copy(set_default_query={'bar': 'Robert'})
- assert _get_params(copied)['bar'] == 'Robert'
+ copied = client.copy(set_default_query={"bar": "Robert"})
+ assert _get_params(copied)["bar"] == "Robert"
with pytest.raises(
- ValueError,
- # TODO: update
- match='`default_query` and `set_default_query` arguments are mutually exclusive',
+ ValueError,
+ # TODO: update
+ match="`default_query` and `set_default_query` arguments are mutually exclusive",
):
- client.copy(set_default_query={}, default_query={'foo': 'Bar'})
+ client.copy(set_default_query={}, default_query={"foo": "Bar"})
def test_copy_signature(self) -> None:
# ensure the same parameters that can be passed to the client are defined in the `.copy()` method
init_signature = inspect.signature(
- # mypy doesn't like that we access the `__init__` property.
- self.client.__init__, # type: ignore[misc]
+ # mypy doesn't like that we access the `__init__` property.
+ self.client.__init__, # type: ignore[misc]
)
copy_signature = inspect.signature(self.client.copy)
exclude_params = {"transport", "proxies", "_strict_response_validation"}
@@ -868,10 +961,10 @@ def add_leak(leaks: list[tracemalloc.StatisticDiff], diff: tracemalloc.Statistic
# to_raw_response_wrapper leaks through the @functools.wraps() decorator.
#
# removing the decorator fixes the leak for reasons we don't understand.
- "openlayer-test/_legacy_response.py",
- "openlayer-test/_response.py",
+ "openlayer/_legacy_response.py",
+ "openlayer/_response.py",
# pydantic.BaseModel.model_dump || pydantic.BaseModel.dict leak memory for some reason.
- "openlayer-test/_compat.py",
+ "openlayer/_compat.py",
# Standard library leaks we don't care about.
"/logging/__init__.py",
]
@@ -902,7 +995,9 @@ async def test_request_timeout(self) -> None:
assert timeout == httpx.Timeout(100.0)
async def test_client_timeout_option(self) -> None:
- client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, timeout=httpx.Timeout(0))
+ client = AsyncOpenlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, timeout=httpx.Timeout(0)
+ )
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
@@ -911,70 +1006,88 @@ async def test_client_timeout_option(self) -> None:
async def test_http_client_timeout_option(self) -> None:
# custom timeout given to the httpx client should be used
async with httpx.AsyncClient(timeout=None) as http_client:
- client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client)
+ client = AsyncOpenlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
+ )
- request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
- timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
- assert timeout == httpx.Timeout(None)
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
+ timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
+ assert timeout == httpx.Timeout(None)
# no timeout given to the httpx client should not use the httpx default
async with httpx.AsyncClient() as http_client:
- client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client)
+ client = AsyncOpenlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
+ )
- request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
- timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
- assert timeout == DEFAULT_TIMEOUT
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
+ timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
+ assert timeout == DEFAULT_TIMEOUT
# explicitly passing the default timeout currently results in it being ignored
async with httpx.AsyncClient(timeout=HTTPX_DEFAULT_TIMEOUT) as http_client:
- client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client)
+ client = AsyncOpenlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=http_client
+ )
- request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
- timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
- assert timeout == DEFAULT_TIMEOUT # our default
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
+ timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore
+ assert timeout == DEFAULT_TIMEOUT # our default
def test_invalid_http_client(self) -> None:
- with pytest.raises(TypeError, match='Invalid `http_client` arg') :
- with httpx.Client() as http_client :
- AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, http_client=cast(Any, http_client))
+ with pytest.raises(TypeError, match="Invalid `http_client` arg"):
+ with httpx.Client() as http_client:
+ AsyncOpenlayer(
+ base_url=base_url,
+ api_key=api_key,
+ _strict_response_validation=True,
+ http_client=cast(Any, http_client),
+ )
def test_default_headers_option(self) -> None:
- client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={
- "X-Foo": "bar"
- })
- request = client._build_request(FinalRequestOptions(method="get", url='/foo'))
- assert request.headers.get('x-foo') == 'bar'
- assert request.headers.get('x-stainless-lang') == 'python'
-
- client2 = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={
- "X-Foo": "stainless",
- "X-Stainless-Lang": "my-overriding-header",
- })
- request = client2._build_request(FinalRequestOptions(method="get", url='/foo'))
- assert request.headers.get('x-foo') == 'stainless'
- assert request.headers.get('x-stainless-lang') == 'my-overriding-header'
+ client = AsyncOpenlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_headers={"X-Foo": "bar"}
+ )
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
+ assert request.headers.get("x-foo") == "bar"
+ assert request.headers.get("x-stainless-lang") == "python"
+
+ client2 = AsyncOpenlayer(
+ base_url=base_url,
+ api_key=api_key,
+ _strict_response_validation=True,
+ default_headers={
+ "X-Foo": "stainless",
+ "X-Stainless-Lang": "my-overriding-header",
+ },
+ )
+ request = client2._build_request(FinalRequestOptions(method="get", url="/foo"))
+ assert request.headers.get("x-foo") == "stainless"
+ assert request.headers.get("x-stainless-lang") == "my-overriding-header"
def test_validate_headers(self) -> None:
client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True)
- request = client._build_request(FinalRequestOptions(method="get", url='/foo'))
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
assert request.headers.get("Authorization") == f"Bearer {api_key}"
client2 = AsyncOpenlayer(base_url=base_url, api_key=None, _strict_response_validation=True)
with pytest.raises(
TypeError,
- match="Could not resolve authentication method. Expected the api_key to be set. Or for the `Authorization` headers to be explicitly omitted"
+ match="Could not resolve authentication method. Expected the api_key to be set. Or for the `Authorization` headers to be explicitly omitted",
):
- client2._build_request(FinalRequestOptions(method="get", url='/foo'))
+ client2._build_request(FinalRequestOptions(method="get", url="/foo"))
- request2 = client2._build_request(FinalRequestOptions(method="get", url='/foo', headers={"Authorization": Omit()}))
+ request2 = client2._build_request(
+ FinalRequestOptions(method="get", url="/foo", headers={"Authorization": Omit()})
+ )
assert request2.headers.get("Authorization") is None
def test_default_query_option(self) -> None:
- client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={
- "query_param": "bar"
- })
- request = client._build_request(FinalRequestOptions(method="get", url='/foo'))
+ client = AsyncOpenlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"query_param": "bar"}
+ )
+ request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
url = httpx.URL(request.url)
assert dict(url.params) == {"query_param": "bar"}
@@ -986,7 +1099,7 @@ def test_default_query_option(self) -> None:
)
)
url = httpx.URL(request.url)
- assert dict(url.params) == {'foo': 'baz', "query_param": "overriden"}
+ assert dict(url.params) == {"foo": "baz", "query_param": "overriden"}
def test_request_extra_json(self) -> None:
request = self.client._build_request(
@@ -1069,7 +1182,7 @@ def test_request_extra_query(self) -> None:
),
)
params = dict(request.url.params)
- assert params == {'bar': '1', 'foo': '2'}
+ assert params == {"bar": "1", "foo": "2"}
# `extra_query` takes priority over `query` when keys clash
request = self.client._build_request(
@@ -1083,7 +1196,7 @@ def test_request_extra_query(self) -> None:
),
)
params = dict(request.url.params)
- assert params == {'foo': '2'}
+ assert params == {"foo": "2"}
def test_multipart_repeating_array(self, async_client: AsyncOpenlayer) -> None:
request = async_client._build_request(
@@ -1122,27 +1235,29 @@ class Model1(BaseModel):
class Model2(BaseModel):
foo: str
- respx_mock.get('/foo').mock(return_value=httpx.Response(200, json={'foo': 'bar'}))
+ respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
response = await self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2]))
assert isinstance(response, Model2)
- assert response.foo == 'bar'
+ assert response.foo == "bar"
+
@pytest.mark.respx(base_url=base_url)
async def test_union_response_different_types(self, respx_mock: MockRouter) -> None:
"""Union of objects with the same field name using a different type"""
+
class Model1(BaseModel):
foo: int
class Model2(BaseModel):
foo: str
- respx_mock.get('/foo').mock(return_value=httpx.Response(200, json={'foo': 'bar'}))
+ respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
response = await self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2]))
assert isinstance(response, Model2)
- assert response.foo == 'bar'
+ assert response.foo == "bar"
- respx_mock.get('/foo').mock(return_value=httpx.Response(200, json={'foo': 1}))
+ respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": 1}))
response = await self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2]))
assert isinstance(response, Model1)
@@ -1153,6 +1268,7 @@ async def test_non_application_json_content_type_for_json_data(self, respx_mock:
"""
Response that sets Content-Type to something other than application/json but returns json data
"""
+
class Model(BaseModel):
foo: int
@@ -1169,7 +1285,9 @@ class Model(BaseModel):
assert response.foo == 2
def test_base_url_setter(self) -> None:
- client = AsyncOpenlayer(base_url="https://example.com/from_init", api_key=api_key, _strict_response_validation=True)
+ client = AsyncOpenlayer(
+ base_url="https://example.com/from_init", api_key=api_key, _strict_response_validation=True
+ )
assert client.base_url == "https://example.com/from_init/"
client.base_url = "https://example.com/from_setter" # type: ignore[assignment]
@@ -1177,11 +1295,25 @@ def test_base_url_setter(self) -> None:
assert client.base_url == "https://example.com/from_setter/"
def test_base_url_env(self) -> None:
- with update_env(OPENLAYER_BASE_URL='http://localhost:5000/from/env'):
- client = AsyncOpenlayer(api_key=api_key, _strict_response_validation=True)
- assert client.base_url == 'http://localhost:5000/from/env/'
+ with update_env(OPENLAYER_BASE_URL="http://localhost:5000/from/env"):
+ client = AsyncOpenlayer(api_key=api_key, _strict_response_validation=True)
+ assert client.base_url == "http://localhost:5000/from/env/"
- @pytest.mark.parametrize("client", [AsyncOpenlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True), AsyncOpenlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True, http_client=httpx.AsyncClient())], ids = ["standard", "custom http client"])
+ @pytest.mark.parametrize(
+ "client",
+ [
+ AsyncOpenlayer(
+ base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True
+ ),
+ AsyncOpenlayer(
+ base_url="http://localhost:5000/custom/path/",
+ api_key=api_key,
+ _strict_response_validation=True,
+ http_client=httpx.AsyncClient(),
+ ),
+ ],
+ ids=["standard", "custom http client"],
+ )
def test_base_url_trailing_slash(self, client: AsyncOpenlayer) -> None:
request = client._build_request(
FinalRequestOptions(
@@ -1192,7 +1324,21 @@ def test_base_url_trailing_slash(self, client: AsyncOpenlayer) -> None:
)
assert request.url == "http://localhost:5000/custom/path/foo"
- @pytest.mark.parametrize("client", [AsyncOpenlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True), AsyncOpenlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True, http_client=httpx.AsyncClient())], ids = ["standard", "custom http client"])
+ @pytest.mark.parametrize(
+ "client",
+ [
+ AsyncOpenlayer(
+ base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True
+ ),
+ AsyncOpenlayer(
+ base_url="http://localhost:5000/custom/path/",
+ api_key=api_key,
+ _strict_response_validation=True,
+ http_client=httpx.AsyncClient(),
+ ),
+ ],
+ ids=["standard", "custom http client"],
+ )
def test_base_url_no_trailing_slash(self, client: AsyncOpenlayer) -> None:
request = client._build_request(
FinalRequestOptions(
@@ -1203,7 +1349,21 @@ def test_base_url_no_trailing_slash(self, client: AsyncOpenlayer) -> None:
)
assert request.url == "http://localhost:5000/custom/path/foo"
- @pytest.mark.parametrize("client", [AsyncOpenlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True), AsyncOpenlayer(base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True, http_client=httpx.AsyncClient())], ids = ["standard", "custom http client"])
+ @pytest.mark.parametrize(
+ "client",
+ [
+ AsyncOpenlayer(
+ base_url="http://localhost:5000/custom/path/", api_key=api_key, _strict_response_validation=True
+ ),
+ AsyncOpenlayer(
+ base_url="http://localhost:5000/custom/path/",
+ api_key=api_key,
+ _strict_response_validation=True,
+ http_client=httpx.AsyncClient(),
+ ),
+ ],
+ ids=["standard", "custom http client"],
+ )
def test_absolute_request_url(self, client: AsyncOpenlayer) -> None:
request = client._build_request(
FinalRequestOptions(
@@ -1229,9 +1389,9 @@ async def test_copied_client_does_not_close_http(self) -> None:
async def test_client_context_manager(self) -> None:
client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True)
async with client as c2:
- assert c2 is client
- assert not c2.is_closed()
- assert not client.is_closed()
+ assert c2 is client
+ assert not c2.is_closed()
+ assert not client.is_closed()
assert client.is_closed()
@pytest.mark.respx(base_url=base_url)
@@ -1249,7 +1409,9 @@ class Model(BaseModel):
async def test_client_max_retries_validation(self) -> None:
with pytest.raises(TypeError, match=r"max_retries cannot be None"):
- AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True, max_retries=cast(Any, None))
+ AsyncOpenlayer(
+ base_url=base_url, api_key=api_key, _strict_response_validation=True, max_retries=cast(Any, None)
+ )
@pytest.mark.respx(base_url=base_url)
@pytest.mark.asyncio
@@ -1262,7 +1424,7 @@ class Model(BaseModel):
strict_client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=True)
with pytest.raises(APIResponseValidationError):
- await strict_client.get("/foo", cast_to=Model)
+ await strict_client.get("/foo", cast_to=Model)
client = AsyncOpenlayer(base_url=base_url, api_key=api_key, _strict_response_validation=False)
@@ -1270,25 +1432,25 @@ class Model(BaseModel):
assert isinstance(response, str) # type: ignore[unreachable]
@pytest.mark.parametrize(
- "remaining_retries,retry_after,timeout",
- [
- [ 3, "20", 20 ],
- [ 3, "0", 0.5 ],
- [ 3, "-10", 0.5 ],
- [ 3, "60", 60 ],
- [ 3, "61", 0.5 ],
- [ 3, "Fri, 29 Sep 2023 16:26:57 GMT", 20 ],
- [ 3, "Fri, 29 Sep 2023 16:26:37 GMT", 0.5 ],
- [ 3, "Fri, 29 Sep 2023 16:26:27 GMT", 0.5 ],
- [ 3, "Fri, 29 Sep 2023 16:27:37 GMT", 60 ],
- [ 3, "Fri, 29 Sep 2023 16:27:38 GMT", 0.5 ],
- [ 3, "99999999999999999999999999999999999", 0.5 ],
- [ 3, "Zun, 29 Sep 2023 16:26:27 GMT", 0.5 ],
- [ 3, "", 0.5 ],
- [ 2, "", 0.5 * 2.0 ],
- [ 1, "", 0.5 * 4.0 ],
- ],
- )
+ "remaining_retries,retry_after,timeout",
+ [
+ [3, "20", 20],
+ [3, "0", 0.5],
+ [3, "-10", 0.5],
+ [3, "60", 60],
+ [3, "61", 0.5],
+ [3, "Fri, 29 Sep 2023 16:26:57 GMT", 20],
+ [3, "Fri, 29 Sep 2023 16:26:37 GMT", 0.5],
+ [3, "Fri, 29 Sep 2023 16:26:27 GMT", 0.5],
+ [3, "Fri, 29 Sep 2023 16:27:37 GMT", 60],
+ [3, "Fri, 29 Sep 2023 16:27:38 GMT", 0.5],
+ [3, "99999999999999999999999999999999999", 0.5],
+ [3, "Zun, 29 Sep 2023 16:26:27 GMT", 0.5],
+ [3, "", 0.5],
+ [2, "", 0.5 * 2.0],
+ [1, "", 0.5 * 4.0],
+ ],
+ )
@mock.patch("time.time", mock.MagicMock(return_value=1696004797))
@pytest.mark.asyncio
async def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str, timeout: float) -> None:
@@ -1297,48 +1459,78 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte
headers = httpx.Headers({"retry-after": retry_after})
options = FinalRequestOptions(method="get", url="/foo", max_retries=3)
calculated = client._calculate_retry_timeout(remaining_retries, options, headers)
- assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType]
+ assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType]
- @mock.patch("openlayer-test._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
+ @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:
- respx_mock.post("/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream").mock(side_effect=httpx.TimeoutException("Test timeout error"))
+ 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, 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's the meaning of life?",
- "output": "42",
- "tokens": 7,
- "cost": 0.02,
- "timestamp": 1620000000,
- }])), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}})
+ await self.client.post(
+ "/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream",
+ body=cast(
+ object,
+ 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's the meaning of life?",
+ "output": "42",
+ "tokens": 7,
+ "cost": 0.02,
+ "timestamp": 1620000000,
+ }
+ ],
+ ),
+ ),
+ cast_to=httpx.Response,
+ options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
+ )
assert _get_open_connections(self.client) == 0
- @mock.patch("openlayer-test._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
+ @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:
- respx_mock.post("/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream").mock(return_value=httpx.Response(500))
+ 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, 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's the meaning of life?",
- "output": "42",
- "tokens": 7,
- "cost": 0.02,
- "timestamp": 1620000000,
- }])), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}})
-
- assert _get_open_connections(self.client) == 0
\ No newline at end of file
+ await self.client.post(
+ "/inference-pipelines/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/data-stream",
+ body=cast(
+ object,
+ 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's the meaning of life?",
+ "output": "42",
+ "tokens": 7,
+ "cost": 0.02,
+ "timestamp": 1620000000,
+ }
+ ],
+ ),
+ ),
+ cast_to=httpx.Response,
+ options={"headers": {RAW_RESPONSE_HEADER: "stream"}},
+ )
+
+ assert _get_open_connections(self.client) == 0
diff --git a/tests/test_deepcopy.py b/tests/test_deepcopy.py
index d912c64b..03af4657 100644
--- a/tests/test_deepcopy.py
+++ b/tests/test_deepcopy.py
@@ -1,4 +1,4 @@
-from openlayer-test._utils import deepcopy_minimal
+from openlayer._utils import deepcopy_minimal
def assert_different_identities(obj1: object, obj2: object) -> None:
diff --git a/tests/test_extract_files.py b/tests/test_extract_files.py
index 1014e579..0d33d0a0 100644
--- a/tests/test_extract_files.py
+++ b/tests/test_extract_files.py
@@ -4,8 +4,8 @@
import pytest
-from openlayer-test._types import FileTypes
-from openlayer-test._utils import extract_files
+from openlayer._types import FileTypes
+from openlayer._utils import extract_files
def test_removes_files_from_input() -> None:
diff --git a/tests/test_files.py b/tests/test_files.py
index 87619862..8c6275bf 100644
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -4,9 +4,9 @@
import pytest
from dirty_equals import IsDict, IsList, IsBytes, IsTuple
-from openlayer-test._files import to_httpx_files, async_to_httpx_files
+from openlayer._files import to_httpx_files, async_to_httpx_files
-readme_path =Path(__file__).parent.parent.joinpath("README.md")
+readme_path = Path(__file__).parent.parent.joinpath("README.md")
def test_pathlib_includes_file_name() -> None:
@@ -16,9 +16,9 @@ def test_pathlib_includes_file_name() -> None:
def test_tuple_input() -> None:
- result = to_httpx_files([('file', readme_path)])
+ result = to_httpx_files([("file", readme_path)])
print(result)
- assert result == IsList(IsTuple('file', IsTuple('README.md', IsBytes())))
+ assert result == IsList(IsTuple("file", IsTuple("README.md", IsBytes())))
@pytest.mark.asyncio
@@ -37,9 +37,9 @@ async def test_async_supports_anyio_path() -> None:
@pytest.mark.asyncio
async def test_async_tuple_input() -> None:
- result = await async_to_httpx_files([('file', readme_path)])
+ result = await async_to_httpx_files([("file", readme_path)])
print(result)
- assert result == IsList(IsTuple('file', IsTuple('README.md', IsBytes())))
+ assert result == IsList(IsTuple("file", IsTuple("README.md", IsBytes())))
def test_string_not_allowed() -> None:
@@ -49,4 +49,3 @@ def test_string_not_allowed() -> None:
"file": "foo", # type: ignore
}
)
-
diff --git a/tests/test_models.py b/tests/test_models.py
index 0232e41c..963a34ff 100644
--- a/tests/test_models.py
+++ b/tests/test_models.py
@@ -7,9 +7,9 @@
import pydantic
from pydantic import Field
-from openlayer-test._utils import PropertyInfo
-from openlayer-test._compat import PYDANTIC_V2, parse_obj, model_dump, model_json
-from openlayer-test._models import BaseModel, construct_type
+from openlayer._utils import PropertyInfo
+from openlayer._compat import PYDANTIC_V2, parse_obj, model_dump, model_json
+from openlayer._models import BaseModel, construct_type
class BasicModel(BaseModel):
diff --git a/tests/test_qs.py b/tests/test_qs.py
index 7c7d0701..f03db996 100644
--- a/tests/test_qs.py
+++ b/tests/test_qs.py
@@ -4,7 +4,7 @@
import pytest
-from openlayer-test._qs import Querystring, stringify
+from openlayer._qs import Querystring, stringify
def test_empty() -> None:
diff --git a/tests/test_required_args.py b/tests/test_required_args.py
index 4c8ca619..430a1acf 100644
--- a/tests/test_required_args.py
+++ b/tests/test_required_args.py
@@ -2,7 +2,7 @@
import pytest
-from openlayer-test._utils import required_args
+from openlayer._utils import required_args
def test_too_many_positional_params() -> None:
diff --git a/tests/test_response.py b/tests/test_response.py
index 388822c8..10480d31 100644
--- a/tests/test_response.py
+++ b/tests/test_response.py
@@ -6,8 +6,8 @@
import pytest
import pydantic
-from openlayer-test import BaseModel, Openlayer, AsyncOpenlayer
-from openlayer-test._response import (
+from openlayer import BaseModel, Openlayer, AsyncOpenlayer
+from openlayer._response import (
APIResponse,
BaseAPIResponse,
AsyncAPIResponse,
@@ -15,8 +15,8 @@
AsyncBinaryAPIResponse,
extract_response_type,
)
-from openlayer-test._streaming import Stream
-from openlayer-test._base_client import FinalRequestOptions
+from openlayer._streaming import Stream
+from openlayer._base_client import FinalRequestOptions
class ConcreteBaseAPIResponse(APIResponse[bytes]):
@@ -40,7 +40,7 @@ def test_extract_response_type_direct_classes() -> None:
def test_extract_response_type_direct_class_missing_type_arg() -> None:
with pytest.raises(
RuntimeError,
- match="Expected type to have a type argument at index 0 but it did not",
+ match="Expected type to have a type argument at index 0 but it did not",
):
extract_response_type(AsyncAPIResponse)
@@ -72,7 +72,7 @@ def test_response_parse_mismatched_basemodel(client: Openlayer) -> None:
with pytest.raises(
TypeError,
- match="Pydantic models must subclass our base model type, e.g. `from openlayer-test import BaseModel`",
+ match="Pydantic models must subclass our base model type, e.g. `from openlayer import BaseModel`",
):
response.parse(to=PydanticModel)
@@ -90,7 +90,7 @@ async def test_async_response_parse_mismatched_basemodel(async_client: AsyncOpen
with pytest.raises(
TypeError,
- match="Pydantic models must subclass our base model type, e.g. `from openlayer-test import BaseModel`",
+ match="Pydantic models must subclass our base model type, e.g. `from openlayer import BaseModel`",
):
await response.parse(to=PydanticModel)
diff --git a/tests/test_streaming.py b/tests/test_streaming.py
index d86e5195..da026347 100644
--- a/tests/test_streaming.py
+++ b/tests/test_streaming.py
@@ -5,8 +5,8 @@
import httpx
import pytest
-from openlayer-test import Openlayer, AsyncOpenlayer
-from openlayer-test._streaming import Stream, AsyncStream, ServerSentEvent
+from openlayer import Openlayer, AsyncOpenlayer
+from openlayer._streaming import Stream, AsyncStream, ServerSentEvent
@pytest.mark.asyncio
@@ -28,9 +28,7 @@ def body() -> Iterator[bytes]:
@pytest.mark.asyncio
@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
-async def test_data_missing_event(
- sync: bool, client: Openlayer, async_client: AsyncOpenlayer
-) -> None:
+async def test_data_missing_event(sync: bool, client: Openlayer, async_client: AsyncOpenlayer) -> None:
def body() -> Iterator[bytes]:
yield b'data: {"foo":true}\n'
yield b"\n"
@@ -46,9 +44,7 @@ def body() -> Iterator[bytes]:
@pytest.mark.asyncio
@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
-async def test_event_missing_data(
- sync: bool, client: Openlayer, async_client: AsyncOpenlayer
-) -> None:
+async def test_event_missing_data(sync: bool, client: Openlayer, async_client: AsyncOpenlayer) -> None:
def body() -> Iterator[bytes]:
yield b"event: ping\n"
yield b"\n"
@@ -64,9 +60,7 @@ def body() -> Iterator[bytes]:
@pytest.mark.asyncio
@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
-async def test_multiple_events(
- sync: bool, client: Openlayer, async_client: AsyncOpenlayer
-) -> None:
+async def test_multiple_events(sync: bool, client: Openlayer, async_client: AsyncOpenlayer) -> None:
def body() -> Iterator[bytes]:
yield b"event: ping\n"
yield b"\n"
@@ -88,9 +82,7 @@ def body() -> Iterator[bytes]:
@pytest.mark.asyncio
@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
-async def test_multiple_events_with_data(
- sync: bool, client: Openlayer, async_client: AsyncOpenlayer
-) -> None:
+async def test_multiple_events_with_data(sync: bool, client: Openlayer, async_client: AsyncOpenlayer) -> None:
def body() -> Iterator[bytes]:
yield b"event: ping\n"
yield b'data: {"foo":true}\n'
@@ -114,9 +106,7 @@ def body() -> Iterator[bytes]:
@pytest.mark.asyncio
@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
-async def test_multiple_data_lines_with_empty_line(
- sync: bool, client: Openlayer, async_client: AsyncOpenlayer
-) -> None:
+async def test_multiple_data_lines_with_empty_line(sync: bool, client: Openlayer, async_client: AsyncOpenlayer) -> None:
def body() -> Iterator[bytes]:
yield b"event: ping\n"
yield b"data: {\n"
@@ -138,9 +128,7 @@ def body() -> Iterator[bytes]:
@pytest.mark.asyncio
@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
-async def test_data_json_escaped_double_new_line(
- sync: bool, client: Openlayer, async_client: AsyncOpenlayer
-) -> None:
+async def test_data_json_escaped_double_new_line(sync: bool, client: Openlayer, async_client: AsyncOpenlayer) -> None:
def body() -> Iterator[bytes]:
yield b"event: ping\n"
yield b'data: {"foo": "my long\\n\\ncontent"}'
@@ -157,9 +145,7 @@ def body() -> Iterator[bytes]:
@pytest.mark.asyncio
@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
-async def test_multiple_data_lines(
- sync: bool, client: Openlayer, async_client: AsyncOpenlayer
-) -> None:
+async def test_multiple_data_lines(sync: bool, client: Openlayer, async_client: AsyncOpenlayer) -> None:
def body() -> Iterator[bytes]:
yield b"event: ping\n"
yield b"data: {\n"
diff --git a/tests/test_transform.py b/tests/test_transform.py
index f6b4288e..3f6ede8e 100644
--- a/tests/test_transform.py
+++ b/tests/test_transform.py
@@ -8,15 +8,15 @@
import pytest
-from openlayer-test._types import Base64FileInput
-from openlayer-test._utils import (
+from openlayer._types import Base64FileInput
+from openlayer._utils import (
PropertyInfo,
transform as _transform,
parse_datetime,
async_transform as _async_transform,
)
-from openlayer-test._compat import PYDANTIC_V2
-from openlayer-test._models import BaseModel
+from openlayer._compat import PYDANTIC_V2
+from openlayer._models import BaseModel
_T = TypeVar("_T")
diff --git a/tests/test_utils/test_proxy.py b/tests/test_utils/test_proxy.py
index 43409f16..7f09e39e 100644
--- a/tests/test_utils/test_proxy.py
+++ b/tests/test_utils/test_proxy.py
@@ -2,7 +2,7 @@
from typing import Any
from typing_extensions import override
-from openlayer-test._utils import LazyProxy
+from openlayer._utils import LazyProxy
class RecursiveLazyProxy(LazyProxy[Any]):
diff --git a/tests/test_utils/test_typing.py b/tests/test_utils/test_typing.py
index fe53eb18..5a33f2d6 100644
--- a/tests/test_utils/test_typing.py
+++ b/tests/test_utils/test_typing.py
@@ -2,7 +2,7 @@
from typing import Generic, TypeVar, cast
-from openlayer-test._utils import extract_type_var_from_base
+from openlayer._utils import extract_type_var_from_base
_T = TypeVar("_T")
_T2 = TypeVar("_T2")
diff --git a/tests/utils.py b/tests/utils.py
index b4b7d1a7..1918bd1e 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -8,8 +8,8 @@
from datetime import date, datetime
from typing_extensions import Literal, get_args, get_origin, assert_type
-from openlayer-test._types import NoneType
-from openlayer-test._utils import (
+from openlayer._types import NoneType
+from openlayer._utils import (
is_dict,
is_list,
is_list_type,
@@ -17,8 +17,8 @@
extract_type_arg,
is_annotated_type,
)
-from openlayer-test._compat import PYDANTIC_V2, field_outer_type, get_model_fields
-from openlayer-test._models import BaseModel
+from openlayer._compat import PYDANTIC_V2, field_outer_type, get_model_fields
+from openlayer._models import BaseModel
BaseModelT = TypeVar("BaseModelT", bound=BaseModel)