Skip to content

Commit 0413e7b

Browse files
chore(stainless): generate watch_evictions as an SSE stream (#10404)
1 parent c06794d commit 0413e7b

6 files changed

Lines changed: 29 additions & 27 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 120
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai/runloop-f18b1bba718700c841b3904207cd8ba2c066421a691845d6283bbbb361cf161d.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai/runloop-6fb96a2de54d260cad2b76366cada4eda15335275dbab7f6c108c1bb29acf309.yml
33
openapi_spec_hash: 6044f4a4da13881c5f82fcc394c1f43b
4-
config_hash: d9a5b7a4227236a55c89de56b56f4aec
4+
config_hash: 92c04f0b12249cb2d2bcf9e503a9cbf9

api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ Types:
201201
```python
202202
from runloop_api_client.types import (
203203
DevboxAsyncExecutionDetailView,
204+
DevboxEvictionEventView,
204205
DevboxExecutionDetailView,
205206
DevboxKillExecutionRequest,
206207
DevboxListView,
@@ -214,7 +215,6 @@ from runloop_api_client.types import (
214215
TunnelView,
215216
DevboxCreateSSHKeyResponse,
216217
DevboxReadFileContentsResponse,
217-
DevboxWatchEvictionsResponse,
218218
)
219219
```
220220

@@ -245,7 +245,7 @@ Methods:
245245
- <code title="post /v1/devboxes/{id}/suspend">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">suspend</a>(id) -> <a href="./src/runloop_api_client/types/devbox_view.py">DevboxView</a></code>
246246
- <code title="post /v1/devboxes/{id}/upload_file">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">upload_file</a>(id, \*\*<a href="src/runloop_api_client/types/devbox_upload_file_params.py">params</a>) -> object</code>
247247
- <code title="post /v1/devboxes/{devbox_id}/executions/{execution_id}/wait_for_status">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">wait_for_command</a>(execution_id, \*, devbox_id, \*\*<a href="src/runloop_api_client/types/devbox_wait_for_command_params.py">params</a>) -> <a href="./src/runloop_api_client/types/devbox_async_execution_detail_view.py">DevboxAsyncExecutionDetailView</a></code>
248-
- <code title="get /v1/devboxes/watch_evictions">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">watch_evictions</a>() -> <a href="./src/runloop_api_client/types/devbox_watch_evictions_response.py">DevboxWatchEvictionsResponse</a></code>
248+
- <code title="get /v1/devboxes/watch_evictions">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">watch_evictions</a>() -> <a href="./src/runloop_api_client/types/devbox_eviction_event_view.py">DevboxEvictionEventView</a></code>
249249
- <code title="post /v1/devboxes/{id}/write_file_contents">client.devboxes.<a href="./src/runloop_api_client/resources/devboxes/devboxes.py">write_file_contents</a>(id, \*\*<a href="src/runloop_api_client/types/devbox_write_file_contents_params.py">params</a>) -> <a href="./src/runloop_api_client/types/devbox_execution_detail_view.py">DevboxExecutionDetailView</a></code>
250250

251251

src/runloop_api_client/resources/devboxes/devboxes.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
LONG_POLL_CLIENT_BUFFER_SECONDS,
7070
EXEC_LONG_POLL_SERVER_MAX_SECONDS,
7171
)
72+
from ..._streaming import Stream, AsyncStream
7273
from ...pagination import (
7374
SyncDevboxesCursorIDPage,
7475
AsyncDevboxesCursorIDPage,
@@ -94,10 +95,10 @@
9495
from ...types.shared_params.mount import Mount
9596
from ...types.devbox_snapshot_view import DevboxSnapshotView
9697
from ...types.shared.launch_parameters import LaunchParameters as SharedLaunchParameters
98+
from ...types.devbox_eviction_event_view import DevboxEvictionEventView
9799
from ...types.devbox_resource_usage_view import DevboxResourceUsageView
98100
from ...types.devbox_execution_detail_view import DevboxExecutionDetailView
99101
from ...types.devbox_create_ssh_key_response import DevboxCreateSSHKeyResponse
100-
from ...types.devbox_watch_evictions_response import DevboxWatchEvictionsResponse
101102
from ...types.shared_params.launch_parameters import LaunchParameters
102103
from ...types.devbox_async_execution_detail_view import DevboxAsyncExecutionDetailView
103104
from ...types.shared_params.code_mount_parameters import CodeMountParameters
@@ -1752,7 +1753,7 @@ def watch_evictions(
17521753
extra_query: Query | None = None,
17531754
extra_body: Body | None = None,
17541755
timeout: float | httpx.Timeout | None | NotGiven = not_given,
1755-
) -> DevboxWatchEvictionsResponse:
1756+
) -> Stream[DevboxEvictionEventView]:
17561757
"""
17571758
Subscribe, via server-sent events, to pending infrastructure evictions for every
17581759
Devbox in the account. On connect the stream emits one event per Devbox that
@@ -1765,7 +1766,9 @@ def watch_evictions(
17651766
options=make_request_options(
17661767
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
17671768
),
1768-
cast_to=DevboxWatchEvictionsResponse,
1769+
cast_to=DevboxEvictionEventView,
1770+
stream=True,
1771+
stream_cls=Stream[DevboxEvictionEventView],
17691772
)
17701773

17711774
def write_file_contents(
@@ -3452,7 +3455,7 @@ async def watch_evictions(
34523455
extra_query: Query | None = None,
34533456
extra_body: Body | None = None,
34543457
timeout: float | httpx.Timeout | None | NotGiven = not_given,
3455-
) -> DevboxWatchEvictionsResponse:
3458+
) -> AsyncStream[DevboxEvictionEventView]:
34563459
"""
34573460
Subscribe, via server-sent events, to pending infrastructure evictions for every
34583461
Devbox in the account. On connect the stream emits one event per Devbox that
@@ -3465,7 +3468,9 @@ async def watch_evictions(
34653468
options=make_request_options(
34663469
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
34673470
),
3468-
cast_to=DevboxWatchEvictionsResponse,
3471+
cast_to=DevboxEvictionEventView,
3472+
stream=True,
3473+
stream_cls=AsyncStream[DevboxEvictionEventView],
34693474
)
34703475

