From d8892cd6e439347c04fb7ba1e97abb421803f379 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 04:39:20 +0000 Subject: [PATCH 1/3] chore(internal): update client tests (#94) --- tests/test_client.py | 46 +++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/tests/test_client.py b/tests/test_client.py index 9d57b3d..628a8c1 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -23,6 +23,7 @@ from runwayml import RunwayML, AsyncRunwayML, APIResponseValidationError from runwayml._types import Omit +from runwayml._utils import maybe_transform from runwayml._models import BaseModel, FinalRequestOptions from runwayml._constants import RAW_RESPONSE_HEADER from runwayml._exceptions import RunwayMLError, APIStatusError, APITimeoutError, APIResponseValidationError @@ -32,6 +33,7 @@ BaseClient, make_request_options, ) +from runwayml.types.image_to_video_create_params import ImageToVideoCreateParams from .utils import update_env @@ -719,10 +721,13 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> No "/v1/image_to_video", body=cast( object, - dict( - model="gen3a_turbo", - prompt_image="https://example.com/assets/bunny.jpg", - prompt_text="The bunny is eating a carrot", + maybe_transform( + dict( + model="gen3a_turbo", + prompt_image="https://example.com/assets/bunny.jpg", + prompt_text="The bunny is eating a carrot", + ), + ImageToVideoCreateParams, ), ), cast_to=httpx.Response, @@ -741,10 +746,13 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> Non "/v1/image_to_video", body=cast( object, - dict( - model="gen3a_turbo", - prompt_image="https://example.com/assets/bunny.jpg", - prompt_text="The bunny is eating a carrot", + maybe_transform( + dict( + model="gen3a_turbo", + prompt_image="https://example.com/assets/bunny.jpg", + prompt_text="The bunny is eating a carrot", + ), + ImageToVideoCreateParams, ), ), cast_to=httpx.Response, @@ -1515,10 +1523,13 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) "/v1/image_to_video", body=cast( object, - dict( - model="gen3a_turbo", - prompt_image="https://example.com/assets/bunny.jpg", - prompt_text="The bunny is eating a carrot", + maybe_transform( + dict( + model="gen3a_turbo", + prompt_image="https://example.com/assets/bunny.jpg", + prompt_text="The bunny is eating a carrot", + ), + ImageToVideoCreateParams, ), ), cast_to=httpx.Response, @@ -1537,10 +1548,13 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) "/v1/image_to_video", body=cast( object, - dict( - model="gen3a_turbo", - prompt_image="https://example.com/assets/bunny.jpg", - prompt_text="The bunny is eating a carrot", + maybe_transform( + dict( + model="gen3a_turbo", + prompt_image="https://example.com/assets/bunny.jpg", + prompt_text="The bunny is eating a carrot", + ), + ImageToVideoCreateParams, ), ), cast_to=httpx.Response, From c478bc7b5115c637a31cb7a0a60a35265500120a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Feb 2025 04:15:58 +0000 Subject: [PATCH 2/3] fix: asyncify on non-asyncio runtimes (#96) --- src/runwayml/_utils/_sync.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/runwayml/_utils/_sync.py b/src/runwayml/_utils/_sync.py index 8b3aaf2..ad7ec71 100644 --- a/src/runwayml/_utils/_sync.py +++ b/src/runwayml/_utils/_sync.py @@ -7,16 +7,20 @@ from typing import Any, TypeVar, Callable, Awaitable from typing_extensions import ParamSpec +import anyio +import sniffio +import anyio.to_thread + T_Retval = TypeVar("T_Retval") T_ParamSpec = ParamSpec("T_ParamSpec") if sys.version_info >= (3, 9): - to_thread = asyncio.to_thread + _asyncio_to_thread = asyncio.to_thread else: # backport of https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread # for Python 3.8 support - async def to_thread( + async def _asyncio_to_thread( func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs ) -> Any: """Asynchronously run function *func* in a separate thread. @@ -34,6 +38,17 @@ async def to_thread( return await loop.run_in_executor(None, func_call) +async def to_thread( + func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs +) -> T_Retval: + if sniffio.current_async_library() == "asyncio": + return await _asyncio_to_thread(func, *args, **kwargs) + + return await anyio.to_thread.run_sync( + functools.partial(func, *args, **kwargs), + ) + + # inspired by `asyncer`, https://github.com/tiangolo/asyncer def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]: """ From b75a92a39f0eee7d3effb79e898cbb53e51af94f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Feb 2025 04:16:17 +0000 Subject: [PATCH 3/3] release: 2.2.2 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 13 +++++++++++++ pyproject.toml | 2 +- src/runwayml/_version.py | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 89d8ff8..b6c8afe 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.2.1" + ".": "2.2.2" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d4de7de..ea2c461 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 2.2.2 (2025-02-14) + +Full Changelog: [v2.2.1...v2.2.2](https://github.com/runwayml/sdk-python/compare/v2.2.1...v2.2.2) + +### Bug Fixes + +* asyncify on non-asyncio runtimes ([#96](https://github.com/runwayml/sdk-python/issues/96)) ([c478bc7](https://github.com/runwayml/sdk-python/commit/c478bc7b5115c637a31cb7a0a60a35265500120a)) + + +### Chores + +* **internal:** update client tests ([#94](https://github.com/runwayml/sdk-python/issues/94)) ([d8892cd](https://github.com/runwayml/sdk-python/commit/d8892cd6e439347c04fb7ba1e97abb421803f379)) + ## 2.2.1 (2025-02-07) Full Changelog: [v2.2.0...v2.2.1](https://github.com/runwayml/sdk-python/compare/v2.2.0...v2.2.1) diff --git a/pyproject.toml b/pyproject.toml index 4404c99..d34e1ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "runwayml" -version = "2.2.1" +version = "2.2.2" description = "The official Python library for the runwayml API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/runwayml/_version.py b/src/runwayml/_version.py index 64fc5a4..3843ffa 100644 --- a/src/runwayml/_version.py +++ b/src/runwayml/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "runwayml" -__version__ = "2.2.1" # x-release-please-version +__version__ = "2.2.2" # x-release-please-version