Skip to content

Commit f8b3493

Browse files
feat(api): api update
1 parent 2005e4f commit f8b3493

8 files changed

Lines changed: 42 additions & 15 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 92
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-1d4b018cbfb409baf83725737f00789a9ddbbdbdbe12db1ac7a1fd2cf9c453f0.yml
3-
openapi_spec_hash: 1c533f386f6d3d3802d353cc6f1df547
4-
config_hash: 33b544375e4a932cbb2890f79a9aa040
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-75c0dc94dd629772c98b3e6f763d8b3a1bdb732aa3eb92d49a59fb446fb2410d.yml
3+
openapi_spec_hash: 12286e648ea1156bfa23020ed0c7598b
4+
config_hash: e722b7242ee36143533531c419043a6f

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ Error codes are as follows:
245245

246246
### Retries
247247

248-
Certain errors are automatically retried 0 times by default, with a short exponential backoff.
248+
Certain errors are automatically retried 3 times by default, with a short exponential backoff.
249249
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
250250
429 Rate Limit, and >=500 Internal errors are all retried by default.
251251

@@ -266,15 +266,15 @@ client.with_options(max_retries=5).devboxes.create()
266266

267267
### Timeouts
268268

269-
By default requests time out after 1 minute. You can configure this with a `timeout` option,
269+
By default requests time out after 30 seconds. You can configure this with a `timeout` option,
270270
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:
271271