34713476
async def write_file_contents(

src/runloop_api_client/types/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
from .scenario_start_run_params import ScenarioStartRunParams as ScenarioStartRunParams
111111
from .benchmark_start_run_params import BenchmarkStartRunParams as BenchmarkStartRunParams
112112
from .blueprint_build_parameters import BlueprintBuildParameters as BlueprintBuildParameters
113+
from .devbox_eviction_event_view import DevboxEvictionEventView as DevboxEvictionEventView
113114
from .devbox_execute_sync_params import DevboxExecuteSyncParams as DevboxExecuteSyncParams
114115
from .devbox_resource_usage_view import DevboxResourceUsageView as DevboxResourceUsageView
115116
from .gateway_config_list_params import GatewayConfigListParams as GatewayConfigListParams
@@ -139,7 +140,6 @@
139140
from .blueprint_build_logs_list_view import BlueprintBuildLogsListView as BlueprintBuildLogsListView
140141
from .devbox_create_ssh_key_response import DevboxCreateSSHKeyResponse as DevboxCreateSSHKeyResponse
141142
from .devbox_wait_for_command_params import DevboxWaitForCommandParams as DevboxWaitForCommandParams
142-
from .devbox_watch_evictions_response import DevboxWatchEvictionsResponse as DevboxWatchEvictionsResponse
143143
from .devbox_read_file_contents_params import DevboxReadFileContentsParams as DevboxReadFileContentsParams
144144
from .benchmark_update_scenarios_params import BenchmarkUpdateScenariosParams as BenchmarkUpdateScenariosParams
145145
from .devbox_list_disk_snapshots_params import DevboxListDiskSnapshotsParams as DevboxListDiskSnapshotsParams

src/runloop_api_client/types/devbox_watch_evictions_response.py renamed to src/runloop_api_client/types/devbox_eviction_event_view.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
from .._models import BaseModel
44

5-
__all__ = ["DevboxWatchEvictionsResponse"]
5+
__all__ = ["DevboxEvictionEventView"]
66

77

8-
class DevboxWatchEvictionsResponse(BaseModel):
8+
class DevboxEvictionEventView(BaseModel):
99
devbox_id: str
1010
"""The ID of the Devbox with a pending eviction."""
1111

tests/api_resources/test_devboxes.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
DevboxResourceUsageView,
2121
DevboxExecutionDetailView,
2222
DevboxCreateSSHKeyResponse,
23-
DevboxWatchEvictionsResponse,
2423
DevboxAsyncExecutionDetailView,
2524
)
2625
from runloop_api_client._response import (
@@ -1193,26 +1192,25 @@ def test_path_params_wait_for_command(self, client: Runloop) -> None:
11931192

11941193
@parametrize
11951194
def test_method_watch_evictions(self, client: Runloop) -> None:
1196-
devbox = client.devboxes.watch_evictions()
1197-
assert_matches_type(DevboxWatchEvictionsResponse, devbox, path=["response"])
1195+
devbox_stream = client.devboxes.watch_evictions()
1196+
devbox_stream.response.close()
11981197

11991198
@parametrize
12001199
def test_raw_response_watch_evictions(self, client: Runloop) -> None:
12011200
response = client.devboxes.with_raw_response.watch_evictions()
12021201

1203-
assert response.is_closed is True
12041202
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
1205-
devbox = response.parse()
1206-
assert_matches_type(DevboxWatchEvictionsResponse, devbox, path=["response"])
1203+
stream = response.parse()
1204+
stream.close()
12071205

12081206
@parametrize
12091207
def test_streaming_response_watch_evictions(self, client: Runloop) -> None:
12101208
with client.devboxes.with_streaming_response.watch_evictions() as response:
12111209
assert not response.is_closed
12121210
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
12131211

1214-
devbox = response.parse()
1215-
assert_matches_type(DevboxWatchEvictionsResponse, devbox, path=["response"])
1212+
stream = response.parse()
1213+
stream.close()
12161214

12171215
assert cast(Any, response.is_closed) is True
12181216

@@ -2887,26 +2885,25 @@ async def test_path_params_wait_for_command(self, async_client: AsyncRunloop) ->
28872885

28882886
@parametrize
28892887
async def test_method_watch_evictions(self, async_client: AsyncRunloop) -> None:
2890-
devbox = await async_client.devboxes.watch_evictions()
2891-
assert_matches_type(DevboxWatchEvictionsResponse, devbox, path=["response"])
2888+
devbox_stream = await async_client.devboxes.watch_evictions()
2889+
await devbox_stream.response.aclose()
28922890

28932891
@parametrize
28942892
async def test_raw_response_watch_evictions(self, async_client: AsyncRunloop) -> None:
28952893
response = await async_client.devboxes.with_raw_response.watch_evictions()
28962894

2897-
assert response.is_closed is True
28982895
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
2899-
devbox = await response.parse()
2900-
assert_matches_type(DevboxWatchEvictionsResponse, devbox, path=["response"])
2896+
stream = await response.parse()
2897+
await stream.close()
29012898

29022899
@parametrize
29032900
async def test_streaming_response_watch_evictions(self, async_client: AsyncRunloop) -> None:
29042901
async with async_client.devboxes.with_streaming_response.watch_evictions() as response:
29052902
assert not response.is_closed
29062903
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
29072904

2908-
devbox = await response.parse()
2909-
assert_matches_type(DevboxWatchEvictionsResponse, devbox, path=["response"])
2905+
stream = await response.parse()
2906+
await stream.close()
29102907

29112908
assert cast(Any, response.is_closed) is True
29122909

0 commit comments

Comments
 (0)