Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.71.0"
".": "1.72.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 29
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/pi-labs%2Fwithpi-d420b4f74855c8f5281a77dcd82b7673de95f65168056f70954c9b78b5577144.yml
openapi_spec_hash: 752afc0137cb5eedcb872c8e42ffa909
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/pi-labs%2Fwithpi-423edf2ae1b86ccd676285b105605ea08afb617355f0914ade339af567245698.yml
openapi_spec_hash: d3d184fd4d37b39c24a6b092655849fb
config_hash: fd3e1149c629c2972c54a66a88fd4fab
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 1.72.0 (2025-09-10)

Full Changelog: [v1.71.0...v1.72.0](https://github.com/withpi/sdk-python/compare/v1.71.0...v1.72.0)

### Features

* **api:** api update ([639ca85](https://github.com/withpi/sdk-python/commit/639ca85add522e94fb6f339a143baa8ec8b6037b))


### Chores

* **tests:** simplify `get_platform` test ([1a2b7cc](https://github.com/withpi/sdk-python/commit/1a2b7ccfa518f7da3df796943a3d395fe2f4ea63))

## 1.71.0 (2025-09-05)

Full Changelog: [v1.70.0...v1.71.0](https://github.com/withpi/sdk-python/compare/v1.70.0...v1.71.0)
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "withpi"
version = "1.71.0"
version = "1.72.0"
description = "The official Python library for the Pi Client API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -56,7 +56,6 @@ dev-dependencies = [
"dirty-equals>=0.6.0",
"importlib-metadata>=6.7.0",
"rich>=13.7.1",
"nest_asyncio==1.6.0",
"pytest-xdist>=3.6.1",
]

Expand Down
1 change: 0 additions & 1 deletion requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ multidict==6.4.4
mypy==1.14.1
mypy-extensions==1.0.0
# via mypy
nest-asyncio==1.6.0
nodeenv==1.8.0
# via pyright
nox==2023.4.22
Expand Down
2 changes: 1 addition & 1 deletion src/withpi/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "withpi"
__version__ = "1.71.0" # x-release-please-version
__version__ = "1.72.0" # x-release-please-version
8 changes: 8 additions & 0 deletions src/withpi/resources/scoring_system/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def start_job(
batch_size: int | NotGiven = NOT_GIVEN,
existing_questions: Iterable[Question] | NotGiven = NOT_GIVEN,
num_questions: int | NotGiven = NOT_GIVEN,
retain_existing_questions: bool | NotGiven = NOT_GIVEN,
try_auto_generating_python_code: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -187,6 +188,8 @@ def start_job(
num_questions: The number of questions that the generated scoring system should contain. If <=
0, then the number is auto selected.

retain_existing_questions: If true, only generate new questions that improve the accuracy.

try_auto_generating_python_code: If true, try to generate python code for the generated questions.

extra_headers: Send extra headers
Expand All @@ -207,6 +210,7 @@ def start_job(
"batch_size": batch_size,
"existing_questions": existing_questions,
"num_questions": num_questions,
"retain_existing_questions": retain_existing_questions,
"try_auto_generating_python_code": try_auto_generating_python_code,
},
generate_start_job_params.GenerateStartJobParams,
Expand Down Expand Up @@ -384,6 +388,7 @@ async def start_job(
batch_size: int | NotGiven = NOT_GIVEN,
existing_questions: Iterable[Question] | NotGiven = NOT_GIVEN,
num_questions: int | NotGiven = NOT_GIVEN,
retain_existing_questions: bool | NotGiven = NOT_GIVEN,
try_auto_generating_python_code: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand Down Expand Up @@ -412,6 +417,8 @@ async def start_job(
num_questions: The number of questions that the generated scoring system should contain. If <=
0, then the number is auto selected.

retain_existing_questions: If true, only generate new questions that improve the accuracy.

try_auto_generating_python_code: If true, try to generate python code for the generated questions.

extra_headers: Send extra headers
Expand All @@ -432,6 +439,7 @@ async def start_job(
"batch_size": batch_size,
"existing_questions": existing_questions,
"num_questions": num_questions,
"retain_existing_questions": retain_existing_questions,
"try_auto_generating_python_code": try_auto_generating_python_code,
},
generate_start_job_params.GenerateStartJobParams,
Expand Down
3 changes: 3 additions & 0 deletions src/withpi/types/scoring_system/generate_start_job_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class GenerateStartJobParams(TypedDict, total=False):
If <= 0, then the number is auto selected.
"""

retain_existing_questions: bool
"""If true, only generate new questions that improve the accuracy."""

try_auto_generating_python_code: bool
"""If true, try to generate python code for the generated questions."""

Expand Down
2 changes: 2 additions & 0 deletions tests/api_resources/scoring_system/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def test_method_start_job_with_all_params(self, client: PiClient) -> None:
}
],
num_questions=0,
retain_existing_questions=False,
try_auto_generating_python_code=False,
)
assert_matches_type(GenerateStartJobResponse, generate, path=["response"])
Expand Down Expand Up @@ -517,6 +518,7 @@ async def test_method_start_job_with_all_params(self, async_client: AsyncPiClien
}
],
num_questions=0,
retain_existing_questions=False,
try_auto_generating_python_code=False,
)
assert_matches_type(GenerateStartJobResponse, generate, path=["response"])
Expand Down
53 changes: 6 additions & 47 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
import os
import sys
import json
import time
import asyncio
import inspect
import subprocess
import tracemalloc
from typing import Any, Union, cast
from textwrap import dedent
from unittest import mock
from typing_extensions import Literal

Expand All @@ -23,14 +20,17 @@

from withpi import PiClient, AsyncPiClient, APIResponseValidationError
from withpi._types import Omit
from withpi._utils import asyncify
from withpi._models import BaseModel, FinalRequestOptions
from withpi._exceptions import PiClientError, APIStatusError, APITimeoutError, APIResponseValidationError
from withpi._base_client import (
DEFAULT_TIMEOUT,
HTTPX_DEFAULT_TIMEOUT,
BaseClient,
OtherPlatform,
DefaultHttpxClient,
DefaultAsyncHttpxClient,
get_platform,
make_request_options,
)

Expand Down Expand Up @@ -1673,50 +1673,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:

assert response.http_request.headers.get("x-stainless-retry-count") == "42"

def test_get_platform(self) -> None:
# A previous implementation of asyncify could leave threads unterminated when
# used with nest_asyncio.
#
# Since nest_asyncio.apply() is global and cannot be un-applied, this
# test is run in a separate process to avoid affecting other tests.
test_code = dedent("""
import asyncio
import nest_asyncio
import threading

from withpi._utils import asyncify
from withpi._base_client import get_platform

async def test_main() -> None:
result = await asyncify(get_platform)()
print(result)
for thread in threading.enumerate():
print(thread.name)

nest_asyncio.apply()
asyncio.run(test_main())
""")
with subprocess.Popen(
[sys.executable, "-c", test_code],
text=True,
) as process:
timeout = 10 # seconds

start_time = time.monotonic()
while True:
return_code = process.poll()
if return_code is not None:
if return_code != 0:
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")

# success
break

if time.monotonic() - start_time > timeout:
process.kill()
raise AssertionError("calling get_platform using asyncify resulted in a hung process")

time.sleep(0.1)
async def test_get_platform(self) -> None:
platform = await asyncify(get_platform)()
assert isinstance(platform, (str, OtherPlatform))

async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None:
# Test that the proxy environment variables are set correctly
Expand Down