Skip to content

Commit a73cf04

Browse files
Merge pull request #34 from prompt-foundry/release-please--branches--main--changes--next
release: 0.1.0-alpha.2
2 parents 28c2d54 + 9d29353 commit a73cf04

File tree

11 files changed

+62
-17
lines changed

11 files changed

+62
-17
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.1.0-alpha.1"
2+
".": "0.1.0-alpha.2"
33
}

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 21
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prompt-foundry%2Fprompt-foundry-sdk-bb0c2179ddf83834412606080e40f875436162cb81210f5af52c5f14aeb9c35b.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prompt-foundry%2Fprompt-foundry-sdk-5099b2b6ce467e4cae4520a778d3149d96ddf1331960860509028e7e2ac4b3f7.yml

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
## 0.1.0-alpha.2 (2024-06-24)
4+
5+
Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/prompt-foundry/python-sdk/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)
6+
7+
### Features
8+
9+
* **api:** OpenAPI spec update via Stainless API ([#35](https://github.com/prompt-foundry/python-sdk/issues/35)) ([0d0e897](https://github.com/prompt-foundry/python-sdk/commit/0d0e8979817239f772d8a9bdd347c9ea9f910481))
10+
* **api:** OpenAPI spec update via Stainless API ([#36](https://github.com/prompt-foundry/python-sdk/issues/36)) ([6f9b826](https://github.com/prompt-foundry/python-sdk/commit/6f9b82645bc7789794b2c8e7d29bf480a7fcfe4f))
11+
* **api:** OpenAPI spec update via Stainless API ([#37](https://github.com/prompt-foundry/python-sdk/issues/37)) ([9535a0c](https://github.com/prompt-foundry/python-sdk/commit/9535a0c92a8214618ade8ae08faf0f19950433d5))
12+
* **api:** OpenAPI spec update via Stainless API ([#38](https://github.com/prompt-foundry/python-sdk/issues/38)) ([4ccb8fc](https://github.com/prompt-foundry/python-sdk/commit/4ccb8fccc509b4ec8beaa1e8dfb551ea8e6b1e59))
13+
* **api:** OpenAPI spec update via Stainless API ([#39](https://github.com/prompt-foundry/python-sdk/issues/39)) ([139c802](https://github.com/prompt-foundry/python-sdk/commit/139c80281ff6aabbf60819d77a2e9e822de045aa))
14+
* **api:** OpenAPI spec update via Stainless API ([#40](https://github.com/prompt-foundry/python-sdk/issues/40)) ([84f798e](https://github.com/prompt-foundry/python-sdk/commit/84f798e668dd40b45349f6fe7c4dba203e4101f9))
15+
* **api:** OpenAPI spec update via Stainless API ([#41](https://github.com/prompt-foundry/python-sdk/issues/41)) ([73fbb5c](https://github.com/prompt-foundry/python-sdk/commit/73fbb5cd1f2a5c55b5e1365933ff2d2100fbb33c))
16+
* **api:** OpenAPI spec update via Stainless API ([#42](https://github.com/prompt-foundry/python-sdk/issues/42)) ([11961df](https://github.com/prompt-foundry/python-sdk/commit/11961df301280f35aa89e52e8790db1e1025b7a8))
17+
* **api:** OpenAPI spec update via Stainless API ([#43](https://github.com/prompt-foundry/python-sdk/issues/43)) ([5cb7b65](https://github.com/prompt-foundry/python-sdk/commit/5cb7b6550e86afa5abb4c811c751115769b27650))
18+
* **api:** OpenAPI spec update via Stainless API ([#44](https://github.com/prompt-foundry/python-sdk/issues/44)) ([7ed514e](https://github.com/prompt-foundry/python-sdk/commit/7ed514e866fe564ad1361e4ce60215a0b67ab5d0))
19+
* **api:** OpenAPI spec update via Stainless API ([#45](https://github.com/prompt-foundry/python-sdk/issues/45)) ([95eee74](https://github.com/prompt-foundry/python-sdk/commit/95eee747f7bb2124586f817459bdaada8e8f0081))
20+
321
## 0.1.0-alpha.1 (2024-06-18)
422

523
Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/prompt-foundry/python-sdk/compare/v0.0.1-alpha.0...v0.1.0-alpha.1)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "prompt_foundry_python_sdk"
3-
version = "0.1.0-alpha.1"
3+
version = "0.1.0-alpha.2"
44
description = "The official Python library for the prompt-foundry API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

src/prompt-foundry-python-sdk/lib/.keep

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/prompt-foundry-sdk/lib/.keep

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/prompt_foundry_python_sdk/_base_client.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
RequestOptions,
6161
ModelBuilderProtocol,
6262
)
63-
from ._utils import is_dict, is_list, is_given, lru_cache, is_mapping
63+
from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping
6464
from ._compat import model_copy, model_dump
6565
from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
6666
from ._response import (
@@ -358,6 +358,7 @@ def __init__(
358358
self._custom_query = custom_query or {}
359359
self._strict_response_validation = _strict_response_validation
360360
self._idempotency_header = None
361+
self._platform: Platform | None = None
361362

362363
if max_retries is None: # pyright: ignore[reportUnnecessaryComparison]
363364
raise TypeError(
@@ -622,7 +623,10 @@ def base_url(self, url: URL | str) -> None:
622623
self._base_url = self._enforce_trailing_slash(url if isinstance(url, URL) else URL(url))
623624

624625
def platform_headers(self) -> Dict[str, str]:
625-
return platform_headers(self._version)
626+
# the actual implementation is in a separate `lru_cache` decorated
627+
# function because adding `lru_cache` to methods will leak memory
628+
# https://github.com/python/cpython/issues/88476
629+
return platform_headers(self._version, platform=self._platform)
626630

627631
def _parse_retry_after_header(self, response_headers: Optional[httpx.Headers] = None) -> float | None:
628632
"""Returns a float of the number of seconds (not milliseconds) to wait after retrying, or None if unspecified.
@@ -1498,6 +1502,11 @@ async def _request(
14981502
stream_cls: type[_AsyncStreamT] | None,
14991503
remaining_retries: int | None,
15001504
) -> ResponseT | _AsyncStreamT:
1505+
if self._platform is None:
1506+
# `get_platform` can make blocking IO calls so we
1507+
# execute it earlier while we are in an async context
1508+
self._platform = await asyncify(get_platform)()
1509+
15011510
cast_to = self._maybe_override_cast_to(cast_to, options)
15021511
await self._prepare_options(options)
15031512

@@ -1921,11 +1930,11 @@ def get_platform() -> Platform:
19211930

19221931

19231932
@lru_cache(maxsize=None)
1924-
def platform_headers(version: str) -> Dict[str, str]:
1933+
def platform_headers(version: str, *, platform: Platform | None) -> Dict[str, str]:
19251934
return {
19261935
"X-Stainless-Lang": "python",
19271936
"X-Stainless-Package-Version": version,
1928-
"X-Stainless-OS": str(get_platform()),
1937+
"X-Stainless-OS": str(platform or get_platform()),
19291938
"X-Stainless-Arch": str(get_architecture()),
19301939
"X-Stainless-Runtime": get_python_runtime(),
19311940
"X-Stainless-Runtime-Version": get_python_version(),

src/prompt_foundry_python_sdk/_utils/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@
4949
maybe_transform as maybe_transform,
5050
async_maybe_transform as async_maybe_transform,
5151
)
52+
from ._reflection import function_has_argument as function_has_argument
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import inspect
2+
from typing import Any, Callable
3+
4+
5+
def function_has_argument(func: Callable[..., Any], arg_name: str) -> bool:
6+
"""Returns whether or not the given function has a specific parameter"""
7+
sig = inspect.signature(func)
8+
return arg_name in sig.parameters

src/prompt_foundry_python_sdk/_utils/_sync.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import anyio
88
import anyio.to_thread
99

10+
from ._reflection import function_has_argument
11+
1012
T_Retval = TypeVar("T_Retval")
1113
T_ParamSpec = ParamSpec("T_ParamSpec")
1214

@@ -59,6 +61,21 @@ def do_work(arg1, arg2, kwarg1="", kwarg2="") -> str:
5961

6062
async def wrapper(*args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs) -> T_Retval:
6163
partial_f = functools.partial(function, *args, **kwargs)
62-
return await anyio.to_thread.run_sync(partial_f, cancellable=cancellable, limiter=limiter)
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+
)
6380

6481
return wrapper

0 commit comments

Comments
 (0)