From 497fe1047ade040d99bf5d7d4fb99f1b1b95a09d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 19:50:11 +0000 Subject: [PATCH 1/6] chore(internal): version bump --- scripts/utils/upload-artifact.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/utils/upload-artifact.sh b/scripts/utils/upload-artifact.sh index 02111be..07e6945 100755 --- a/scripts/utils/upload-artifact.sh +++ b/scripts/utils/upload-artifact.sh @@ -18,7 +18,7 @@ UPLOAD_RESPONSE=$(tar -cz . | curl -v -X PUT \ if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then echo -e "\033[32mUploaded build to Stainless storage.\033[0m" - echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/replicate-client-python/$SHA'\033[0m" + echo -e "\033[32mInstallation: pip install --pre 'https://pkg.stainless.com/s/replicate-client-python/$SHA'\033[0m" else echo -e "\033[31mFailed to upload artifact.\033[0m" exit 1 From 7c641711dcde5733ba5da72a5085cacb632b2e39 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 12 Jun 2025 21:22:24 +0000 Subject: [PATCH 2/6] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d3678f4..fa985e6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 35 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/replicate%2Freplicate-client-37cd8ea847eb57706035f766ca549d5b4e2111053af0656a2df9a8150421428e.yml openapi_spec_hash: a3e4d6fd9aff6de0e4b6d8ad28cbbe05 -config_hash: da444f7a7ac6238fa0bdecaa01ffa4c3 +config_hash: 12536d2bf978a995771d076a4647c17d From 9330c565de11b0c61e43df899f4113c5214572c9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Jun 2025 02:05:21 +0000 Subject: [PATCH 3/6] chore(tests): run tests in parallel --- pyproject.toml | 3 ++- requirements-dev.lock | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f9905ba..291ac15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,7 @@ dev-dependencies = [ "importlib-metadata>=6.7.0", "rich>=13.7.1", "nest_asyncio==1.6.0", + "pytest-xdist>=3.6.1", ] [tool.rye.scripts] @@ -125,7 +126,7 @@ replacement = '[\1](https://github.com/replicate/replicate-python-stainless/tree [tool.pytest.ini_options] testpaths = ["tests"] -addopts = "--tb=short" +addopts = "--tb=short -n auto" xfail_strict = true asyncio_mode = "auto" asyncio_default_fixture_loop_scope = "session" diff --git a/requirements-dev.lock b/requirements-dev.lock index f29c3c8..c456756 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -30,6 +30,8 @@ distro==1.8.0 exceptiongroup==1.2.2 # via anyio # via pytest +execnet==2.1.1 + # via pytest-xdist filelock==3.12.4 # via virtualenv h11==0.14.0 @@ -72,7 +74,9 @@ pygments==2.18.0 pyright==1.1.399 pytest==8.3.3 # via pytest-asyncio + # via pytest-xdist pytest-asyncio==0.24.0 +pytest-xdist==3.7.0 python-dateutil==2.8.2 # via time-machine pytz==2023.3.post1 From ec19335fcce5a7ceba6aa1a4ac67411421a571ec Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Jun 2025 02:31:32 +0000 Subject: [PATCH 4/6] fix(client): correctly parse binary response | stream --- src/replicate/_base_client.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/replicate/_base_client.py b/src/replicate/_base_client.py index 131706e..af0d340 100644 --- a/src/replicate/_base_client.py +++ b/src/replicate/_base_client.py @@ -1071,7 +1071,14 @@ def _process_response( ) -> ResponseT: origin = get_origin(cast_to) or cast_to - if inspect.isclass(origin) and issubclass(origin, BaseAPIResponse): + if ( + inspect.isclass(origin) + and issubclass(origin, BaseAPIResponse) + # we only want to actually return the custom BaseAPIResponse class if we're + # returning the raw response, or if we're not streaming SSE, as if we're streaming + # SSE then `cast_to` doesn't actively reflect the type we need to parse into + and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER))) + ): if not issubclass(origin, APIResponse): raise TypeError(f"API Response types must subclass {APIResponse}; Received {origin}") @@ -1588,7 +1595,14 @@ async def _process_response( ) -> ResponseT: origin = get_origin(cast_to) or cast_to - if inspect.isclass(origin) and issubclass(origin, BaseAPIResponse): + if ( + inspect.isclass(origin) + and issubclass(origin, BaseAPIResponse) + # we only want to actually return the custom BaseAPIResponse class if we're + # returning the raw response, or if we're not streaming SSE, as if we're streaming + # SSE then `cast_to` doesn't actively reflect the type we need to parse into + and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER))) + ): if not issubclass(origin, AsyncAPIResponse): raise TypeError(f"API Response types must subclass {AsyncAPIResponse}; Received {origin}") From b6608ca5bbfc38d68a9bbfb853bbb8645e046d39 Mon Sep 17 00:00:00 2001 From: Samuel El-Borai Date: Fri, 13 Jun 2025 18:35:44 +0200 Subject: [PATCH 5/6] fix(test): update prediction response --- tests/lib/test_run.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/lib/test_run.py b/tests/lib/test_run.py index 168447d..956787a 100644 --- a/tests/lib/test_run.py +++ b/tests/lib/test_run.py @@ -32,6 +32,7 @@ def create_mock_prediction( urls = { "get": "https://api.replicate.com/v1/predictions/test_prediction_id", "cancel": "https://api.replicate.com/v1/predictions/test_prediction_id/cancel", + "web": "https://replicate.com/p/test_prediction_id", } return { From 01e7d4d16df364586c9ce0eb09bfb8d721d0116c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Jun 2025 16:36:02 +0000 Subject: [PATCH 6/6] release: 2.0.0-alpha.2 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 15 +++++++++++++++ pyproject.toml | 2 +- src/replicate/_version.py | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6e011e8..0c548e2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-alpha.1" + ".": "2.0.0-alpha.2" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6787016..3181617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 2.0.0-alpha.2 (2025-06-13) + +Full Changelog: [v2.0.0-alpha.1...v2.0.0-alpha.2](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.1...v2.0.0-alpha.2) + +### Bug Fixes + +* **client:** correctly parse binary response | stream ([ec19335](https://github.com/replicate/replicate-python-stainless/commit/ec19335fcce5a7ceba6aa1a4ac67411421a571ec)) +* **test:** update prediction response ([b6608ca](https://github.com/replicate/replicate-python-stainless/commit/b6608ca5bbfc38d68a9bbfb853bbb8645e046d39)) + + +### Chores + +* **internal:** version bump ([497fe10](https://github.com/replicate/replicate-python-stainless/commit/497fe1047ade040d99bf5d7d4fb99f1b1b95a09d)) +* **tests:** run tests in parallel ([9330c56](https://github.com/replicate/replicate-python-stainless/commit/9330c565de11b0c61e43df899f4113c5214572c9)) + ## 2.0.0-alpha.1 (2025-06-10) Full Changelog: [v0.6.0...v2.0.0-alpha.1](https://github.com/replicate/replicate-python-stainless/compare/v0.6.0...v2.0.0-alpha.1) diff --git a/pyproject.toml b/pyproject.toml index 291ac15..91c2cea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "replicate" -version = "2.0.0-alpha.1" +version = "2.0.0-alpha.2" description = "The official Python library for the replicate API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/replicate/_version.py b/src/replicate/_version.py index 60265a9..e6857d0 100644 --- a/src/replicate/_version.py +++ b/src/replicate/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "replicate" -__version__ = "2.0.0-alpha.1" # x-release-please-version +__version__ = "2.0.0-alpha.2" # x-release-please-version