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.2.1"
".": "2.2.2"
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
19 changes: 17 additions & 2 deletions src/runwayml/_utils/_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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]]:
"""
Expand Down
2 changes: 1 addition & 1 deletion src/runwayml/_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__ = "runwayml"
__version__ = "2.2.1" # x-release-please-version
__version__ = "2.2.2" # x-release-please-version
46 changes: 30 additions & 16 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,6 +33,7 @@
BaseClient,
make_request_options,
)
from runwayml.types.image_to_video_create_params import ImageToVideoCreateParams

from .utils import update_env

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