mixpeek 0.18.6__py3-none-any.whl → 0.18.8__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.
mixpeek/_version.py CHANGED
@@ -3,10 +3,10 @@
3
3
  import importlib.metadata
4
4
 
5
5
  __title__: str = "mixpeek"
6
- __version__: str = "0.18.6"
6
+ __version__: str = "0.18.8"
7
7
  __openapi_doc_version__: str = "0.81"
8
- __gen_version__: str = "2.495.0"
9
- __user_agent__: str = "speakeasy-sdk/python 0.18.6 2.495.0 0.81 mixpeek"
8
+ __gen_version__: str = "2.495.1"
9
+ __user_agent__: str = "speakeasy-sdk/python 0.18.8 2.495.1 0.81 mixpeek"
10
10
 
11
11
  try:
12
12
  if __package__ is not None:
mixpeek/assets.py CHANGED
@@ -234,7 +234,7 @@ class Assets(BaseSDK):
234
234
  server_url: Optional[str] = None,
235
235
  timeout_ms: Optional[int] = None,
236
236
  http_headers: Optional[Mapping[str, str]] = None,
237
- ) -> Any:
237
+ ) -> models.GenericSuccessResponse:
238
238
  r"""Delete Asset
239
239
 
240
240
  **Requirements:**
@@ -299,7 +299,7 @@ class Assets(BaseSDK):
299
299
 
300
300
  data: Any = None
301
301
  if utils.match_response(http_res, "200", "application/json"):
302
- return utils.unmarshal_json(http_res.text, Any)
302
+ return utils.unmarshal_json(http_res.text, models.GenericSuccessResponse)
303
303
  if utils.match_response(
304
304
  http_res, ["400", "401", "403", "404"], "application/json"
305
305
  ):
@@ -340,7 +340,7 @@ class Assets(BaseSDK):
340
340
  server_url: Optional[str] = None,
341
341
  timeout_ms: Optional[int] = None,
342
342
  http_headers: Optional[Mapping[str, str]] = None,
343
- ) -> Any:
343
+ ) -> models.GenericSuccessResponse:
344
344
  r"""Delete Asset
345
345
 
346
346
  **Requirements:**
@@ -405,7 +405,7 @@ class Assets(BaseSDK):
405
405
 
406
406
  data: Any = None
407
407
  if utils.match_response(http_res, "200", "application/json"):
408
- return utils.unmarshal_json(http_res.text, Any)
408
+ return utils.unmarshal_json(http_res.text, models.GenericSuccessResponse)
409
409
  if utils.match_response(
410
410
  http_res, ["400", "401", "403", "404"], "application/json"
411
411
  ):
mixpeek/features.py CHANGED
@@ -230,7 +230,7 @@ class Features(BaseSDK):
230
230
  server_url: Optional[str] = None,
231
231
  timeout_ms: Optional[int] = None,
232
232
  http_headers: Optional[Mapping[str, str]] = None,
233
- ) -> Any:
233
+ ) -> models.GenericSuccessResponse:
234
234
  r"""Delete Feature
235
235
 
236
236
  **Requirements:**
@@ -295,7 +295,7 @@ class Features(BaseSDK):
295
295
 
296
296
  data: Any = None
297
297
  if utils.match_response(http_res, "200", "application/json"):
298
- return utils.unmarshal_json(http_res.text, Any)
298
+ return utils.unmarshal_json(http_res.text, models.GenericSuccessResponse)
299
299
  if utils.match_response(
300
300
  http_res, ["400", "401", "403", "404"], "application/json"
301
301
  ):
@@ -336,7 +336,7 @@ class Features(BaseSDK):
336
336
  server_url: Optional[str] = None,
337
337
  timeout_ms: Optional[int] = None,
338
338
  http_headers: Optional[Mapping[str, str]] = None,
339
- ) -> Any:
339
+ ) -> models.GenericSuccessResponse:
340
340
  r"""Delete Feature
341
341
 
342
342
  **Requirements:**
@@ -401,7 +401,7 @@ class Features(BaseSDK):
401
401
 
