syncsdk 0.1.0__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.
Files changed (52) hide show
  1. sync/__init__.py +63 -0
  2. sync/client.py +144 -0
  3. sync/common/__init__.py +46 -0
  4. sync/common/errors/__init__.py +8 -0
  5. sync/common/errors/bad_request_error.py +9 -0
  6. sync/common/errors/internal_server_error.py +9 -0
  7. sync/common/errors/not_found_error.py +9 -0
  8. sync/common/errors/unauthorized_error.py +9 -0
  9. sync/common/types/__init__.py +39 -0
  10. sync/common/types/audio.py +27 -0
  11. sync/common/types/create_generation_dto.py +44 -0
  12. sync/common/types/estimated_generation_cost.py +33 -0
  13. sync/common/types/generation.py +77 -0
  14. sync/common/types/generation_error.py +35 -0
  15. sync/common/types/generation_error_message.py +5 -0
  16. sync/common/types/generation_id.py +3 -0
  17. sync/common/types/generation_options.py +28 -0
  18. sync/common/types/generation_status.py +7 -0
  19. sync/common/types/input.py +8 -0
  20. sync/common/types/model.py +7 -0
  21. sync/common/types/segment_frames.py +5 -0
  22. sync/common/types/segment_secs.py +5 -0
  23. sync/common/types/sync_mode.py +5 -0
  24. sync/common/types/tts.py +28 -0
  25. sync/common/types/tts_provider_config.py +34 -0
  26. sync/common/types/video.py +35 -0
  27. sync/core/__init__.py +50 -0
  28. sync/core/api_error.py +15 -0
  29. sync/core/client_wrapper.py +55 -0
  30. sync/core/datetime_utils.py +28 -0
  31. sync/core/file.py +67 -0
  32. sync/core/http_client.py +497 -0
  33. sync/core/http_response.py +47 -0
  34. sync/core/jsonable_encoder.py +100 -0
  35. sync/core/pydantic_utilities.py +294 -0
  36. sync/core/query_encoder.py +58 -0
  37. sync/core/remove_none_from_dict.py +11 -0
  38. sync/core/request_options.py +35 -0
  39. sync/core/serialization.py +276 -0
  40. sync/environment.py +7 -0
  41. sync/generate/__init__.py +2 -0
  42. sync/generate/client.py +446 -0
  43. sync/generate/raw_client.py +648 -0
  44. sync/py.typed +0 -0
  45. sync/version.py +3 -0
  46. sync/webhooks/__init__.py +5 -0
  47. sync/webhooks/types/__init__.py +6 -0
  48. sync/webhooks/types/generation_notification.py +73 -0
  49. sync/webhooks/types/webhook_status.py +5 -0
  50. syncsdk-0.1.0.dist-info/METADATA +190 -0
  51. syncsdk-0.1.0.dist-info/RECORD +52 -0
  52. syncsdk-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,73 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ...core.pydantic_utilities import UniversalBaseModel
