Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a35a4b5
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.357.3
speakeasybot Aug 8, 2024
ccd3e28
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.358.0
speakeasybot Aug 9, 2024
ce9501d
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.368.0
speakeasybot Aug 15, 2024
2c909fa
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.376.0
speakeasybot Aug 20, 2024
04004e0
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.383.2
speakeasybot Aug 30, 2024
26b2309
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.392.1
speakeasybot Sep 7, 2024
59cf283
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.394.0
speakeasybot Sep 10, 2024
48a6881
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.396.6
speakeasybot Sep 13, 2024
480f65e
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.401.2
speakeasybot Sep 21, 2024
d9357bb
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.405.6
speakeasybot Oct 1, 2024
39ecc30
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.406.0
speakeasybot Oct 3, 2024
ca3a2b7
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.411.1
speakeasybot Oct 8, 2024
3574021
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.421.1
speakeasybot Oct 24, 2024
55dabe9
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.423.5
speakeasybot Oct 31, 2024
2e92b8c
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.426.0
speakeasybot Nov 5, 2024
5581b9d
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.436.0
speakeasybot Nov 9, 2024
a1df762
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.443.0
speakeasybot Nov 22, 2024
00a6fff
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.446.0
speakeasybot Nov 26, 2024
cb5b9b5
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.448.2
speakeasybot Nov 28, 2024
68beb80
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.451.5
speakeasybot Dec 5, 2024
865e3de
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.453.8
speakeasybot Dec 10, 2024
8e0343f
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.455.3
speakeasybot Dec 14, 2024
e014dd3
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.455.7
speakeasybot Dec 17, 2024
3bee802
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.459.2
speakeasybot Dec 21, 2024
dea7514
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.460.2
speakeasybot Dec 24, 2024
f564f5f
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.462.2
speakeasybot Jan 4, 2025
e5f919c
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.465.1
speakeasybot Jan 9, 2025
a39f29c
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.467.0
speakeasybot Jan 10, 2025
8bb0b1d
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.468.2
speakeasybot Jan 12, 2025
614c726
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.468.6
speakeasybot Jan 15, 2025
afccb40
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.468.8
speakeasybot Jan 16, 2025
0aecb55
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.469.2
speakeasybot Jan 20, 2025
4b0d5de
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.469.11
speakeasybot Jan 21, 2025
a609848
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.474.0
speakeasybot Jan 24, 2025
ad548d0
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.476.0
speakeasybot Jan 25, 2025
dab720d
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.477.2
speakeasybot Jan 30, 2025
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
Prev Previous commit
Next Next commit
ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.476.0
  • Loading branch information