402
402
  data: Any = None
403
403
  if utils.match_response(http_res, "200", "application/json"):
404
- return utils.unmarshal_json(http_res.text, Any)
404
+ return utils.unmarshal_json(http_res.text, models.GenericSuccessResponse)
405
405
  if utils.match_response(
406
406
  http_res, ["400", "401", "403", "404"], "application/json"
407
407
  ):
mixpeek/httpclient.py CHANGED
@@ -1,6 +1,8 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  # pyright: reportReturnType = false
4
+ import asyncio
5
+ from concurrent.futures import ThreadPoolExecutor
4
6
  from typing_extensions import Protocol, runtime_checkable
5
7
  import httpx
6
8
  from typing import Any, Optional, Union
@@ -82,3 +84,51 @@ class AsyncHttpClient(Protocol):
82
84
 
83
85
  async def aclose(self) -> None:
84
86
  pass
87
+
88
+
89
+ class ClientOwner(Protocol):
90
+ client: Union[HttpClient, None]
91
+ async_client: Union[AsyncHttpClient, None]
92
+
93
+
94
+ def close_clients(
95
+ owner: ClientOwner,
96
+ sync_client: Union[HttpClient, None],
97
+ async_client: Union[AsyncHttpClient, None],
98
+ ) -> None:
99
+ """
100
+ A finalizer function that is meant to be used with weakref.finalize to close
101
+ httpx clients used by an SDK so that underlying resources can be garbage
102
+ collected.
103
+ """
104
+
105
+ # Unset the client/async_client properties so there are no more references
106
+ # to them from the owning SDK instance and they can be reaped.
107
+ owner.client = None
108
+ owner.async_client = None
109
+
110
+ if sync_client is not None:
111
+ try:
112
+ sync_client.close()
113
+ except Exception:
114
+ pass
115
+
116
+ if async_client is not None:
117
+ is_async = False
118
+ try:
119
+ asyncio.get_running_loop()
120
+ is_async = True
121
+ except RuntimeError:
122
+ pass
123
+
124
+ try:
125
+ # If this function is called in an async loop then start another
126
+ # loop in a separate thread to close the async http client.
127
+ if is_async:
128
+ with ThreadPoolExecutor(max_workers=1) as executor:
129
+ future = executor.submit(asyncio.run, async_client.aclose())
130
+ future.result()
131
+ else:
132
+ asyncio.run(async_client.aclose())
133
+ except Exception:
134
+ pass
mixpeek/sdk.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from .basesdk import BaseSDK
4
- from .httpclient import AsyncHttpClient, HttpClient
4
+ from .httpclient import AsyncHttpClient, ClientOwner, HttpClient, close_clients
5
5
  from .sdkconfiguration import SDKConfiguration
6
6
  from .utils.logger import Logger, get_default_logger
7
7
  from .utils.retries import RetryConfig
@@ -22,7 +22,8 @@ from mixpeek.taxonomies import Taxonomies
22
22
  from mixpeek.taxonomyentities import TaxonomyEntities
23
23
  from mixpeek.types import OptionalNullable, UNSET
24
24
  from mixpeek.users import Users
25
- from typing import Any, Callable, Dict, Optional, Union
25
+ from typing import Any, Callable, Dict, Optional, Union, cast
26
+ import weakref
26
27
 
27
28
 
28
29
  class Mixpeek(BaseSDK):
@@ -127,6 +128,14 @@ class Mixpeek(BaseSDK):
127
128
  # pylint: disable=protected-access
128
129
  self.sdk_configuration.__dict__["_hooks"] = hooks
129
130
 
131
+ weakref.finalize(
132
+ self,
133
+ close_clients,
134
+ cast(ClientOwner, self.sdk_configuration),
135
+ self.sdk_configuration.client,
136
+ self.sdk_configuration.async_client,
137
+ )
138
+
130
139
  self._init_sdks()
131
140
 
