Skip to content

Commit 732ca9e

Browse files
committed
return lost functionality
1 parent effb5ea commit 732ca9e

4 files changed

Lines changed: 119 additions & 36 deletions

File tree

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies = [
1515
"distro>=1.7.0, <2",
1616
"sniffio",
1717
]
18+
1819
requires-python = ">= 3.8"
1920
classifiers = [
2021
"Typing :: Typed",
@@ -93,6 +94,11 @@ typecheck = { chain = [
9394
requires = ["hatchling==1.26.3", "hatch-fancy-pypi-readme"]
9495
build-backend = "hatchling.build"
9596

97+
[dependency-groups]
98+
lint = [
99+
"ruff>=0.12.7",
100+
]
101+
96102
[tool.hatch.build]
97103
include = [
98104
"src/*"

src/runloop_api_client/resources/blueprints.py

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

33
from __future__ import annotations
44

5-
from typing import Dict, List, Iterable, Optional
5+
from typing import Dict, List, Iterable, Optional, TypedDict
66

77
import httpx
88

@@ -28,7 +28,19 @@
2828
from ..types.shared_params.launch_parameters import LaunchParameters
2929
from ..types.shared_params.code_mount_parameters import CodeMountParameters
3030

31-
__all__ = ["BlueprintsResource", "AsyncBlueprintsResource"]
31+
32+
# Type for request arguments that combine polling config with additional request options
33+
class BlueprintRequestArgs(TypedDict, total=False):
34+
polling_config: PollingConfig | None
35+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
36+
# The extra values given here take precedence over values defined on the client or passed to this method.
37+
extra_headers: Headers | None
38+
extra_query: Query | None
39+
extra_body: Body | None
40+
timeout: float | httpx.Timeout | None | NotGiven
41+
42+
43+
__all__ = ["BlueprintsResource", "AsyncBlueprintsResource", "BlueprintRequestArgs"]
3244

3345

3446
class BlueprintsResource(SyncAPIResource):
@@ -188,13 +200,10 @@ def await_build_complete(
188200
PollingTimeout: If polling times out before blueprint is built
189201
RunloopError: If blueprint enters a non-built terminal state
190202
"""
203+
191204
def retrieve_blueprint() -> BlueprintView:
192205
return self.retrieve(
193-
id,
194-
extra_headers=extra_headers,
195-
extra_query=extra_query,
196-
extra_body=extra_body,
197-
timeout=timeout
206+
id, extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
198207
)
199208

200209
def is_done_building(blueprint: BlueprintView) -> bool:
@@ -203,25 +212,23 @@ def is_done_building(blueprint: BlueprintView) -> bool:
203212
blueprint = poll_until(retrieve_blueprint, is_done_building, polling_config)
204213

205214
if blueprint.status != "build_complete":
206-
raise RunloopError(
207-
f"Blueprint entered non-built terminal state: {blueprint.status}"
208-
)
215+
raise RunloopError(f"Blueprint entered non-built terminal state: {blueprint.status}")
209216

210217
return blueprint
211218

212219
def create_and_await_build_complete(
213220
self,
214221
*,
215222
create_args: blueprint_create_params.BlueprintCreateParams,
216-
polling_config: PollingConfig | None = None,
223+
request_args: BlueprintRequestArgs | None = None,
217224
) -> BlueprintView:
218225
"""Create a new Blueprint and wait for it to finish building.
219226
220227
This is a wrapper around the `create` method that waits for the blueprint to finish building.
221228
222229
Args:
223230
create_args: Arguments to pass to the `create` method. See the `create` method for detailed documentation.
224-
polling_config: Optional polling configuration
231+
request_args: Optional request arguments including polling configuration and additional request options
225232
226233
Returns:
227234
The built blueprint
@@ -233,9 +240,16 @@ def create_and_await_build_complete(
233240
# Pass all create_args to the underlying create method
234241
blueprint = self.create(**create_args)
235242

243+
if request_args is None:
244+
request_args = {}
245+
236246
return self.await_build_complete(
237247
blueprint.id,
238-
polling_config=polling_config,
248+
polling_config=request_args.get("polling_config", None),
249+
extra_headers=request_args.get("extra_headers", None),
250+
extra_query=request_args.get("extra_query", None),
251+
extra_body=request_args.get("extra_body", None),
252+
timeout=request_args.get("timeout", None),
239253
)
240254

241255
def list(
@@ -563,7 +577,7 @@ async def retrieve(
563577
),
564578
cast_to=BlueprintView,
565579
)
566-
580+
567581
async def await_build_complete(
568582
self,
569583
id: str,
@@ -593,13 +607,10 @@ async def await_build_complete(
593607
PollingTimeout: If polling times out before blueprint is built
594608
RunloopError: If blueprint enters a non-built terminal state
595609
"""
610+
596611
async def retrieve_blueprint() -> BlueprintView:
597612
return await self.retrieve(
598-
id,
599-
extra_headers=extra_headers,
600-
extra_query=extra_query,
601-
extra_body=extra_body,
602-
timeout=timeout
613+
id, extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
603614
)
604615

605616
def is_done_building(blueprint: BlueprintView) -> bool:
@@ -608,25 +619,23 @@ def is_done_building(blueprint: BlueprintView) -> bool:
608619
blueprint = await async_poll_until(retrieve_blueprint, is_done_building, polling_config)
609620

610621
if blueprint.status != "build_complete":
611-
raise RunloopError(
612-
f"Blueprint entered non-built terminal state: {blueprint.status}"
613-
)
622+
raise RunloopError(f"Blueprint entered non-built terminal state: {blueprint.status}")
614623

615624
return blueprint
616625

617626
async def create_and_await_build_complete(
618627
self,
619628
*,
620629
create_args: blueprint_create_params.BlueprintCreateParams,
621-
polling_config: PollingConfig | None = None,
630+
request_args: BlueprintRequestArgs | None = None,
622631
) -> BlueprintView:
623632
"""Create a new Blueprint and wait for it to finish building.
624633
625634
This is a wrapper around the `create` method that waits for the blueprint to finish building.
626635
627636
Args:
628637
create_args: Arguments to pass to the `create` method. See the `create` method for detailed documentation.
629-
polling_config: Optional polling configuration
638+
request_args: Optional request arguments including polling configuration and additional request options
630639
631640
Returns:
632641
The built blueprint
@@ -638,9 +647,17 @@ async def create_and_await_build_complete(
638647
# Pass all create_args to the underlying create method
639648
blueprint = await self.create(**create_args)
640649

650+
# Extract polling config and other request args
651+
if request_args is None:
652+
request_args = {}
653+
641654
return await self.await_build_complete(
642655
blueprint.id,
643-
polling_config=polling_config,
656+
polling_config=request_args.get("polling_config", None),
657+
extra_headers=request_args.get("extra_headers", None),
658+
extra_query=request_args.get("extra_query", None),
659+
extra_body=request_args.get("extra_body", None),
660+
timeout=request_args.get("timeout", None),
644661
)
645662

646663
def list(

src/runloop_api_client/resources/devboxes/devboxes.py

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

33
from __future__ import annotations
44

5-
from typing import Dict, Mapping, Iterable, Optional, cast
5+
from typing import Dict, Mapping, Iterable, Optional, cast, TypedDict
66
from typing_extensions import Literal
77

88
import httpx
@@ -110,11 +110,20 @@
110110
from ...types.devbox_async_execution_detail_view import DevboxAsyncExecutionDetailView
111111
from ...types.shared_params.code_mount_parameters import CodeMountParameters
112112

113-
__all__ = ["DevboxesResource", "AsyncDevboxesResource"]
113+
__all__ = ["DevboxesResource", "AsyncDevboxesResource", "DevboxRequestArgs"]
114114

115115
DEVBOX_BOOTING_STATES = frozenset(("provisioning", "initializing"))
116116

117117

118+
# Type for request arguments that combine polling config with additional request options
119+
class DevboxRequestArgs(TypedDict, total=False):
120+
polling_config: PollingConfig | None
121+
extra_headers: Headers | None
122+
extra_query: Query | None
123+
extra_body: Body | None
124+
timeout: float | httpx.Timeout | None | NotGiven
125+
126+
118127
def placeholder_devbox_view(id: str) -> DevboxView:
119128
return DevboxView(
120129
id=id,
@@ -374,6 +383,10 @@ def await_running(
374383
*,
375384
# Use polling_config to configure the "long" polling behavior.
376385
polling_config: PollingConfig | None = None,
386+
extra_headers: Headers | None = None,
387+
extra_query: Query | None = None,
388+
extra_body: Body | None = None,
389+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
377390
) -> DevboxView:
378391
"""Wait for a devbox to be in running state.
379392
@@ -427,15 +440,15 @@ def create_and_await_running(
427440
self,
428441
*,
429442
create_args: devbox_create_params.DevboxCreateParams,
430-
polling_config: PollingConfig | None = None,
443+
request_args: DevboxRequestArgs | None = None,
431444
) -> DevboxView:
432445
"""Create a new devbox and wait for it to be in running state.
433446
434447
This is a wrapper around the `create` method that waits for the devbox to reach running state.
435-
448+
436449
Args:
437450
create_args: Arguments to pass to the `create` method. See the `create` method for detailed documentation.
438-
polling_config: Optional polling configuration
451+
request_args: Optional request arguments including polling configuration and additional request options
439452
440453
Returns:
441454
The devbox in running state
@@ -444,12 +457,22 @@ def create_and_await_running(
444457
PollingTimeout: If polling times out before devbox is running
445458
RunloopError: If devbox enters a non-running terminal state
446459
"""
460+
# Extract polling config and other request args
461+
if request_args is None:
462+
request_args = {}
463+
447464
# Pass all create_args to the underlying create method
448-
devbox = self.create(**create_args)
465+
devbox = self.create(
466+
**create_args,
467+
extra_headers=request_args.get("extra_headers", None),
468+
extra_query=request_args.get("extra_query", None),
469+
extra_body=request_args.get("extra_body", None),
470+
timeout=request_args.get("timeout", None),
471+
)
449472

450473
return self.await_running(
451474
devbox.id,
452-
polling_config=polling_config,
475+
polling_config=request_args.get("polling_config", None),
453476
)
454477

455478
def list(
@@ -1570,15 +1593,15 @@ async def create_and_await_running(
15701593
self,
15711594
*,
15721595
create_args: devbox_create_params.DevboxCreateParams,
1573-
polling_config: PollingConfig | None = None,
1596+
request_args: DevboxRequestArgs | None = None,
15741597
) -> DevboxView:
15751598
"""Create a devbox and wait for it to be in running state.
15761599
15771600
This is a wrapper around the `create` method that waits for the devbox to reach running state.
1578-
1601+
15791602
Args:
15801603
create_args: Arguments to pass to the `create` method. See the `create` method for detailed documentation.
1581-
polling_config: Optional polling configuration
1604+
request_args: Optional request arguments including polling configuration and additional request options
15821605
15831606
Returns:
15841607
The devbox in running state
@@ -1590,9 +1613,13 @@ async def create_and_await_running(
15901613
# Pass all create_args to the underlying create method
15911614
devbox = await self.create(**create_args)
15921615

1616+
# Extract polling config and other request args
1617+
if request_args is None:
1618+
request_args = {}
1619+
15931620
return await self.await_running(
15941621
devbox.id,
1595-
polling_config=polling_config,
1622+
polling_config=request_args.get("polling_config", None),
15961623
)
15971624

15981625
async def await_running(

uv.lock

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)