Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.0.0-alpha.23"
".": "2.0.0-alpha.24"
}
17 changes: 15 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
- `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.

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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",
]

Expand Down
1 change: 0 additions & 1 deletion requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/replicate/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "replicate"
__version__ = "2.0.0-alpha.23" # x-release-please-version
__version__ = "2.0.0-alpha.24" # x-release-please-version
53 changes: 6 additions & 47 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
)

Expand Down Expand Up @@ -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
Expand Down