speakeasybot committed Jan 25, 2025
commit ad548d022ed78e1493f6a46ce89d87c455b4dd4c
10 changes: 5 additions & 5 deletions submission/.speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ id: 33caae79-0482-46e7-9dea-4e7a337d182e
management:
docChecksum: d4af78e6c6d718d7121f5ce9edb789ef
docVersion: 1.0.0
speakeasyVersion: 1.474.0
generationVersion: 2.495.0
releaseVersion: 1.13.6
configChecksum: cde6d9c66fcdd6923fef72fbf965c859
speakeasyVersion: 1.476.0
generationVersion: 2.496.0
releaseVersion: 1.13.7
configChecksum: b44435745cd889b77b88dc377739bc4e
repoURL: https://github.com/epilot-dev/sdk-python.git
repoSubDirectory: submission
installationURL: https://github.com/epilot-dev/sdk-python.git#subdirectory=submission
features:
python:
additionalDependencies: 1.0.0
additionalProperties: 1.0.1
core: 5.10.4
core: 5.10.5
defaultEnabledRetries: 0.2.0
deprecations: 3.0.2
enumUnions: 0.1.0
Expand Down
22 changes: 22 additions & 0 deletions submission/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,27 @@ with Epilot(
```
<!-- End Authentication [security] -->

<!-- Start Resource Management [resource-management] -->
## Resource Management

The `Epilot` 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.

[context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers

```python
from epilot_submission import Epilot
def main():
with Epilot() as epilot:
# Rest of application here...


# Or when using async:
async def amain():
async with Epilot() as epilot:
# Rest of application here...
```
<!-- End Resource Management [resource-management] -->

<!-- Start Debugging [debug] -->
## Debugging

Expand Down Expand Up @@ -555,6 +576,7 @@ Submission API: Use this API to handle submissions entities from external source
* [Server Selection](#server-selection)
* [Custom HTTP Client](#custom-http-client)
* [Authentication](#authentication)
* [Resource Management](#resource-management)
* [Debugging](#debugging)
* [IDE Support](#ide-support)

Expand Down
10 changes: 9 additions & 1 deletion submission/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,12 @@ Based on:
- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/submission-api.yaml
- Speakeasy CLI 1.474.0 (2.495.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [python v1.13.6] submission
- [python v1.13.6] submission

## 2025-01-25 00:25:21
### Changes
Based on:
- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/submission-api.yaml
- Speakeasy CLI 1.476.0 (2.496.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [python v1.13.7] submission
2 changes: 1 addition & 1 deletion submission/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ generation:
sdkFlattening: true
telemetryEnabled: false
python:
version: 1.13.6
version: 1.13.7
additionalDependencies:
dev: {}
main: {}
Expand Down
2 changes: 1 addition & 1 deletion submission/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "epilot-submission"
version = "1.13.6"
version = "1.13.7"
description = "Python Client SDK for Epilot"
authors = [{ name = "Speakeasy" },]
readme = "README-PYPI.md"
Expand Down
6 changes: 3 additions & 3 deletions submission/src/epilot_submission/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import importlib.metadata

__title__: str = "epilot-submission"
__version__: str = "1.13.6"
__version__: str = "1.13.7"
__openapi_doc_version__: str = "1.0.0"
__gen_version__: str = "2.495.0"
__user_agent__: str = "speakeasy-sdk/python 1.13.6 2.495.0 1.0.0 epilot-submission"
__gen_version__: str = "2.496.0"
__user_agent__: str = "speakeasy-sdk/python 1.13.7 2.496.0 1.0.0 epilot-submission"

try:
if __package__ is not None:
Expand Down
50 changes: 50 additions & 0 deletions submission/src/epilot_submission/httpclient.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

# pyright: reportReturnType = false
import asyncio
from concurrent.futures import ThreadPoolExecutor
from typing_extensions import Protocol, runtime_checkable
import httpx
from typing import Any, Optional, Union
Expand Down Expand Up @@ -82,3 +84,51 @@ def build_request(

async def aclose(self) -> None:
pass


class ClientOwner(Protocol):
client: Union[HttpClient, None]
async_client: Union[AsyncHttpClient, None]


def close_clients(
owner: ClientOwner,
sync_client: Union[HttpClient, None],
async_client: Union[AsyncHttpClient, None],
) -> None:
"""
A finalizer function that is meant to be used with weakref.finalize to close
httpx clients used by an SDK so that underlying resources can be garbage
collected.
"""

# Unset the client/async_client properties so there are no more references
# to them from the owning SDK instance and they can be reaped.
owner.client = None
owner.async_client = None

if sync_client is not None:
try:
sync_client.close()
except Exception:
pass

if async_client is not None:
is_async = False
try:
asyncio.get_running_loop()
is_async = True
except RuntimeError:
pass

try:
# If this function is called in an async loop then start another
# loop in a separate thread to close the async http client.
if is_async:
with ThreadPoolExecutor(max_workers=1) as executor:
future = executor.submit(asyncio.run, async_client.aclose())
future.result()
else:
asyncio.run(async_client.aclose())
except Exception:
pass
13 changes: 11 additions & 2 deletions submission/src/epilot_submission/sdk.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from .basesdk import BaseSDK
from .httpclient import AsyncHttpClient, HttpClient
from .httpclient import AsyncHttpClient, ClientOwner, HttpClient, close_clients
from .sdkconfiguration import SDKConfiguration
from .utils.logger import Logger, get_default_logger
from .utils.retries import RetryConfig
Expand All @@ -10,7 +10,8 @@
from epilot_submission.submissions import Submissions
from epilot_submission.types import OptionalNullable, UNSET
import httpx
from typing import Any, Callable, Dict, Optional, Union
from typing import Any, Callable, Dict, Optional, Union, cast
import weakref


class Epilot(BaseSDK):
Expand Down Expand Up @@ -96,6 +97,14 @@ def __init__(
# pylint: disable=protected-access
self.sdk_configuration.__dict__["_hooks"] = hooks

weakref.finalize(
self,
close_clients,
cast(ClientOwner, self.sdk_configuration),
self.sdk_configuration.client,
self.sdk_configuration.async_client,
)

self._init_sdks()

def _init_sdks(self):
Expand Down