From 98f0cbb48c8fffc29608e3a2cce51b8bd7e2e5d9 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 4 Sep 2025 17:40:43 -0700 Subject: [PATCH 1/3] expand agents.md (#62) --- AGENTS.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 76127b1..f27f9a5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # AGENTS.md -This file is for code-writing LLM agents like Claude Code, Gemini CLI, Cursor, etc. +This file contains instructions for code-writing LLM agents like Claude Code, Gemini CLI, Cursor, OpenAI Codex, etc. CLAUDE.md symlinks to this file. @@ -19,4 +19,17 @@ Use the `scripts/` directory to run scripts: - `scripts/lint` - Run linting checks (ruff + pyright + mypy) and import verification - `scripts/format` - Run code formatting (ruff format + doc formatting) - `scripts/test` - Run full test suite (includes Prism mock server setup and Pydantic v1 compatibility tests) -- `scripts/mock` - Start Prism mock server for testing \ No newline at end of file +- `scripts/mock` - Start Prism mock server for testing + + +## Branches and Pull Requests + +When opening a pull request, target the `next` branch. + +The `main` branch reflects code that has been released to the package manager whereas the next branch queues up unreleased changes for you to review via the release PR. + + +## More information + +Read the CONTRIBUTING.md file in this repository for more information. + From 0b697dc72e8a177ad383fac229b7e43ee5d7d1ee Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 11 Sep 2025 18:55:40 +0000 Subject: [PATCH 2/3] chore(tests): simplify `get_platform` test `nest_asyncio` is archived and broken on some platforms so it's not worth keeping in our test suite. --- pyproject.toml | 1 - requirements-dev.lock | 1 - tests/test_client.py | 53 +++++-------------------------------------- 3 files changed, 6 insertions(+), 49 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5e95926..7837369 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,6 @@ dev-dependencies = [ "dirty-equals>=0.6.0", "importlib-metadata>=6.7.0", "rich>=13.7.1", - "nest_asyncio==1.6.0", "pytest-xdist>=3.6.1", ] diff --git a/requirements-dev.lock b/requirements-dev.lock index b9364b9..22fdd88 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -75,7 +75,6 @@ multidict==6.4.4 mypy==1.14.1 mypy-extensions==1.0.0 # via mypy -nest-asyncio==1.6.0 nodeenv==1.8.0 # via pyright nox==2023.4.22 diff --git a/tests/test_client.py b/tests/test_client.py index 607533a..f93834b 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -6,13 +6,10 @@ import os import sys import json -import time import asyncio import inspect -import subprocess import tracemalloc from typing import Any, Union, cast -from textwrap import dedent from unittest import mock from typing_extensions import Literal @@ -23,14 +20,17 @@ from replicate import Replicate, AsyncReplicate, APIResponseValidationError from replicate._types import Omit +from replicate._utils import asyncify from replicate._models import BaseModel, FinalRequestOptions from replicate._exceptions import APIStatusError, ReplicateError, APITimeoutError, APIResponseValidationError from replicate._base_client import ( DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, + OtherPlatform, DefaultHttpxClient, DefaultAsyncHttpxClient, + get_platform, make_request_options, ) @@ -1709,50 +1709,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert response.http_request.headers.get("x-stainless-retry-count") == "42" - def test_get_platform(self) -> None: - # A previous implementation of asyncify could leave threads unterminated when - # used with nest_asyncio. - # - # Since nest_asyncio.apply() is global and cannot be un-applied, this - # test is run in a separate process to avoid affecting other tests. - test_code = dedent(""" - import asyncio - import nest_asyncio - import threading - - from replicate._utils import asyncify - from replicate._base_client import get_platform - - async def test_main() -> None: - result = await asyncify(get_platform)() - print(result) - for thread in threading.enumerate(): - print(thread.name) - - nest_asyncio.apply() - asyncio.run(test_main()) - """) - with subprocess.Popen( - [sys.executable, "-c", test_code], - text=True, - ) as process: - timeout = 10 # seconds - - start_time = time.monotonic() - while True: - return_code = process.poll() - if return_code is not None: - if return_code != 0: - raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code") - - # success - break - - if time.monotonic() - start_time > timeout: - process.kill() - raise AssertionError("calling get_platform using asyncify resulted in a hung process") - - time.sleep(0.1) + async def test_get_platform(self) -> None: + platform = await asyncify(get_platform)() + assert isinstance(platform, (str, OtherPlatform)) async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: # Test that the proxy environment variables are set correctly From 32182f0fe4770c336de7a232a12ea8267a7dbcb7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 11 Sep 2025 18:55:58 +0000 Subject: [PATCH 3/3] release: 2.0.0-alpha.24 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ pyproject.toml | 2 +- src/replicate/_version.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3d42eab..806e32b 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-alpha.23" + ".": "2.0.0-alpha.24" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ddfc55..3313282 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 2.0.0-alpha.24 (2025-09-11) + +Full Changelog: [v2.0.0-alpha.23...v2.0.0-alpha.24](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.23...v2.0.0-alpha.24) + +### Chores + +* **tests:** simplify `get_platform` test ([0b697dc](https://github.com/replicate/replicate-python-stainless/commit/0b697dc72e8a177ad383fac229b7e43ee5d7d1ee)) + ## 2.0.0-alpha.23 (2025-09-04) Full Changelog: [v2.0.0-alpha.22...v2.0.0-alpha.23](https://github.com/replicate/replicate-python-stainless/compare/v2.0.0-alpha.22...v2.0.0-alpha.23) diff --git a/pyproject.toml b/pyproject.toml index 7837369..3e26bf3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "replicate" -version = "2.0.0-alpha.23" +version = "2.0.0-alpha.24" 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 80c40d2..8e98d18 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.23" # x-release-please-version +__version__ = "2.0.0-alpha.24" # x-release-please-version