runwayml 1.0.0__tar.gz → 2.0.0__tar.gz

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.
Files changed (70) hide show
  1. runwayml-2.0.0/.release-please-manifest.json +3 -0
  2. {runwayml-1.0.0 → runwayml-2.0.0}/CHANGELOG.md +15 -0
  3. {runwayml-1.0.0 → runwayml-2.0.0}/CONTRIBUTING.md +24 -20
  4. {runwayml-1.0.0 → runwayml-2.0.0}/PKG-INFO +5 -1
  5. {runwayml-1.0.0 → runwayml-2.0.0}/README.md +4 -0
  6. {runwayml-1.0.0 → runwayml-2.0.0}/pyproject.toml +1 -1
  7. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_base_client.py +63 -48
  8. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_compat.py +2 -0
  9. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_version.py +1 -1
  10. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/resources/image_to_video.py +16 -0
  11. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/types/image_to_video_create_params.py +6 -0
  12. {runwayml-1.0.0 → runwayml-2.0.0}/tests/api_resources/test_image_to_video.py +4 -0
  13. {runwayml-1.0.0 → runwayml-2.0.0}/tests/test_client.py +104 -0
  14. runwayml-1.0.0/.release-please-manifest.json +0 -3
  15. {runwayml-1.0.0 → runwayml-2.0.0}/.gitignore +0 -0
  16. {runwayml-1.0.0 → runwayml-2.0.0}/LICENSE +0 -0
  17. {runwayml-1.0.0 → runwayml-2.0.0}/SECURITY.md +0 -0
  18. {runwayml-1.0.0 → runwayml-2.0.0}/api.md +0 -0
  19. {runwayml-1.0.0 → runwayml-2.0.0}/bin/check-release-environment +0 -0
  20. {runwayml-1.0.0 → runwayml-2.0.0}/bin/publish-pypi +0 -0
  21. {runwayml-1.0.0 → runwayml-2.0.0}/examples/.keep +0 -0
  22. {runwayml-1.0.0 → runwayml-2.0.0}/mypy.ini +0 -0
  23. {runwayml-1.0.0 → runwayml-2.0.0}/noxfile.py +0 -0
  24. {runwayml-1.0.0 → runwayml-2.0.0}/release-please-config.json +0 -0
  25. {runwayml-1.0.0 → runwayml-2.0.0}/requirements-dev.lock +0 -0
  26. {runwayml-1.0.0 → runwayml-2.0.0}/requirements.lock +0 -0
  27. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/__init__.py +0 -0
  28. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_client.py +0 -0
  29. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_constants.py +0 -0
  30. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_exceptions.py +0 -0
  31. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_files.py +0 -0
  32. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_models.py +0 -0
  33. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_qs.py +0 -0
  34. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_resource.py +0 -0
  35. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_response.py +0 -0
  36. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_streaming.py +0 -0
  37. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_types.py +0 -0
  38. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_utils/__init__.py +0 -0
  39. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_utils/_logs.py +0 -0
  40. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_utils/_proxy.py +0 -0
  41. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_utils/_reflection.py +0 -0
  42. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_utils/_streams.py +0 -0
  43. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_utils/_sync.py +0 -0
  44. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_utils/_transform.py +0 -0
  45. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_utils/_typing.py +0 -0
  46. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/_utils/_utils.py +0 -0
  47. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/lib/.keep +0 -0
  48. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/py.typed +0 -0
  49. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/resources/__init__.py +0 -0
  50. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/resources/tasks.py +0 -0
  51. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/types/__init__.py +0 -0
  52. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/types/image_to_video_create_response.py +0 -0
  53. {runwayml-1.0.0 → runwayml-2.0.0}/src/runwayml/types/task_retrieve_response.py +0 -0
  54. {runwayml-1.0.0 → runwayml-2.0.0}/tests/__init__.py +0 -0
  55. {runwayml-1.0.0 → runwayml-2.0.0}/tests/api_resources/__init__.py +0 -0
  56. {runwayml-1.0.0 → runwayml-2.0.0}/tests/api_resources/test_tasks.py +0 -0
  57. {runwayml-1.0.0 → runwayml-2.0.0}/tests/conftest.py +0 -0
  58. {runwayml-1.0.0 → runwayml-2.0.0}/tests/sample_file.txt +0 -0
  59. {runwayml-1.0.0 → runwayml-2.0.0}/tests/test_deepcopy.py +0 -0
  60. {runwayml-1.0.0 → runwayml-2.0.0}/tests/test_extract_files.py +0 -0
  61. {runwayml-1.0.0 → runwayml-2.0.0}/tests/test_files.py +0 -0
  62. {runwayml-1.0.0 → runwayml-2.0.0}/tests/test_models.py +0 -0
  63. {runwayml-1.0.0 → runwayml-2.0.0}/tests/test_qs.py +0 -0
  64. {runwayml-1.0.0 → runwayml-2.0.0}/tests/test_required_args.py +0 -0
  65. {runwayml-1.0.0 → runwayml-2.0.0}/tests/test_response.py +0 -0
  66. {runwayml-1.0.0 → runwayml-2.0.0}/tests/test_streaming.py +0 -0
  67. {runwayml-1.0.0 → runwayml-2.0.0}/tests/test_transform.py +0 -0
  68. {runwayml-1.0.0 → runwayml-2.0.0}/tests/test_utils/test_proxy.py +0 -0
  69. {runwayml-1.0.0 → runwayml-2.0.0}/tests/test_utils/test_typing.py +0 -0
  70. {runwayml-1.0.0 → runwayml-2.0.0}/tests/utils.py +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "2.0.0"