132
141
  def _init_sdks(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mixpeek
3
- Version: 0.18.6
3
+ Version: 0.18.8
4
4
  Summary: Python Client SDK Generated by Speakeasy.
5
5
  Author: Speakeasy
6
6
  Requires-Python: >=3.9
@@ -42,6 +42,7 @@ Mixpeek API: This is the Mixpeek API, providing access to various endpoints for
42
42
  * [Error Handling](https://github.com/mixpeek/python-sdk/blob/master/#error-handling)
43
43
  * [Server Selection](https://github.com/mixpeek/python-sdk/blob/master/#server-selection)
44
44
  * [Custom HTTP Client](https://github.com/mixpeek/python-sdk/blob/master/#custom-http-client)
45
+ * [Resource Management](https://github.com/mixpeek/python-sdk/blob/master/#resource-management)
45
46
  * [Debugging](https://github.com/mixpeek/python-sdk/blob/master/#debugging)
46
47
  * [Development](https://github.com/mixpeek/python-sdk/blob/master/#development)
47
48
  * [Maturity](https://github.com/mixpeek/python-sdk/blob/master/#maturity)
@@ -453,6 +454,32 @@ s = Mixpeek(async_client=CustomClient(httpx.AsyncClient()))
453
454
  ```
454
455
  <!-- End Custom HTTP Client [http-client] -->
455
456
 
457
+ <!-- Start Resource Management [resource-management] -->
458
+ ## Resource Management
459
+
460
+ The `Mixpeek` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
461
+
462
+ [context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
463
+
464
+ ```python
465
+ from mixpeek import Mixpeek
466
+ import os
467
+ def main():
468
+ with Mixpeek(
469
+ token=os.getenv("MIXPEEK_TOKEN", ""),
470
+ ) as mixpeek:
471
+ # Rest of application here...
472
+
473
+
474
+ # Or when using async:
475
+ async def amain():
476
+ async with Mixpeek(
477
+ token=os.getenv("MIXPEEK_TOKEN", ""),
478
+ ) as mixpeek:
479
+ # Rest of application here...
480
+ ```
481
+ <!-- End Resource Management [resource-management] -->
482
+
456
483
  <!-- Start Debugging [debug] -->
457
484
  ## Debugging
458
485
 
@@ -3,14 +3,14 @@ mixpeek/_hooks/__init__.py,sha256=p5J13DeYuISQyQWirjJAObHIf2VtIlOtFqnIpvjjVwk,11
3
3
  mixpeek/_hooks/registration.py,sha256=1QZB41w6If7I9dXiOSQx6dhSc6BPWrnI5Q5bMOr4iVA,624
4
4
  mixpeek/_hooks/sdkhooks.py,sha256=T0xbVPw8mvvFszHZlrZdtFrJBovAqE-JQfw4dS9Xi7Y,2495
5
5
  mixpeek/_hooks/types.py,sha256=Qh9pO5ndynMrWpMLPkJUsOmAJ1AJHntJAXb5Yxe_a4o,2568
6
- mixpeek/_version.py,sha256=TOn3-PgNetSFWC3MAOZzDvmmyDMHysjGS_27JNLnqA8,456
7
- mixpeek/assets.py,sha256=cggTlrFg6BAlddsB3TJS67XAO7oaaEZxuXE7rac6ASw,75414
6
+ mixpeek/_version.py,sha256=3Epg0xN761-l6qKDILNGshB2ntjRkHsGOzUz_ivm1qE,456
7
+ mixpeek/assets.py,sha256=-jYhngwslhsoc-Ni8MKxyk9pJl44uu2U0DRISErGt1Y,75518
8
8
  mixpeek/basesdk.py,sha256=j_PZqE6WgIfx1cPCK5gAVn-rgPy9iLhUN5ELtefoEU0,11976
9
9
  mixpeek/collections.py,sha256=mh0ypu89kY78Lnfal7OdBrHsCpJ3O54DVR3ejhD5oSo,49021
10
10
  mixpeek/featureextractors.py,sha256=uMZncapRYj7dM_qAJ5hbT86Uyb9x1N1IraNMupGp7UE,9598
11
- mixpeek/features.py,sha256=z_JoaD_k_HNcHLrRpdOxcbnNLUjVljZmpnsbiZLHy3I,58748
11
+ mixpeek/features.py,sha256=ZlbCIHemhMYrULKlEDr1vqCkRQ9sVf5qy1DTlr2SsNo,58852
12
12
  mixpeek/health.py,sha256=4i7KHGS2bYHCAE0nyHDw5g24MXcTZYVaTviQNKPW5o0,6742
13
- mixpeek/httpclient.py,sha256=WDbLpMzo7qmWki_ryOJcCAYNI1T4uyWKV08rRuCdNII,2688
13
+ mixpeek/httpclient.py,sha256=N-D-srtDBykpfyVKacTY4upDGvNLqdWlEYqhJvta99E,4194
14
14
  mixpeek/ingestassets.py,sha256=yW6eDg9JpSQzWM1Zl-GqDIpacKrUItXBL6LOOaDo8q8,40442
15
15
  mixpeek/models/__init__.py,sha256=tA15wFp9zSk7e76MF48-to5yygR17id6EGWQjXnQ6W4,31191
16
16
  mixpeek/models/actionusage.py,sha256=WAnnBVTeQ9j0dtIrubfyyJQwbBamxManfS8fc2OFNyo,324
@@ -170,7 +170,7 @@ mixpeek/models/videotranscriptionsettings.py,sha256=70EN-PX2QiQAQjDLYaV2coUCnVjR
170
170
  mixpeek/namespaces.py,sha256=ED42wsbEksGpW61sUvtnjJPl8O6ktVE7R7K5ZTHiZko,53848
171
171
  mixpeek/organizations.py,sha256=Q0Nu_eg7bXCZniB0a8Gj7Kt8kRkVLzs5h_-T5w4c1Ic,44795
172
172
  mixpeek/py.typed,sha256=zrp19r0G21lr2yRiMC0f8MFkQFGj9wMpSbboePMg8KM,59
173
- mixpeek/sdk.py,sha256=GfRtkLl__iaA04EY_E9_-ASxvY1Fp2ejYiKBZBARlnc,6071
173
+ mixpeek/sdk.py,sha256=qGyoPseO0ijF5NEWKaXaDRJWtQJ97EHhLYiGmHpsbkI,6349
174
174
  mixpeek/sdkconfiguration.py,sha256=WDFDVblhsi547ZxDPEPR243zKLM1shTDSt9w3nporHc,1703
175
175
  mixpeek/tasks.py,sha256=tQMg5XUINdXAjbTVbJP63zLfRs5eNl5Fk46onDo5yFo,27602
176
176
  mixpeek/taxonomies.py,sha256=M3q8g39M6VK3saT0sIgjsV5vs-4NO7iKdCJ894VxnLk,29553
@@ -193,6 +193,6 @@ mixpeek/utils/security.py,sha256=XoK-R2YMyZtVWQte7FoezfGJS-dea9jz4qQ7w5dwNWc,600
193
193
  mixpeek/utils/serializers.py,sha256=BSJT7kBOkNBFyP7KREyMoe14JGbgijD1M6AXFMbdmco,4924
194
194
  mixpeek/utils/url.py,sha256=BgGPgcTA6MRK4bF8fjP2dUopN3NzEzxWMXPBVg8NQUA,5254
195
195
  mixpeek/utils/values.py,sha256=_89YXPTI_BU6SXJBzFR4pIzTCBPQW9tsOTN1jeBBIDs,3428
196
- mixpeek-0.18.6.dist-info/METADATA,sha256=T2ABMGKmGYxesHmPO_-r9UB_dMW3FI3X1uzhn7h_KiE,20959
197
- mixpeek-0.18.6.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
198
- mixpeek-0.18.6.dist-info/RECORD,,
196
+ mixpeek-0.18.8.dist-info/METADATA,sha256=jb55DY38A0qdpB0F3lnOKVImpVJARgU6H5d2_AZPr2A,22186
197
+ mixpeek-0.18.8.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
198
+ mixpeek-0.18.8.dist-info/RECORD,,