4
+ from .webhook_status import WebhookStatus
5
+ import pydantic
6
+ import typing_extensions
7
+ import datetime as dt
8
+ from ...core.serialization import FieldMetadata
9
+ from ...common.types.generation_id import GenerationId
10
+ import typing
11
+ from ...common.types.input import Input
12
+ from ...common.types.model import Model
13
+ from ...common.types.generation_options import GenerationOptions
14
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2
15
+
16
+
17
+ class GenerationNotification(UniversalBaseModel):
18
+ status: WebhookStatus = pydantic.Field()
19
+ """
20
+ The status of the generation
21
+ """
22
+
23
+ created_at: typing_extensions.Annotated[dt.datetime, FieldMetadata(alias="createdAt")] = pydantic.Field()
24
+ """
25
+ The date and time the generation was created
26
+ """
27
+
28
+ id: GenerationId
29
+ input: typing.List[Input] = pydantic.Field()
30
+ """
31
+ The input items for the generation
32
+ """
33
+
34
+ model: Model
35
+ error: typing.Optional[str] = pydantic.Field(default=None)
36
+ """
37
+ error message if the generation failed
38
+ """
39
+
40
+ options: typing.Optional[GenerationOptions] = pydantic.Field(default=None)
41
+ """
42
+ options used for the generation
43
+ """
44
+
45
+ output_duration: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="outputDuration")] = (
46
+ pydantic.Field(default=None)
47
+ )
48
+ """
49
+ generated output media duration in seconds
50
+ """
51
+
52
+ output_url: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="outputUrl")] = pydantic.Field(
53
+ default=None
54
+ )
55
+ """
56
+ url of the generated output media
57
+ """
58
+
59
+ webhook_url: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="webhookUrl")] = pydantic.Field(
60
+ default=None
61
+ )
62
+ """
63
+ url of the webhook server
64
+ """
65
+
66
+ if IS_PYDANTIC_V2:
67
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
68
+ else:
69
+
70
+ class Config:
71
+ frozen = True
72
+ smart_union = True
73
+ extra = pydantic.Extra.allow
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ WebhookStatus = typing.Union[typing.Literal["COMPLETED", "FAILED"], typing.Any]
@@ -0,0 +1,190 @@
1
+ Metadata-Version: 2.1
2
+ Name: syncsdk
3
+ Version: 0.1.0
4
+ Summary:
5
+ Requires-Python: >=3.8,<4.0
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: Operating System :: MacOS
8
+ Classifier: Operating System :: Microsoft :: Windows
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Operating System :: POSIX
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Typing :: Typed
21
+ Requires-Dist: httpx (>=0.21.2)
22
+ Requires-Dist: pydantic (>=1.9.2)
23
+ Requires-Dist: pydantic-core (>=2.18.2,<3.0.0)
24
+ Requires-Dist: typing_extensions (>=4.0.0)
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Sync Python Library
28
+
29
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fsynchronicity-labs%2Fsync-python-sdk)
30
+ [![pypi](https://img.shields.io/pypi/v/syncsdk)](https://pypi.python.org/pypi/syncsdk)
31
+
32
+ The Sync Python library provides convenient access to the Sync API from Python.
33
+
34
+ ## Installation
35
+
36
+ ```sh
37
+ pip install syncsdk
38
+ ```
39
+
40
+ ## Reference
41
+
42
+ A full reference for this library is available [here](./reference.md).
43
+
44
+ ## Usage
45
+
46
+ Instantiate and use the client with the following:
47
+
48
+ ```python
49
+ from sync import Sync
50
+ from sync.common import Audio, GenerationOptions, Video
51
+
52
+ client = Sync(
53
+ api_key="YOUR_API_KEY",
54
+ )
55
+ client.generate.create_generation(
56
+ input=[
57
+ Video(
58
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortvid-03a10044-7741-4cfc-816a-5bccd392d1ee.mp4",
59
+ ),
60
+ Audio(
61
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortaud-27623a4f-edab-4c6a-8383-871b18961a4a.wav",
62
+ ),
63
+ ],
64
+ model="lipsync-2",
65
+ options=GenerationOptions(
66
+ sync_mode="loop",
67
+ ),
68
+ )
69
+ ```
70
+
71
+ ## Async Client
72
+
73
+ The SDK also exports an `async` client so that you can make non-blocking calls to our API.
74
+
75
+ ```python
76
+ import asyncio
77
+
78
+ from sync import AsyncSync
79
+ from sync.common import Audio, GenerationOptions, Video
80
+
81
+ client = AsyncSync(
82
+ api_key="YOUR_API_KEY",
83
+ )
84
+
85
+
86
+ async def main() -> None:
87
+ await client.generate.create_generation(
88
+ input=[
89
+ Video(
90
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortvid-03a10044-7741-4cfc-816a-5bccd392d1ee.mp4",
91
+ ),
92
+ Audio(
93
+ url="https://synchlabs-public.s3.us-west-2.amazonaws.com/david_demo_shortaud-27623a4f-edab-4c6a-8383-871b18961a4a.wav",
94
+ ),
95
+ ],
96
+ model="lipsync-2",
97
+ options=GenerationOptions(
98
+ sync_mode="loop",
99
+ ),
100
+ )
101
+
102
+
103
+ asyncio.run(main())
104
+ ```
105
+
106
+ ## Exception Handling
107
+
108
+ When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
109
+ will be thrown.
110
+
111
+ ```python
112
+ from sync.core.api_error import ApiError
113
+
114
+ try:
115
+ client.generate.create_generation(...)
116
+ except ApiError as e:
117
+ print(e.status_code)
118
+ print(e.body)
119
+ ```
120
+
121
+ ## Advanced
122
+
123
+ ### Retries
124
+
125
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
126
+ as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
127
+ retry limit (default: 2).
128
+
129
+ A request is deemed retryable when any of the following HTTP status codes is returned:
130
+
131
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
132
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
133
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
134
+
135
+ Use the `max_retries` request option to configure this behavior.
136
+
137
+ ```python
138
+ client.generate.create_generation(..., request_options={
139
+ "max_retries": 1
140
+ })
141
+ ```
142
+
143
+ ### Timeouts
144
+
145
+ The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
146
+
147
+ ```python
148
+
149
+ from sync import Sync
150
+
151
+ client = Sync(
152
+ ...,
153
+ timeout=20.0,
154
+ )
155
+
156
+
157
+ # Override timeout for a specific method
158
+ client.generate.create_generation(..., request_options={
159
+ "timeout_in_seconds": 1
160
+ })
161
+ ```
162
+
163
+ ### Custom Client
164
+
165
+ You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
166
+ and transports.
167
+
168
+ ```python
169
+ import httpx
170
+ from sync import Sync
171
+
172
+ client = Sync(
173
+ ...,
174
+ httpx_client=httpx.Client(
175
+ proxies="http://my.test.proxy.example.com",
176
+ transport=httpx.HTTPTransport(local_address="0.0.0.0"),
177
+ ),
178
+ )
179
+ ```
180
+
181
+ ## Contributing
182
+
183
+ While we value open-source contributions to this SDK, this library is generated programmatically.
184
+ Additions made directly to this library would have to be moved over to our generation code,
185
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
186
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
187
+ an issue first to discuss with us!
188
+
189
+ On the other hand, contributions to the README are always very welcome!
190
+
@@ -0,0 +1,52 @@
1
+ sync/__init__.py,sha256=bCeM3EltauM6hYbtikPNraL8G-BTGQiFg6edkaBQUdI,1317
2
+ sync/client.py,sha256=JIPbAiic4uiB5Kk8inUl8E3ggCvXo9jC2CsNHnPDX04,5335
3
+ sync/common/__init__.py,sha256=aW85Tl7--x61xA2fATgA_oW5Mmf9xh4MbctCj8O2aaA,940
4
+ sync/common/errors/__init__.py,sha256=eS-2RID0VAXmu9g8dB9B0CHTeq_bxovRWS6ICqazkz0,352
5
+ sync/common/errors/bad_request_error.py,sha256=IKpd3W3qabLmuh0wf97Cz5Ght2rV1il6aPR4_kGMnX8,292
6
+ sync/common/errors/internal_server_error.py,sha256=5RUX4m2n3YnT0XAxOknDznp35jQWroeYHoH6tPmZL2g,296
7
+ sync/common/errors/not_found_error.py,sha256=y0m9Bh3o-gCLWSS5UPZYNxvaVg0xvxQFaOn04oUIpaY,290
8
+ sync/common/errors/unauthorized_error.py,sha256=r4frsrusFBtbcsRf5OAJqua4knJ3FmicW1cfsaUEyXE,294
9
+ sync/common/types/__init__.py,sha256=Qj45LbdH_6Zo_hoCHZEX_gMbgWhfMvlkNZ-_zr8PArY,1104
10
+ sync/common/types/audio.py,sha256=x06-08R3i0MCXrpzcTCiuOC5XhAq-Md3eDQWE23EfWM,726
11
+ sync/common/types/create_generation_dto.py,sha256=1U-FtRFIlGH896GwNiri54jQwAs7OEZK4sbuHGsmXuk,1565
12
+ sync/common/types/estimated_generation_cost.py,sha256=8KrWzhKDPjmP5puPfHsVusYIM1U0NVKw8uQzX1hSlZ8,1049
13
+ sync/common/types/generation.py,sha256=tDmBha1owv8rjlnGsIqElhGI9TNWjgISQdkfDj_EvVk,2203
14
+ sync/common/types/generation_error.py,sha256=AtQcuyVFfxd038tEGW331a_LJ1EWPTcm_zdNlYXOVEw,1035
15
+ sync/common/types/generation_error_message.py,sha256=do_Z6U04P3AzeeTTjw2zpHdgYt8WyPPduY2rOS5KScQ,141
16
+ sync/common/types/generation_id.py,sha256=YEhd4qSmFip5e7Hmm8OFEGyviAmxDjAlzdZRCH_bJo0,84
17
+ sync/common/types/generation_options.py,sha256=y2JX1D0PdBnX0PG1317IZ3jMQu1tQfSHPtvN8_iqwgA,1064
18
+ sync/common/types/generation_status.py,sha256=fKwOcKDca9qgffpqUx6PP3GrDT_ct9kW-G8iGrRtUd4,218
19
+ sync/common/types/input.py,sha256=x-DFWbB-TS3HVylqrcWuB9g0LU1owdlaHy-SaxBHd3Q,191
20
+ sync/common/types/model.py,sha256=DiMzMa7Ou7hjbmwiep7Hm9RkEF5HuDlvjHwjvlj5DZY,221
21
+ sync/common/types/segment_frames.py,sha256=VhZOX0puafw599JyGLzTgTwC4netR9jYkTjGJLx8btM,113
22
+ sync/common/types/segment_secs.py,sha256=mse4UDSgQxZROm3-BmgP36a-xQeZ6KeCBA7nVh5B0zk,113
23
+ sync/common/types/sync_mode.py,sha256=Hyp2KzortpaVnuMUSWgPQKrZn35HZPcu3XyK0rqaag0,181
24
+ sync/common/types/tts.py,sha256=svbSYajBkKl3DlUGT9E5nEY0rQtMulR37yDVrP50ygI,775
25
+ sync/common/types/tts_provider_config.py,sha256=q4aa0FyQu-NZoGRrPFPL_O-mbvv3tDH_kNmOD5w1P4Q,945
26
+ sync/common/types/video.py,sha256=J5D8wN30Tw0f25swf9RS4raYdCBQwJ5Es6ArpEEgPAQ,1588
27
+ sync/core/__init__.py,sha256=JZDozMOUlhvOLnOO6kGBxye5Ctfg_KDOjeUTSUoMmV8,1542
28
+ sync/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
29
+ sync/core/client_wrapper.py,sha256=uElyHl5vilvws2WIamp5MmwyGBhddfxIsHKtqbcsnVs,1845
30
+ sync/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
31
+ sync/core/file.py,sha256=d4NNbX8XvXP32z8KpK2Xovv33nFfruIrpz0QWxlgpZk,2663
32
+ sync/core/http_client.py,sha256=cKs2w0ybDBk1wHQf-fTALm_MmvaMe3cZKcYJxqmCxkE,19539
33
+ sync/core/http_response.py,sha256=Argerx6pFZdCpe637AT3EejZw5zlMGgsshZq6rb7krQ,1005
34
+ sync/core/jsonable_encoder.py,sha256=hGgcEEeX11sqxxsll7h15pO3pTNVxk_n79Kcn0laoWA,3655
35
+ sync/core/pydantic_utilities.py,sha256=Q2ZdeXKMwntaR9k2PJoMEhtHPlSgnG95c1v3iIrCFyA,11971
36
+ sync/core/query_encoder.py,sha256=ekulqNd0j8TgD7ox-Qbz7liqX8-KP9blvT9DsRCenYM,2144
37
+ sync/core/remove_none_from_dict.py,sha256=EU9SGgYidWq7SexuJbNs4-PZ-5Bl3Vppd864mS6vQZw,342
38
+ sync/core/request_options.py,sha256=h0QUNCFVdCW_7GclVySCAY2w4NhtXVBUCmHgmzaxpcg,1681
39
+ sync/core/serialization.py,sha256=ECL3bvv_0i7U4uvPidZCNel--MUbA0iq0aGcNKi3kws,9818
40
+ sync/environment.py,sha256=iySkk6t0eJAFKuhbTyZ17xie8ttWtKnKp2vW16nrCIU,149
41
+ sync/generate/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
42
+ sync/generate/client.py,sha256=TQpTYLw6fhwu0ZZ-gUtqPf13SrOHT94IDIZfPUnMnU4,14503
43
+ sync/generate/raw_client.py,sha256=fCGxQ5ODejs1aaqgKGW04L2j_xArv7JPEIO7-HnlJLs,25349
44
+ sync/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
+ sync/version.py,sha256=5ypVFAM2korpl0hkrz99dLMCDDDWcvTuVczCQ_kpRdU,74
46
+ sync/webhooks/__init__.py,sha256=agltaFEe8eygkhO4jOjE4C8SBj7OVmR1DpmQrmxRuoQ,177
47
+ sync/webhooks/types/__init__.py,sha256=EeBWDIoP1YoqpJq7Au2PSnPrtyhZR0gD9lyYdDi8dGQ,222
48
+ sync/webhooks/types/generation_notification.py,sha256=nyQhJcxVLXPN6eyoZC93iAXE2XRVTVspgjloPGLWBNA,2175
49
+ sync/webhooks/types/webhook_status.py,sha256=QL183incvzGMqyXGybw1rK9lYq-k00fCu32uytuzCjQ,160
50
+ syncsdk-0.1.0.dist-info/METADATA,sha256=qJbi5xLXoEhtV69SUZ-Ytwj94kJBubOIV_x6ZJGXTwk,5416
51
+ syncsdk-0.1.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
52
+ syncsdk-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 1.6.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any