runwayml 2.1.0__py3-none-any.whl → 2.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
runwayml/_base_client.py CHANGED
@@ -792,6 +792,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
792
792
  custom_query: Mapping[str, object] | None = None,
793
793
  _strict_response_validation: bool,
794
794
  ) -> None:
795
+ kwargs: dict[str, Any] = {}
795
796
  if limits is not None:
796
797
  warnings.warn(
797
798
  "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead",
@@ -804,6 +805,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
804
805
  limits = DEFAULT_CONNECTION_LIMITS
805
806
 
806
807
  if transport is not None:
808
+ kwargs["transport"] = transport
807
809
  warnings.warn(
808
810
  "The `transport` argument is deprecated. The `http_client` argument should be passed instead",
809
811
  category=DeprecationWarning,
@@ -813,6 +815,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
813
815
  raise ValueError("The `http_client` argument is mutually exclusive with `transport`")
814
816
 
815
817
  if proxies is not None:
818
+ kwargs["proxies"] = proxies
816
819
  warnings.warn(
817
820
  "The `proxies` argument is deprecated. The `http_client` argument should be passed instead",
818
821
  category=DeprecationWarning,
@@ -856,10 +859,9 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
856
859
  base_url=base_url,
857
860
  # cast to a valid type because mypy doesn't understand our type narrowing
858
861
  timeout=cast(Timeout, timeout),
859
- proxies=proxies,
860
- transport=transport,
861
862
  limits=limits,
862
863
  follow_redirects=True,
864
+ **kwargs, # type: ignore
863
865
  )
864
866
 
865
867
  def is_closed(self) -> bool:
@@ -1358,6 +1360,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1358
1360
  custom_headers: Mapping[str, str] | None = None,
1359
1361
  custom_query: Mapping[str, object] | None = None,
1360
1362
  ) -> None:
1363
+ kwargs: dict[str, Any] = {}
1361
1364
  if limits is not None:
1362
1365
  warnings.warn(
1363
1366
  "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead",
@@ -1370,6 +1373,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1370
1373
  limits = DEFAULT_CONNECTION_LIMITS
1371
1374
 
1372
1375
  if transport is not None:
1376
+ kwargs["transport"] = transport
1373
1377
  warnings.warn(
1374
1378
  "The `transport` argument is deprecated. The `http_client` argument should be passed instead",
1375
1379
  category=DeprecationWarning,
@@ -1379,6 +1383,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1379
1383
  raise ValueError("The `http_client` argument is mutually exclusive with `transport`")
1380
1384
 
1381
1385
  if proxies is not None:
1386
+ kwargs["proxies"] = proxies
1382
1387
  warnings.warn(
1383
1388
  "The `proxies` argument is deprecated. The `http_client` argument should be passed instead",
1384
1389
  category=DeprecationWarning,
@@ -1422,10 +1427,9 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1422
1427
  base_url=base_url,
1423
1428
  # cast to a valid type because mypy doesn't understand our type narrowing
1424
1429
  timeout=cast(Timeout, timeout),
1425
- proxies=proxies,
1426
- transport=transport,
1427
1430
  limits=limits,
1428
1431
  follow_redirects=True,
1432
+ **kwargs, # type: ignore
1429
1433
  )
1430
1434
 
1431
1435
  def is_closed(self) -> bool:
runwayml/_compat.py CHANGED
@@ -145,7 +145,8 @@ def model_dump(
145
145
  exclude=exclude,
146
146
  exclude_unset=exclude_unset,
147
147
  exclude_defaults=exclude_defaults,
148
- warnings=warnings,
148
+ # warnings are not supported in Pydantic v1
149
+ warnings=warnings if PYDANTIC_V2 else True,
149
150
  )
150
151
  return cast(
151
152
  "dict[str, Any]",
@@ -213,9 +214,6 @@ if TYPE_CHECKING:
213
214
  # __set__ is not defined at runtime, but @cached_property is designed to be settable
214
215
  def __set__(self, instance: object, value: _T) -> None: ...
215
216
  else:
216
- try:
217
- from functools import cached_property as cached_property
218
- except ImportError:
219
- from cached_property import cached_property as cached_property
217
+ from functools import cached_property as cached_property
220
218
 
221
219
  typed_cached_property = cached_property
runwayml/_utils/_sync.py CHANGED
@@ -1,56 +1,62 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import sys
4
+ import asyncio
3
5
  import functools
4
- from typing import TypeVar, Callable, Awaitable
6
+ import contextvars
7
+ from typing import Any, TypeVar, Callable, Awaitable
5
8
  from typing_extensions import ParamSpec
6
9
 
7
- import anyio
8
- import anyio.to_thread
9
-
10
- from ._reflection import function_has_argument
11
-
12
10
  T_Retval = TypeVar("T_Retval")
13
11
  T_ParamSpec = ParamSpec("T_ParamSpec")
14
12
 
15
13
 
16
- # copied from `asyncer`, https://github.com/tiangolo/asyncer
17
- def asyncify(
18
- function: Callable[T_ParamSpec, T_Retval],
19
- *,
20
- cancellable: bool = False,
21
- limiter: anyio.CapacityLimiter | None = None,
22
- ) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
14
+ if sys.version_info >= (3, 9):
15
+ to_thread = asyncio.to_thread
16
+ else:
17
+ # backport of https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread
18
+ # for Python 3.8 support
19
+ async def to_thread(
20
+ func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
21
+ ) -> Any:
22
+ """Asynchronously run function *func* in a separate thread.
23
+
24
+ Any *args and **kwargs supplied for this function are directly passed
25
+ to *func*. Also, the current :class:`contextvars.Context` is propagated,
26
+ allowing context variables from the main thread to be accessed in the
27
+ separate thread.
28
+
29
+ Returns a coroutine that can be awaited to get the eventual result of *func*.
30
+ """
31
+ loop = asyncio.events.get_running_loop()
32
+ ctx = contextvars.copy_context()
33
+ func_call = functools.partial(ctx.run, func, *args, **kwargs)
34
+ return await loop.run_in_executor(None, func_call)
35
+
36
+
37
+ # inspired by `asyncer`, https://github.com/tiangolo/asyncer
38
+ def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
23
39
  """
24
40
  Take a blocking function and create an async one that receives the same
25
- positional and keyword arguments, and that when called, calls the original function
26
- in a worker thread using `anyio.to_thread.run_sync()`. Internally,
27
- `asyncer.asyncify()` uses the same `anyio.to_thread.run_sync()`, but it supports
28
- keyword arguments additional to positional arguments and it adds better support for
29
- autocompletion and inline errors for the arguments of the function called and the
30
- return value.
31
-
32
- If the `cancellable` option is enabled and the task waiting for its completion is
33
- cancelled, the thread will still run its course but its return value (or any raised
34
- exception) will be ignored.
41
+ positional and keyword arguments. For python version 3.9 and above, it uses
42
+ asyncio.to_thread to run the function in a separate thread. For python version
43
+ 3.8, it uses locally defined copy of the asyncio.to_thread function which was
44
+ introduced in python 3.9.
35
45
 
36
- Use it like this:
46
+ Usage:
37
47
 
38
- ```Python
39
- def do_work(arg1, arg2, kwarg1="", kwarg2="") -> str:
40
- # Do work
41
- return "Some result"
48
+ ```python
49
+ def blocking_func(arg1, arg2, kwarg1=None):
50
+ # blocking code
51
+ return result
42
52
 
43
53
 
44
- result = await to_thread.asyncify(do_work)("spam", "ham", kwarg1="a", kwarg2="b")
45
- print(result)
54
+ result = asyncify(blocking_function)(arg1, arg2, kwarg1=value1)
46
55
  ```
47
56
 
48
57
  ## Arguments
49
58
 
50
59
  `function`: a blocking regular callable (e.g. a function)
51
- `cancellable`: `True` to allow cancellation of the operation
52
- `limiter`: capacity limiter to use to limit the total amount of threads running
53
- (if omitted, the default limiter is used)
54
60
 
55
61
  ## Return
56
62
 
@@ -60,22 +66,6 @@ def asyncify(
60
66
  """
61
67
 
62
68
  async def wrapper(*args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs) -> T_Retval:
63
- partial_f = functools.partial(function, *args, **kwargs)
64
-
65
- # In `v4.1.0` anyio added the `abandon_on_cancel` argument and deprecated the old
66
- # `cancellable` argument, so we need to use the new `abandon_on_cancel` to avoid
67
- # surfacing deprecation warnings.
68
- if function_has_argument(anyio.to_thread.run_sync, "abandon_on_cancel"):
69
- return await anyio.to_thread.run_sync(
70
- partial_f,
71
- abandon_on_cancel=cancellable,
72
- limiter=limiter,
73
- )
74
-
75
- return await anyio.to_thread.run_sync(
76
- partial_f,
77
- cancellable=cancellable,
78
- limiter=limiter,
79
- )
69
+ return await to_thread(function, *args, **kwargs)
80
70
 
81
71
  return wrapper
@@ -316,6 +316,11 @@ async def _async_transform_recursive(
316
316
  # Iterable[T]
317
317
  or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
318
318
  ):
319
+ # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
320
+ # intended as an iterable, so we don't transform it.
321
+ if isinstance(data, dict):
322
+ return cast(object, data)
323
+
319
324
  inner_type = extract_type_arg(stripped_type, 0)
320
325
  return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
321
326
 
runwayml/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "runwayml"
4
- __version__ = "2.1.0" # x-release-please-version
4
+ __version__ = "2.1.1" # x-release-please-version
@@ -1,12 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: runwayml
3
- Version: 2.1.0
3
+ Version: 2.1.1
4
4
  Summary: The official Python library for the runwayml API
5
5
  Project-URL: Homepage, https://github.com/runwayml/sdk-python
6
6
  Project-URL: Repository, https://github.com/runwayml/sdk-python
7
7
  Author-email: RunwayML <dev-feedback@runwayml.com>
8
- License-Expression: Apache-2.0
9
- License-File: LICENSE
8
+ License: Apache-2.0
10
9
  Classifier: Intended Audience :: Developers
11
10
  Classifier: License :: OSI Approved :: Apache Software License
12
11
  Classifier: Operating System :: MacOS
@@ -23,7 +22,6 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
22
  Classifier: Typing :: Typed
24
23
  Requires-Python: >=3.8
25
24
  Requires-Dist: anyio<5,>=3.5.0
26
- Requires-Dist: cached-property; python_version < '3.8'
27
25
  Requires-Dist: distro<2,>=1.7.0
28
26
  Requires-Dist: httpx<1,>=0.23.0
29
27
  Requires-Dist: pydantic<3,>=1.9.0
@@ -61,8 +59,7 @@ import os
61
59
  from runwayml import RunwayML
62
60
 
63
61
  client = RunwayML(
64
- # This is the default and can be omitted
65
- api_key=os.environ.get("RUNWAYML_API_SECRET"),
62
+ api_key=os.environ.get("RUNWAYML_API_SECRET"), # This is the default and can be omitted
66
63
  )
67
64
 
68
65
  image_to_video = client.image_to_video.create(
@@ -88,8 +85,7 @@ import asyncio
88
85
  from runwayml import AsyncRunwayML
89
86
 
90
87
  client = AsyncRunwayML(
91
- # This is the default and can be omitted
92
- api_key=os.environ.get("RUNWAYML_API_SECRET"),
88
+ api_key=os.environ.get("RUNWAYML_API_SECRET"), # This is the default and can be omitted
93
89
  )
94
90
 
95
91
 
@@ -223,12 +219,14 @@ Note that requests that time out are [retried twice by default](https://github.c
223
219
 
224
220
  We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
225
221
 
226
- You can enable logging by setting the environment variable `RUNWAYML_LOG` to `debug`.
222
+ You can enable logging by setting the environment variable `RUNWAYML_LOG` to `info`.
227
223
 
228
224
  ```shell
229
- $ export RUNWAYML_LOG=debug
225
+ $ export RUNWAYML_LOG=info
230
226
  ```
231
227
 
228
+ Or to `debug` for more verbose logging.
229
+
232
230
  ### How to tell whether `None` means `null` or missing
233
231
 
234
232
  In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:
@@ -1,7 +1,7 @@
1
1
  runwayml/__init__.py,sha256=LsywCoz3efgd9DJAXxam_dZp4-0CuDCfyY658Isqy8k,2458
2
- runwayml/_base_client.py,sha256=JZj36mhT5VFQZj-_KhawxsYsoiIzBKDaNmqosZwOQC4,67846
2
+ runwayml/_base_client.py,sha256=Ehfq1oaghucmu9n_MpuoOlH-qZGbetwzgNOmVG81cns,68038
3
3
  runwayml/_client.py,sha256=mJfU5Cq2rBWL1fwMlbjFd9w5oWZ8kb5Ps5B37y53PQw,16428
4
- runwayml/_compat.py,sha256=fQkXUY7reJc8m_yguMWSjHBfO8lNzw4wOAxtkhP9d1Q,6607
4
+ runwayml/_compat.py,sha256=VWemUKbj6DDkQ-O4baSpHVLJafotzeXmCQGJugfVTIw,6580
5
5
  runwayml/_constants.py,sha256=JE8kyZa2Q4NK_i4fO--8siEYTzeHnT0fYbOFDgDP4uk,464
6
6
  runwayml/_exceptions.py,sha256=p2Q8kywHCVQzArLQL4Ht-HetTBhAvevU6yDvEq7PpIE,3224
7
7
  runwayml/_files.py,sha256=mf4dOgL4b0ryyZlbqLhggD3GVgDf6XxdGFAgce01ugE,3549
@@ -11,15 +11,15 @@ runwayml/_resource.py,sha256=BF-j3xY5eRTKmuTxg8eDhLtLP4MLB1phDh_B6BKipKA,1112
11
11
  runwayml/_response.py,sha256=7EGNYCVRHiVys7y6gAx5HWIwUxWvmjhd05ur53OeFkQ,28621
12
12
  runwayml/_streaming.py,sha256=NSVuAgknVQWU1cgZEjQn01IdZKKynb5rOeYp5Lo-OEQ,10108
13
13
  runwayml/_types.py,sha256=Mr22kL-koHslGlVH9m-m0B9AMh9Ke2iktDDu_rTGdy4,6169
14
- runwayml/_version.py,sha256=Q13Mdu-wI8eYR-VMNkBsal9FhtGE8eXvUuWPzokQAfs,160
14
+ runwayml/_version.py,sha256=jewVENkeCrsl3eeyxLXqBB-3C3t83ldrhRd3uFyAEd4,160
15
15
  runwayml/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  runwayml/_utils/__init__.py,sha256=k266EatJr88V8Zseb7xUimTlCeno9SynRfLwadHP1b4,2016
17
17
  runwayml/_utils/_logs.py,sha256=ZfS5W59hdqEBVV86lNrk28PhvUxtHOzs9JqiLhSu0pI,780
18
18
  runwayml/_utils/_proxy.py,sha256=z3zsateHtb0EARTWKk8QZNHfPkqJbqwd1lM993LBwGE,1902
19
19
  runwayml/_utils/_reflection.py,sha256=ZmGkIgT_PuwedyNBrrKGbxoWtkpytJNU1uU4QHnmEMU,1364
20
20
  runwayml/_utils/_streams.py,sha256=SMC90diFFecpEg_zgDRVbdR3hSEIgVVij4taD-noMLM,289
21
- runwayml/_utils/_sync.py,sha256=9ex9pfOyd8xAF1LxpFx4IkqL8k0vk8srE2Ee-OTMQ0A,2840
22
- runwayml/_utils/_transform.py,sha256=GcsgDf2GwWGI6a7DTKRKa7JPdzcv2EFK8IHFG_8Cw5E,13226
21
+ runwayml/_utils/_sync.py,sha256=jJl-iCEaZZUAkq4IUtzN1-aMsKTUFaNoNbeYnnpQjIQ,2438
22
+ runwayml/_utils/_transform.py,sha256=Dkkyr7OveGmOolepcvXmVJWE3kqim4b0nM0h7yWbgeY,13468
23
23
  runwayml/_utils/_typing.py,sha256=tFbktdpdHCQliwzGsWysgn0P5H0JRdagkZdb_LegGkY,3838
24
24
  runwayml/_utils/_utils.py,sha256=8UmbPOy_AAr2uUjjFui-VZSrVBHRj6bfNEKRp5YZP2A,12004
25
25
  runwayml/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
@@ -30,7 +30,7 @@ runwayml/types/__init__.py,sha256=R3cLEXzpcEpEOuxaFBo3R72ewH1LtjpkZ0aYOIt1CAo,40
30
30
  runwayml/types/image_to_video_create_params.py,sha256=98DsjOHnmHEi8mVjZOQEDL3P1hJUT8uktp0mDA5WJ5Y,1869
31
31
  runwayml/types/image_to_video_create_response.py,sha256=l5GszzUSItV-ZYHCB8hH_GSVibUZEkzfRLrAhXkd8O4,346
32
32
  runwayml/types/task_retrieve_response.py,sha256=v8y2bLxsW6srzScW-B3Akv72q_PI_NQmduGrGRQMHds,2139
33
- runwayml-2.1.0.dist-info/METADATA,sha256=bH3HLY2e_TgITkCpbnSqYILCuc_2ugd8bwvyfqYjgUo,13358
34
- runwayml-2.1.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
35
- runwayml-2.1.0.dist-info/licenses/LICENSE,sha256=p4nykVRdA5nXTd8-slKCIfrlJZMB3wn8QBVasNQ_G_Q,11338
36
- runwayml-2.1.0.dist-info/RECORD,,
33
+ runwayml-2.1.1.dist-info/METADATA,sha256=1jF1NtUuZ-vNGcSndJolTsRgr3TEDG_e5I-JKo7xZf0,13303
34
+ runwayml-2.1.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
35
+ runwayml-2.1.1.dist-info/licenses/LICENSE,sha256=p4nykVRdA5nXTd8-slKCIfrlJZMB3wn8QBVasNQ_G_Q,11338
36
+ runwayml-2.1.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.26.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any