Skip to content

Commit 1cf74fe

Browse files
chore(internal): codegen related update
1 parent fc50cbe commit 1cf74fe

File tree

4 files changed

+391
-459
lines changed

4 files changed

+391
-459
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ dev-dependencies = [
5858
"dirty-equals>=0.6.0",
5959
"importlib-metadata>=6.7.0",
6060
"rich>=13.7.1",
61-
"nest_asyncio==1.6.0",
6261
"pytest-xdist>=3.6.1",
6362
]
6463
conflicts = [

requirements-dev.lock

Lines changed: 78 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,40 @@
33
-e .
44
annotated-types==0.7.0
55
# via pydantic
6-
anyio==4.5.2 ; python_full_version < '3.9'
7-
# via
8-
# httpx
9-
# llama-stack-client
10-
anyio==4.8.0 ; python_full_version >= '3.9'
6+
anyio==4.8.0
117
# via
128
# httpx
139
# llama-stack-client
10+
black==25.1.0
1411
certifi==2024.12.14
1512
# via
1613
# httpcore
1714
# httpx
15+
# requests
16+
cfgv==3.4.0
17+
# via pre-commit
18+
charset-normalizer==3.4.3
19+
# via requests
20+
click==8.2.1
21+
# via
22+
# black
23+
# llama-stack-client
1824
colorama==0.4.6 ; sys_platform == 'win32'
19-
# via pytest
25+
# via
26+
# click
27+
# pytest
28+
# tqdm
2029
dirty-equals==0.9.0
30+
distlib==0.4.0
31+
# via virtualenv
2132
distro==1.9.0
2233
# via llama-stack-client
23-
exceptiongroup==1.2.2 ; python_full_version < '3.11'
24-
# via
25-
# anyio
26-
# pytest
2734
execnet==2.1.1
2835
# via pytest-xdist
36+
filelock==3.19.1
37+
# via virtualenv
38+
fire==0.7.1
39+
# via llama-stack-client
2940
h11==0.16.0
3041
# via httpcore
3142
httpcore==1.0.9
@@ -34,12 +45,14 @@ httpx==0.28.1
3445
# via
3546
# llama-stack-client
3647
# respx
48+
identify==2.6.14
49+
# via pre-commit
3750
idna==3.10
3851
# via
3952
# anyio
4053
# httpx
41-
importlib-metadata==8.5.0 ; python_full_version < '3.9'
42-
importlib-metadata==8.6.1 ; python_full_version >= '3.9'
54+
# requests
55+
importlib-metadata==8.6.1
4356
iniconfig==2.0.0
4457
# via pytest
4558
markdown-it-py==3.0.0
@@ -48,14 +61,34 @@ mdurl==0.1.2
4861
# via markdown-it-py
4962
mypy==1.14.1
5063
mypy-extensions==1.0.0
51-
# via mypy
52-
nest-asyncio==1.6.0
64+
# via
65+
# black
66+
# mypy
5367
nodeenv==1.9.1
54-
# via pyright
68+
# via
69+
# pre-commit
70+
# pyright
71+
numpy==2.3.3
72+
# via pandas
5573
packaging==24.2
56-
# via pytest
74+
# via
75+
# black
76+
# pytest
77+
pandas==2.3.2
78+
# via llama-stack-client
79+
pathspec==0.12.1
80+
# via black
81+
platformdirs==4.4.0
82+
# via
83+
# black
84+
# virtualenv
5785
pluggy==1.5.0
5886
# via pytest
87+
pre-commit==4.3.0
88+
prompt-toolkit==3.0.52
89+
# via llama-stack-client
90+
pyaml==25.7.0
91+
# via llama-stack-client
5992
pydantic==2.10.3
6093
# via llama-stack-client
6194
pydantic-core==2.27.1
@@ -65,47 +98,56 @@ pygments==2.19.1
6598
# pytest
6699
# rich
67100
pyright==1.1.399
68-
pytest==8.3.5 ; python_full_version < '3.9'
69-
# via
70-
# pytest-asyncio
71-
# pytest-xdist
72-
pytest==8.4.1 ; python_full_version >= '3.9'
101+
pytest==8.4.1
73102
# via
74103
# pytest-asyncio
75104
# pytest-xdist
76105
pytest-asyncio==0.24.0
77-
pytest-xdist==3.6.1 ; python_full_version < '3.9'
78-
pytest-xdist==3.7.0 ; python_full_version >= '3.9'
106+
pytest-xdist==3.7.0
79107
python-dateutil==2.9.0.post0
80-
# via time-machine
81-
pytz==2024.2 ; python_full_version < '3.9'
82-
# via dirty-equals
108+
# via
109+
# pandas
110+
# time-machine
111+
pytz==2024.2
112+
# via pandas
113+
pyyaml==6.0.2
114+
# via
115+
# pre-commit
116+
# pyaml
117+
requests==2.32.5
118+
# via llama-stack-client
83119
respx==0.22.0
84120
rich==13.9.4
121+
# via llama-stack-client
85122
ruff==0.9.4
86123
six==1.17.0
87124
# via python-dateutil
88125
sniffio==1.3.1
89126
# via
90127
# anyio
91128
# llama-stack-client
92-
time-machine==2.15.0 ; python_full_version < '3.9'
93-
time-machine==2.16.0 ; python_full_version >= '3.9'
94-
tomli==2.2.1 ; python_full_version < '3.11'
129+
termcolor==3.1.0
95130
# via
96-
# mypy
97-
# pytest
131+
# fire
132+
# llama-stack-client
133+
time-machine==2.16.0
134+
tqdm==4.67.1
135+
# via llama-stack-client
98136
typing-extensions==4.12.2
99137
# via
100-
# annotated-types
101138
# anyio
102139
# llama-stack-client
103140
# mypy
104141
# pydantic
105142
# pydantic-core
106143
# pyright
107-
# rich
108-
zipp==3.20.2 ; python_full_version < '3.9'
109-
# via importlib-metadata
110-
zipp==3.21.0 ; python_full_version >= '3.9'
144+
tzdata==2025.2
145+
# via pandas
146+
urllib3==2.5.0
147+
# via requests
148+
virtualenv==20.34.0
149+
# via pre-commit
150+
wcwidth==0.2.13
151+
# via prompt-toolkit
152+
zipp==3.21.0
111153
# via importlib-metadata

tests/test_client.py

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
import os
77
import sys
88
import json
9-
import time
109
import asyncio
1110
import inspect
12-
import subprocess
1311
import tracemalloc
1412
from typing import Any, Union, cast
15-
from textwrap import dedent
1613
from unittest import mock
1714
from typing_extensions import Literal
1815

@@ -23,14 +20,17 @@
2320

2421
from llama_stack_client import LlamaStackClient, AsyncLlamaStackClient, APIResponseValidationError
2522
from llama_stack_client._types import Omit
23+
from llama_stack_client._utils import asyncify
2624
from llama_stack_client._models import BaseModel, FinalRequestOptions
2725
from llama_stack_client._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError
2826
from llama_stack_client._base_client import (
2927
DEFAULT_TIMEOUT,
3028
HTTPX_DEFAULT_TIMEOUT,
3129
BaseClient,
30+
OtherPlatform,
3231
DefaultHttpxClient,
3332
DefaultAsyncHttpxClient,
33+
get_platform,
3434
make_request_options,
3535
)
3636

@@ -1638,50 +1638,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16381638

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

1641-
def test_get_platform(self) -> None:
1642-
# A previous implementation of asyncify could leave threads unterminated when
1643-
# used with nest_asyncio.
1644-
#
1645-
# Since nest_asyncio.apply() is global and cannot be un-applied, this
1646-
# test is run in a separate process to avoid affecting other tests.
1647-
test_code = dedent("""
1648-
import asyncio
1649-
import nest_asyncio
1650-
import threading
1651-
1652-
from llama_stack_client._utils import asyncify
1653-
from llama_stack_client._base_client import get_platform
1654-
1655-
async def test_main() -> None:
1656-
result = await asyncify(get_platform)()
1657-
print(result)
1658-
for thread in threading.enumerate():
1659-
print(thread.name)
1660-
1661-
nest_asyncio.apply()
1662-
asyncio.run(test_main())
1663-
""")
1664-
with subprocess.Popen(
1665-
[sys.executable, "-c", test_code],
1666-
text=True,
1667-
) as process:
1668-
timeout = 10 # seconds
1669-
1670-
start_time = time.monotonic()
1671-
while True:
1672-
return_code = process.poll()
1673-
if return_code is not None:
1674-
if return_code != 0:
1675-
raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code")
1676-
1677-
# success
1678-
break
1679-
1680-
if time.monotonic() - start_time > timeout:
1681-
process.kill()
1682-
raise AssertionError("calling get_platform using asyncify resulted in a hung process")
1683-
1684-
time.sleep(0.1)
1641+
async def test_get_platform(self) -> None:
1642+
platform = await asyncify(get_platform)()
1643+
assert isinstance(platform, (str, OtherPlatform))
16851644

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

0 commit comments

Comments
 (0)