272272
```python
273273
from runloop_api_client import Runloop
274274

275275
# Configure the default for all requests:
276276
client = Runloop(
277-
# 20 seconds (default is 1 minute)
277+
# 20 seconds (default is 30 seconds)
278278
timeout=20.0,
279279
)
280280

src/runloop_api_client/_constants.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
RAW_RESPONSE_HEADER = "X-Stainless-Raw-Response"
66
OVERRIDE_CAST_TO_HEADER = "____stainless_override_cast_to"
77

8-
# default timeout is 1 minute
9-
DEFAULT_TIMEOUT = httpx.Timeout(timeout=60, connect=5.0)
10-
DEFAULT_MAX_RETRIES = 0
8+
# default timeout is 30 seconds
9+
DEFAULT_TIMEOUT = httpx.Timeout(timeout=30, connect=5.0)
10+
DEFAULT_MAX_RETRIES = 3
1111
DEFAULT_CONNECTION_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20)
1212

1313
INITIAL_RETRY_DELAY = 1.0
14-
MAX_RETRY_DELAY = 10.0
14+
MAX_RETRY_DELAY = 15.0

src/runloop_api_client/resources/devboxes/devboxes.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,8 @@ def download_file(
691691
"""
692692
if not id:
693693
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
694+
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
695+
timeout = 600
694696
extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})}
695697
return self._post(
696698
f"/v1/devboxes/{id}/download_file",
@@ -962,6 +964,8 @@ def read_file_contents(
962964
"""
963965
if not id:
964966
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
967+
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
968+
timeout = 600
965969
extra_headers = {"Accept": "text/plain", **(extra_headers or {})}
966970
return self._post(
967971
f"/v1/devboxes/{id}/read_file_contents",
@@ -1297,6 +1301,8 @@ def upload_file(
12971301
"""
12981302
if not id:
12991303
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1304+
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
1305+
timeout = 600
13001306
body = deepcopy_minimal(
13011307
{
13021308
"path": path,
@@ -1359,6 +1365,8 @@ def write_file_contents(
13591365
"""
13601366
if not id:
13611367
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1368+
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
1369+
timeout = 600
13621370
return self._post(
13631371
f"/v1/devboxes/{id}/write_file_contents",
13641372
body=maybe_transform(
@@ -1954,6 +1962,8 @@ async def download_file(
19541962
"""
19551963
if not id:
19561964
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1965+
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
1966+
timeout = 600
19571967
extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})}
19581968
return await self._post(
19591969
f"/v1/devboxes/{id}/download_file",
@@ -2225,6 +2235,8 @@ async def read_file_contents(
22252235
"""
22262236
if not id:
22272237
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2238+
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
2239+
timeout = 600
22282240
extra_headers = {"Accept": "text/plain", **(extra_headers or {})}
22292241
return await self._post(
22302242
f"/v1/devboxes/{id}/read_file_contents",
@@ -2560,6 +2572,8 @@ async def upload_file(
25602572
"""
25612573
if not id:
25622574
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2575+
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
2576+
timeout = 600
25632577
body = deepcopy_minimal(
25642578
{
25652579
"path": path,
@@ -2622,6 +2636,8 @@ async def write_file_contents(
26222636
"""
26232637
if not id:
26242638
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
2639+
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
2640+
timeout = 600
26252641
return await self._post(
26262642
f"/v1/devboxes/{id}/write_file_contents",
26272643
body=await async_maybe_transform(

src/runloop_api_client/resources/devboxes/executions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import httpx
88

99
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10-
from ..._utils import maybe_transform, async_maybe_transform
10+
from ..._utils import is_given, maybe_transform, async_maybe_transform
1111
from ..._compat import cached_property
1212
from ..._resource import SyncAPIResource, AsyncAPIResource
1313
from ..._response import (
@@ -17,6 +17,7 @@
1717
async_to_streamed_response_wrapper,
1818
)
1919
from ...lib.polling import PollingConfig, poll_until
20+
from ..._constants import DEFAULT_TIMEOUT
2021
from ..._base_client import make_request_options
2122
from ...types.devboxes import execution_retrieve_params, execution_execute_sync_params, execution_execute_async_params
2223
from ...lib.polling_async import async_poll_until
@@ -235,6 +236,8 @@ def execute_sync(
235236
"""
236237
if not id:
237238
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
239+
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
240+
timeout = 600
238241
return self._post(
239242
f"/v1/devboxes/{id}/execute_sync",
240243
body=maybe_transform(
@@ -510,6 +513,8 @@ async def execute_sync(
510513
"""
511514
if not id:
512515
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
516+
if not is_given(timeout) and self._client.timeout == DEFAULT_TIMEOUT:
517+
timeout = 600
513518
return await self._post(
514519
f"/v1/devboxes/{id}/execute_sync",
515520
body=await async_maybe_transform(

src/runloop_api_client/types/scoring_function.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class ScorerPythonScriptScoringFunction(BaseModel):
7474

7575
type: Literal["python_script_scorer"]
7676

77+
python_version_constraint: Optional[str] = None
78+
"""Python version to run scoring. Default is "==3.12.10" """
79+
7780
requirements_contents: Optional[str] = None
7881
"""Package dependencies to be installed.
7982

src/runloop_api_client/types/scoring_function_param.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class ScorerPythonScriptScoringFunction(TypedDict, total=False):
7373

7474
type: Required[Literal["python_script_scorer"]]
7575

76+
python_version_constraint: Optional[str]
77+
"""Python version to run scoring. Default is "==3.12.10" """
78+
7679
requirements_contents: str
7780
"""Package dependencies to be installed.
7881

tests/test_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def test_copy_default_options(self) -> None:
9393
# options that have a default are overridden correctly
9494
copied = self.client.copy(max_retries=7)
9595
assert copied.max_retries == 7
96-
assert self.client.max_retries == 0
96+
assert self.client.max_retries == 3
9797

9898
copied2 = copied.copy(max_retries=6)
9999
assert copied2.max_retries == 6
@@ -754,7 +754,7 @@ class Model(BaseModel):
754754
[3, "", 1],
755755
[2, "", 1 * 2.0],
756756
[1, "", 1 * 4.0],
757-
[-1100, "", 10], # test large number potentially overflowing
757+
[-1100, "", 15], # test large number potentially overflowing
758758
],
759759
)
760760
@mock.patch("time.time", mock.MagicMock(return_value=1696004797))
@@ -949,7 +949,7 @@ def test_copy_default_options(self) -> None:
949949
# options that have a default are overridden correctly
950950
copied = self.client.copy(max_retries=7)
951951
assert copied.max_retries == 7
952-
assert self.client.max_retries == 0
952+
assert self.client.max_retries == 3
953953

954954
copied2 = copied.copy(max_retries=6)
955955
assert copied2.max_retries == 6
@@ -1613,7 +1613,7 @@ class Model(BaseModel):
16131613
[3, "", 1],
16141614
[2, "", 1 * 2.0],
16151615
[1, "", 1 * 4.0],
1616-
[-1100, "", 10], # test large number potentially overflowing
1616+
[-1100, "", 15], # test large number potentially overflowing
16171617
],
16181618
)
16191619
@mock.patch("time.time", mock.MagicMock(return_value=1696004797))

0 commit comments

Comments
 (0)