3
+ }
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.0 (2024-10-04)
4
+
5
+ Full Changelog: [v1.0.0...v2.0.0](https://github.com/runwayml/sdk-python/compare/v1.0.0...v2.0.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** update via SDK Studio ([#7](https://github.com/runwayml/sdk-python/issues/7)) ([e31ea2c](https://github.com/runwayml/sdk-python/commit/e31ea2ca5602245bd936d564b66752f592cc2fab))
10
+
11
+
12
+ ### Chores
13
+
14
+ * **internal:** codegen related update ([#10](https://github.com/runwayml/sdk-python/issues/10)) ([b1b5a5f](https://github.com/runwayml/sdk-python/commit/b1b5a5f1eb6dadc9674e771a598d7269a6ed23b2))
15
+ * **internal:** codegen related update ([#11](https://github.com/runwayml/sdk-python/issues/11)) ([6a8ccd0](https://github.com/runwayml/sdk-python/commit/6a8ccd00924f775851a9a8e9429ae4b2f1790dee))
16
+ * **internal:** codegen related update ([#8](https://github.com/runwayml/sdk-python/issues/8)) ([c66ad91](https://github.com/runwayml/sdk-python/commit/c66ad91471c094e4c42bbbefdce4ea0d81fe487f))
17
+
3
18
  ## 1.0.0 (2024-09-18)
4
19
 
5
20
  Full Changelog: [v0.1.0-alpha.1...v1.0.0](https://github.com/runwayml/sdk-python/compare/v0.1.0-alpha.1...v1.0.0)
@@ -2,9 +2,13 @@
2
2
 
3
3
  ### With Rye
4
4
 
5
- We use [Rye](https://rye.astral.sh/) to manage dependencies so we highly recommend [installing it](https://rye.astral.sh/guide/installation/) as it will automatically provision a Python environment with the expected Python version.
5
+ We use [Rye](https://rye.astral.sh/) to manage dependencies because it will automatically provision a Python environment with the expected Python version. To set it up, run:
6
6
 
7
- After installing Rye, you'll just have to run this command:
7
+ ```sh
8
+ $ ./scripts/bootstrap
9
+ ```
10
+
11
+ Or [install Rye manually](https://rye.astral.sh/guide/installation/) and run:
8
12
 
9
13
  ```sh
10
14
  $ rye sync --all-features
@@ -39,17 +43,17 @@ modify the contents of the `src/runwayml/lib/` and `examples/` directories.
39
43
 
40
44
  All files in the `examples/` directory are not modified by the generator and can be freely edited or added to.
41
45
 
42
- ```bash
46
+ ```py
43
47
  # add an example to examples/<your-example>.py
44
48
 
45
49
  #!/usr/bin/env -S rye run python
46
50
 
47
51
  ```
48
52
 
49
- ```
50
- chmod +x examples/<your-example>.py
53
+ ```sh
54
+ $ chmod +x examples/<your-example>.py
51
55
  # run the example against your api
52
- ./examples/<your-example>.py
56
+ $ ./examples/<your-example>.py
53
57
  ```
54
58
 
55
59
  ## Using the repository from source
@@ -58,8 +62,8 @@ If you’d like to use the repository from source, you can either install from g
58
62
 
59
63
  To install via git:
60
64
 
61
- ```bash
62
- pip install git+ssh://git@github.com/runwayml/sdk-python.git
65
+ ```sh
66
+ $ pip install git+ssh://git@github.com/runwayml/sdk-python.git
63
67
  ```
64
68
 
65
69
  Alternatively, you can build from source and install the wheel file:
@@ -68,29 +72,29 @@ Building this package will create two files in the `dist/` directory, a `.tar.gz
68
72
 
69
73
  To create a distributable version of the library, all you have to do is run this command:
70
74
 
71
- ```bash
72
- rye build
75
+ ```sh
76
+ $ rye build
73
77
  # or
74
- python -m build
78
+ $ python -m build
75
79
  ```
76
80
 
77
81
  Then to install:
78
82
 
79
83
  ```sh
80
- pip install ./path-to-wheel-file.whl
84
+ $ pip install ./path-to-wheel-file.whl
81
85
  ```
82
86
 
83
87
  ## Running tests
84
88
 
85
89
  Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.
86
90
 
87
- ```bash
91
+ ```sh
88
92
  # you will need npm installed
89
- npx prism mock path/to/your/openapi.yml
93
+ $ npx prism mock path/to/your/openapi.yml
90
94
  ```
91
95
 
92
- ```bash
93
- rye run pytest
96
+ ```sh
97
+ $ ./scripts/test
94
98
  ```
95
99
 
96
100
  ## Linting and formatting
@@ -100,14 +104,14 @@ This repository uses [ruff](https://github.com/astral-sh/ruff) and
100
104
 
101
105
  To lint:
102
106
 
103
- ```bash
104
- rye run lint
107
+ ```sh
108
+ $ ./scripts/lint
105
109
  ```
106
110
 
107
111
  To format and fix all ruff issues automatically:
108
112
 
109
- ```bash
110
- rye run format
113
+ ```sh
114
+ $ ./scripts/format
111
115
  ```
112
116
 
113
117
  ## Publishing and releases
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: runwayml
3
- Version: 1.0.0
3
+ Version: 2.0.0
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
@@ -377,3 +377,7 @@ print(runwayml.__version__)
377
377
  ## Requirements
378
378
 
379
379
  Python 3.7 or higher.
380
+
381
+ ## Contributing
382
+
383
+ See [the contributing documentation](https://github.com/runwayml/sdk-python/tree/main/./CONTRIBUTING.md).
@@ -343,3 +343,7 @@ print(runwayml.__version__)
343
343
  ## Requirements
344
344
 
345
345
  Python 3.7 or higher.
346
+
347
+ ## Contributing
348
+
349
+ See [the contributing documentation](./CONTRIBUTING.md).
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "runwayml"
3
- version = "1.0.0"
3
+ version = "2.0.0"
4
4
  description = "The official Python library for the runwayml API"
5
5
  dynamic = ["readme"]
6
6
  license = "Apache-2.0"
@@ -400,14 +400,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
400
400
  ) -> _exceptions.APIStatusError:
401
401
  raise NotImplementedError()
402
402
 
403
- def _remaining_retries(
404
- self,
405
- remaining_retries: Optional[int],
406
- options: FinalRequestOptions,
407
- ) -> int:
408
- return remaining_retries if remaining_retries is not None else options.get_max_retries(self.max_retries)
409
-
410
- def _build_headers(self, options: FinalRequestOptions) -> httpx.Headers:
403
+ def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0) -> httpx.Headers:
411
404
  custom_headers = options.headers or {}
412
405
  headers_dict = _merge_mappings(self.default_headers, custom_headers)
413
406
  self._validate_headers(headers_dict, custom_headers)
@@ -419,6 +412,11 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
419
412
  if idempotency_header and options.method.lower() != "get" and idempotency_header not in headers:
420
413
  headers[idempotency_header] = options.idempotency_key or self._idempotency_key()
421
414
 
415
+ # Don't set the retry count header if it was already set or removed by the caller. We check
416
+ # `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
417
+ if "x-stainless-retry-count" not in (header.lower() for header in custom_headers):
418
+ headers["x-stainless-retry-count"] = str(retries_taken)
419
+
422
420
  return headers
423
421
 
424
422
  def _prepare_url(self, url: str) -> URL:
@@ -440,6 +438,8 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
440
438
  def _build_request(
441
439
  self,
442
440
  options: FinalRequestOptions,
441
+ *,
442
+ retries_taken: int = 0,
443
443
  ) -> httpx.Request:
444
444
  if log.isEnabledFor(logging.DEBUG):
445
445
  log.debug("Request options: %s", model_dump(options, exclude_unset=True))
@@ -455,7 +455,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
455
455
  else:
456
456
  raise RuntimeError(f"Unexpected JSON data type, {type(json_data)}, cannot merge with `extra_body`")
457
457
 
458
- headers = self._build_headers(options)
458
+ headers = self._build_headers(options, retries_taken=retries_taken)
459
459
  params = _merge_mappings(self.default_query, options.params)
460
460
  content_type = headers.get("Content-Type")
461
461
  files = options.files
@@ -489,12 +489,17 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
489
489
  if not files:
490
490
  files = cast(HttpxRequestFiles, ForceMultipartDict())
491
491
 
492
+ prepared_url = self._prepare_url(options.url)
493
+ if "_" in prepared_url.host:
494
+ # work around https://github.com/encode/httpx/discussions/2880
495
+ kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}
496
+
492
497
  # TODO: report this error to httpx
493
498
  return self._client.build_request( # pyright: ignore[reportUnknownMemberType]
494
499
  headers=headers,
495
500
  timeout=self.timeout if isinstance(options.timeout, NotGiven) else options.timeout,
496
501
  method=options.method,
497
- url=self._prepare_url(options.url),
502
+ url=prepared_url,
498
503
  # the `Query` type that we use is incompatible with qs'
499
504
  # `Params` type as it needs to be typed as `Mapping[str, object]`
500
505
  # so that passing a `TypedDict` doesn't cause an error.
@@ -933,12 +938,17 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
933
938
  stream: bool = False,
934
939
  stream_cls: type[_StreamT] | None = None,
935
940
  ) -> ResponseT | _StreamT:
941
+ if remaining_retries is not None:
942
+ retries_taken = options.get_max_retries(self.max_retries) - remaining_retries
943
+ else:
944
+ retries_taken = 0
945
+
936
946
  return self._request(
937
947
  cast_to=cast_to,
938
948
  options=options,
939
949
  stream=stream,
940
950
  stream_cls=stream_cls,
941
- remaining_retries=remaining_retries,
951
+ retries_taken=retries_taken,
942
952
  )
943
953
 
944
954
  def _request(
@@ -946,7 +956,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
946
956
  *,
947
957
  cast_to: Type[ResponseT],
948
958
  options: FinalRequestOptions,
949
- remaining_retries: int | None,
959
+ retries_taken: int,
950
960
  stream: bool,
951
961
  stream_cls: type[_StreamT] | None,
952
962
  ) -> ResponseT | _StreamT:
@@ -958,8 +968,8 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
958
968
  cast_to = self._maybe_override_cast_to(cast_to, options)
959
969
  options = self._prepare_options(options)
960
970
 
961
- retries = self._remaining_retries(remaining_retries, options)
962
- request = self._build_request(options)
971
+ remaining_retries = options.get_max_retries(self.max_retries) - retries_taken
972
+ request = self._build_request(options, retries_taken=retries_taken)
963
973
  self._prepare_request(request)
964
974
 
965
975
  kwargs: HttpxSendArgs = {}
@@ -977,11 +987,11 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
977
987
  except httpx.TimeoutException as err:
978
988
  log.debug("Encountered httpx.TimeoutException", exc_info=True)
979
989
 
980
- if retries > 0:
990
+ if remaining_retries > 0:
981
991
  return self._retry_request(
982
992
  input_options,
983
993
  cast_to,
984
- retries,
994
+ retries_taken=retries_taken,
985
995
  stream=stream,
986
996
  stream_cls=stream_cls,
987
997
  response_headers=None,
@@ -992,11 +1002,11 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
992
1002
  except Exception as err:
993
1003
  log.debug("Encountered Exception", exc_info=True)
994
1004
 
995
- if retries > 0:
1005
+ if remaining_retries > 0:
996
1006
  return self._retry_request(
997
1007
  input_options,
998
1008
  cast_to,
999
- retries,
1009
+ retries_taken=retries_taken,
1000
1010
  stream=stream,
1001
1011
  stream_cls=stream_cls,
1002
1012
  response_headers=None,
@@ -1019,13 +1029,13 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1019
1029
  except httpx.HTTPStatusError as err: # thrown on 4xx and 5xx status code
1020
1030
  log.debug("Encountered httpx.HTTPStatusError", exc_info=True)
1021
1031
 
1022
- if retries > 0 and self._should_retry(err.response):
1032
+ if remaining_retries > 0 and self._should_retry(err.response):
1023
1033
  err.response.close()
1024
1034
  return self._retry_request(
1025
1035
  input_options,
1026
1036
  cast_to,
1027
- retries,
1028
- err.response.headers,
1037
+ retries_taken=retries_taken,
1038
+ response_headers=err.response.headers,
1029
1039
  stream=stream,
1030
1040
  stream_cls=stream_cls,
1031
1041
  )
@@ -1044,26 +1054,26 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1044
1054
  response=response,
1045
1055
  stream=stream,
1046
1056
  stream_cls=stream_cls,
1047
- retries_taken=options.get_max_retries(self.max_retries) - retries,
1057
+ retries_taken=retries_taken,
1048
1058
  )
1049
1059
 
1050
1060
  def _retry_request(
1051
1061
  self,
1052
1062
  options: FinalRequestOptions,
1053
1063
  cast_to: Type[ResponseT],
1054
- remaining_retries: int,
1055
- response_headers: httpx.Headers | None,
1056
1064
  *,
1065
+ retries_taken: int,
1066
+ response_headers: httpx.Headers | None,
1057
1067
  stream: bool,
1058
1068
  stream_cls: type[_StreamT] | None,
1059
1069
  ) -> ResponseT | _StreamT:
1060
- remaining = remaining_retries - 1
1061
- if remaining == 1:
1070
+ remaining_retries = options.get_max_retries(self.max_retries) - retries_taken
1071
+ if remaining_retries == 1:
1062
1072
  log.debug("1 retry left")
1063
1073
  else:
1064
- log.debug("%i retries left", remaining)
1074
+ log.debug("%i retries left", remaining_retries)
1065
1075
 
1066
- timeout = self._calculate_retry_timeout(remaining, options, response_headers)
1076
+ timeout = self._calculate_retry_timeout(remaining_retries, options, response_headers)
1067
1077
  log.info("Retrying request to %s in %f seconds", options.url, timeout)
1068
1078
 
1069
1079
  # In a synchronous context we are blocking the entire thread. Up to the library user to run the client in a
@@ -1073,7 +1083,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1073
1083
  return self._request(
1074
1084
  options=options,
1075
1085
  cast_to=cast_to,
1076
- remaining_retries=remaining,
1086
+ retries_taken=retries_taken + 1,
1077
1087
  stream=stream,
1078
1088
  stream_cls=stream_cls,
1079
1089
  )
@@ -1491,12 +1501,17 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1491
1501
  stream_cls: type[_AsyncStreamT] | None = None,
1492
1502
  remaining_retries: Optional[int] = None,
1493
1503
  ) -> ResponseT | _AsyncStreamT:
1504
+ if remaining_retries is not None:
1505
+ retries_taken = options.get_max_retries(self.max_retries) - remaining_retries
1506
+ else:
1507
+ retries_taken = 0
1508
+
1494
1509
  return await self._request(
1495
1510
  cast_to=cast_to,
1496
1511
  options=options,
1497
1512
  stream=stream,
1498
1513
  stream_cls=stream_cls,
1499
- remaining_retries=remaining_retries,
1514
+ retries_taken=retries_taken,
1500
1515
  )
1501
1516
 
1502
1517
  async def _request(
@@ -1506,7 +1521,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1506
1521
  *,
1507
1522
  stream: bool,
1508
1523
  stream_cls: type[_AsyncStreamT] | None,
1509
- remaining_retries: int | None,
1524
+ retries_taken: int,
1510
1525
  ) -> ResponseT | _AsyncStreamT:
1511
1526
  if self._platform is None:
1512
1527
  # `get_platform` can make blocking IO calls so we
@@ -1521,8 +1536,8 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1521
1536
  cast_to = self._maybe_override_cast_to(cast_to, options)
1522
1537
  options = await self._prepare_options(options)
1523
1538
 
1524
- retries = self._remaining_retries(remaining_retries, options)
1525
- request = self._build_request(options)
1539
+ remaining_retries = options.get_max_retries(self.max_retries) - retries_taken
1540
+ request = self._build_request(options, retries_taken=retries_taken)
1526
1541
  await self._prepare_request(request)
1527
1542
 
1528
1543
  kwargs: HttpxSendArgs = {}
@@ -1538,11 +1553,11 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1538
1553
  except httpx.TimeoutException as err:
1539
1554
  log.debug("Encountered httpx.TimeoutException", exc_info=True)
1540
1555
 
1541
- if retries > 0:
1556
+ if remaining_retries > 0:
1542
1557
  return await self._retry_request(
1543
1558
  input_options,
1544
1559
  cast_to,
1545
- retries,
1560
+ retries_taken=retries_taken,
1546
1561
  stream=stream,
1547
1562
  stream_cls=stream_cls,
1548
1563
  response_headers=None,
@@ -1553,11 +1568,11 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1553
1568
  except Exception as err:
1554
1569
  log.debug("Encountered Exception", exc_info=True)
1555
1570
 
1556
- if retries > 0:
1571
+ if retries_taken > 0:
1557
1572
  return await self._retry_request(
1558
1573
  input_options,
1559
1574
  cast_to,
1560
- retries,
1575
+ retries_taken=retries_taken,
1561
1576
  stream=stream,
1562
1577
  stream_cls=stream_cls,
1563
1578
  response_headers=None,
@@ -1575,13 +1590,13 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1575
1590
  except httpx.HTTPStatusError as err: # thrown on 4xx and 5xx status code
1576
1591
  log.debug("Encountered httpx.HTTPStatusError", exc_info=True)
1577
1592
 
1578
- if retries > 0 and self._should_retry(err.response):
1593
+ if remaining_retries > 0 and self._should_retry(err.response):
1579
1594
  await err.response.aclose()
1580
1595
  return await self._retry_request(
1581
1596
  input_options,
1582
1597
  cast_to,
1583
- retries,
1584
- err.response.headers,
1598
+ retries_taken=retries_taken,
1599
+ response_headers=err.response.headers,
1585
1600
  stream=stream,
1586
1601
  stream_cls=stream_cls,
1587
1602
  )
@@ -1600,26 +1615,26 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1600
1615
  response=response,
1601
1616
  stream=stream,
1602
1617
  stream_cls=stream_cls,
1603
- retries_taken=options.get_max_retries(self.max_retries) - retries,
1618
+ retries_taken=retries_taken,
1604
1619
  )
1605
1620
 
1606
1621
  async def _retry_request(
1607
1622
  self,
1608
1623
  options: FinalRequestOptions,
1609
1624
  cast_to: Type[ResponseT],
1610
- remaining_retries: int,
1611
- response_headers: httpx.Headers | None,
1612
1625
  *,
1626
+ retries_taken: int,
1627
+ response_headers: httpx.Headers | None,
1613
1628
  stream: bool,
1614
1629
  stream_cls: type[_AsyncStreamT] | None,
1615
1630
  ) -> ResponseT | _AsyncStreamT:
1616
- remaining = remaining_retries - 1
1617
- if remaining == 1:
1631
+ remaining_retries = options.get_max_retries(self.max_retries) - retries_taken
1632
+ if remaining_retries == 1:
1618
1633
  log.debug("1 retry left")
1619
1634
  else:
1620
- log.debug("%i retries left", remaining)
1635
+ log.debug("%i retries left", remaining_retries)
1621
1636
 
1622
- timeout = self._calculate_retry_timeout(remaining, options, response_headers)
1637
+ timeout = self._calculate_retry_timeout(remaining_retries, options, response_headers)
1623
1638
  log.info("Retrying request to %s in %f seconds", options.url, timeout)
1624
1639
 
1625
1640
  await anyio.sleep(timeout)
@@ -1627,7 +1642,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1627
1642
  return await self._request(
1628
1643
  options=options,
1629
1644
  cast_to=cast_to,
1630
- remaining_retries=remaining,
1645
+ retries_taken=retries_taken + 1,
1631
1646
  stream=stream,
1632
1647
  stream_cls=stream_cls,
1633
1648
  )
@@ -136,12 +136,14 @@ def model_dump(
136
136
  exclude: IncEx = None,
137
137
  exclude_unset: bool = False,
138
138
  exclude_defaults: bool = False,
139
+ warnings: bool = True,
139
140
  ) -> dict[str, Any]:
140
141
  if PYDANTIC_V2:
141
142
  return model.model_dump(
142
143
  exclude=exclude,
143
144
  exclude_unset=exclude_unset,
144
145
  exclude_defaults=exclude_defaults,
146
+ warnings=warnings,
145
147
  )
146
148
  return cast(
147
149
  "dict[str, Any]",
@@ -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__ = "1.0.0" # x-release-please-version
4
+ __version__ = "2.0.0" # x-release-please-version
@@ -51,7 +51,9 @@ class ImageToVideoResource(SyncAPIResource):
51
51
  *,
52
52
  model: Literal["gen3a_turbo"],
53
53
  prompt_image: str,
54
+ duration: Literal[5, 10] | NotGiven = NOT_GIVEN,
54
55
  prompt_text: str | NotGiven = NOT_GIVEN,
56
+ ratio: Literal["16:9", "9:16"] | NotGiven = NOT_GIVEN,
55
57
  seed: int | NotGiven = NOT_GIVEN,
56
58
  watermark: bool | NotGiven = NOT_GIVEN,
57
59
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -70,8 +72,12 @@ class ImageToVideoResource(SyncAPIResource):
70
72
  prompt_image: A HTTPS URL pointing to an image. Images must be JPEG, PNG, or WebP and are
71
73
  limited to 16MB. Responses must include a valid `Content-Length` header.
72
74
 
75
+ duration: The number of seconds of duration for the output video.
76
+
73
77
  prompt_text
74
78
 
79
+ ratio: The aspect ratio of the output video.
80
+
75
81
  seed: If unspecified, a random number is chosen. Varying the seed integer is a way to
76
82
  get different results for the same other request parameters. Using the same seed
77
83
  integer for an identical request will produce similar results.
@@ -93,7 +99,9 @@ class ImageToVideoResource(SyncAPIResource):
93
99
  {
94
100
  "model": model,
95
101
  "prompt_image": prompt_image,
102
+ "duration": duration,
96
103
  "prompt_text": prompt_text,
104
+ "ratio": ratio,
97
105
  "seed": seed,
98
106
  "watermark": watermark,
99
107
  },
@@ -131,7 +139,9 @@ class AsyncImageToVideoResource(AsyncAPIResource):
131
139
  *,
132
140
  model: Literal["gen3a_turbo"],
133
141
  prompt_image: str,
142
+ duration: Literal[5, 10] | NotGiven = NOT_GIVEN,
134
143
  prompt_text: str | NotGiven = NOT_GIVEN,
144
+ ratio: Literal["16:9", "9:16"] | NotGiven = NOT_GIVEN,
135
145
  seed: int | NotGiven = NOT_GIVEN,
136
146
  watermark: bool | NotGiven = NOT_GIVEN,
137
147
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -150,8 +160,12 @@ class AsyncImageToVideoResource(AsyncAPIResource):
150
160
  prompt_image: A HTTPS URL pointing to an image. Images must be JPEG, PNG, or WebP and are
151
161
  limited to 16MB. Responses must include a valid `Content-Length` header.
152
162
 
163
+ duration: The number of seconds of duration for the output video.
164
+
153
165
  prompt_text
154
166
 
167
+ ratio: The aspect ratio of the output video.
168
+
155
169
  seed: If unspecified, a random number is chosen. Varying the seed integer is a way to
156
170
  get different results for the same other request parameters. Using the same seed
157
171
  integer for an identical request will produce similar results.
@@ -173,7 +187,9 @@ class AsyncImageToVideoResource(AsyncAPIResource):
173
187
  {
174
188
  "model": model,
175
189
  "prompt_image": prompt_image,
190
+ "duration": duration,
176
191
  "prompt_text": prompt_text,
192
+ "ratio": ratio,
177
193
  "seed": seed,
178
194
  "watermark": watermark,
179
195
  },
@@ -20,8 +20,14 @@ class ImageToVideoCreateParams(TypedDict, total=False):
20
20
  include a valid `Content-Length` header.
21
21
  """
22
22
 
23
+ duration: Literal[5, 10]
24
+ """The number of seconds of duration for the output video."""
25
+
23
26
  prompt_text: Annotated[str, PropertyInfo(alias="promptText")]
24
27
 
28
+ ratio: Literal["16:9", "9:16"]
29
+ """The aspect ratio of the output video."""
30
+
25
31
  seed: int
26
32
  """If unspecified, a random number is chosen.
27
33
 
@@ -30,7 +30,9 @@ class TestImageToVideo:
30
30
  image_to_video = client.image_to_video.create(
31
31
  model="gen3a_turbo",
32
32
  prompt_image="https://example.com",
33
+ duration=5,
33
34
  prompt_text="promptText",
35
+ ratio="16:9",
34
36
  seed=0,
35
37
  watermark=True,
36
38
  )
@@ -79,7 +81,9 @@ class TestAsyncImageToVideo:
79
81
  image_to_video = await async_client.image_to_video.create(
80
82
  model="gen3a_turbo",
81
83
  prompt_image="https://example.com",
84
+ duration=5,
82
85
  prompt_text="promptText",
86
+ ratio="16:9",
83
87
  seed=0,
84
88
  watermark=True,
85
89
  )
@@ -769,6 +769,57 @@ class TestRunwayML:
769
769
  )
770
770
 
771
771
  assert response.retries_taken == failures_before_success
772
+ assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
773
+
774
+ @pytest.mark.parametrize("failures_before_success", [0, 2, 4])
775
+ @mock.patch("runwayml._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
776
+ @pytest.mark.respx(base_url=base_url)
777
+ def test_omit_retry_count_header(
778
+ self, client: RunwayML, failures_before_success: int, respx_mock: MockRouter
779
+ ) -> None:
780
+ client = client.with_options(max_retries=4)
781
+
782
+ nb_retries = 0
783
+
784
+ def retry_handler(_request: httpx.Request) -> httpx.Response:
785
+ nonlocal nb_retries
786
+ if nb_retries < failures_before_success:
787
+ nb_retries += 1
788
+ return httpx.Response(500)
789
+ return httpx.Response(200)
790
+
791
+ respx_mock.post("/v1/image_to_video").mock(side_effect=retry_handler)
792
+
793
+ response = client.image_to_video.with_raw_response.create(
794
+ model="gen3a_turbo", prompt_image="https://example.com", extra_headers={"x-stainless-retry-count": Omit()}
795
+ )
796
+
797
+ assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
798
+
799
+ @pytest.mark.parametrize("failures_before_success", [0, 2, 4])
800
+ @mock.patch("runwayml._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
801
+ @pytest.mark.respx(base_url=base_url)
802
+ def test_overwrite_retry_count_header(
803
+ self, client: RunwayML, failures_before_success: int, respx_mock: MockRouter
804
+ ) -> None:
805
+ client = client.with_options(max_retries=4)
806
+
807
+ nb_retries = 0
808
+
809
+ def retry_handler(_request: httpx.Request) -> httpx.Response:
810
+ nonlocal nb_retries
811
+ if nb_retries < failures_before_success:
812
+ nb_retries += 1
813
+ return httpx.Response(500)
814
+ return httpx.Response(200)
815
+
816
+ respx_mock.post("/v1/image_to_video").mock(side_effect=retry_handler)
817
+
818
+ response = client.image_to_video.with_raw_response.create(
819
+ model="gen3a_turbo", prompt_image="https://example.com", extra_headers={"x-stainless-retry-count": "42"}
820
+ )
821
+
822
+ assert response.http_request.headers.get("x-stainless-retry-count") == "42"
772
823
 
773
824
 
774
825
  class TestAsyncRunwayML:
@@ -1507,3 +1558,56 @@ class TestAsyncRunwayML:
1507
1558
  )
1508
1559
 
1509
1560
  assert response.retries_taken == failures_before_success
1561
+ assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
1562
+
1563
+ @pytest.mark.parametrize("failures_before_success", [0, 2, 4])
1564
+ @mock.patch("runwayml._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
1565
+ @pytest.mark.respx(base_url=base_url)
1566
+ @pytest.mark.asyncio
1567
+ async def test_omit_retry_count_header(
1568
+ self, async_client: AsyncRunwayML, failures_before_success: int, respx_mock: MockRouter
1569
+ ) -> None:
1570
+ client = async_client.with_options(max_retries=4)
1571
+
1572
+ nb_retries = 0
1573
+
1574
+ def retry_handler(_request: httpx.Request) -> httpx.Response:
1575
+ nonlocal nb_retries
1576
+ if nb_retries < failures_before_success:
1577
+ nb_retries += 1
1578
+ return httpx.Response(500)
1579
+ return httpx.Response(200)
1580
+
1581
+ respx_mock.post("/v1/image_to_video").mock(side_effect=retry_handler)
1582
+
1583
+ response = await client.image_to_video.with_raw_response.create(
1584
+ model="gen3a_turbo", prompt_image="https://example.com", extra_headers={"x-stainless-retry-count": Omit()}
1585
+ )
1586
+
1587
+ assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
1588
+
1589
+ @pytest.mark.parametrize("failures_before_success", [0, 2, 4])
1590
+ @mock.patch("runwayml._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
1591
+ @pytest.mark.respx(base_url=base_url)
1592
+ @pytest.mark.asyncio
1593
+ async def test_overwrite_retry_count_header(
1594
+ self, async_client: AsyncRunwayML, failures_before_success: int, respx_mock: MockRouter
1595
+ ) -> None:
1596
+ client = async_client.with_options(max_retries=4)
1597
+
1598
+ nb_retries = 0
1599
+
1600
+ def retry_handler(_request: httpx.Request) -> httpx.Response:
1601
+ nonlocal nb_retries
1602
+ if nb_retries < failures_before_success:
1603
+ nb_retries += 1
1604
+ return httpx.Response(500)
1605
+ return httpx.Response(200)
1606
+
1607
+ respx_mock.post("/v1/image_to_video").mock(side_effect=retry_handler)
1608
+
1609
+ response = await client.image_to_video.with_raw_response.create(
1610
+ model="gen3a_turbo", prompt_image="https://example.com", extra_headers={"x-stainless-retry-count": "42"}
1611
+ )
1612
+
1613
+ assert response.http_request.headers.get("x-stainless-retry-count") == "42"
@@ -1,3 +0,0 @@
1
- {
2
- ".": "1.0.0"
3
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes