Skip to content

Commit 78b4faa

Browse files
feat(benchmarks): add update_scenarios method to benchmarks resource
1 parent ca27100 commit 78b4faa

6 files changed

Lines changed: 236 additions & 2 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 97
1+
configured_endpoints: 98
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-370a5d676ff0ef41f3ca6ed669d29b6e3e6b7f0a914ac3dbed6bd45e75533c74.yml
33
openapi_spec_hash: 7bb5ea1117d754b7985aff0da5bca3a7
4-
config_hash: 2363f563f42501d2b1587a4f64bdccaf
4+
config_hash: 7b7fc2ccd6bf3551718a79332772e713

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ from runloop_api_client.types import (
2020
BenchmarkCreateParameters,
2121
BenchmarkRunListView,
2222
BenchmarkRunView,
23+
BenchmarkScenarioUpdateParameters,
2324
BenchmarkView,
2425
ScenarioDefinitionListView,
2526
StartBenchmarkRunParameters,
@@ -35,6 +36,7 @@ Methods:
3536
- <code title="get /v1/benchmarks/{id}/definitions">client.benchmarks.<a href="./src/runloop_api_client/resources/benchmarks/benchmarks.py">definitions</a>(id, \*\*<a href="src/runloop_api_client/types/benchmark_definitions_params.py">params</a>) -> <a href="./src/runloop_api_client/types/scenario_definition_list_view.py">ScenarioDefinitionListView</a></code>
3637
- <code title="get /v1/benchmarks/list_public">client.benchmarks.<a href="./src/runloop_api_client/resources/benchmarks/benchmarks.py">list_public</a>(\*\*<a href="src/runloop_api_client/types/benchmark_list_public_params.py">params</a>) -> <a href="./src/runloop_api_client/types/benchmark_view.py">SyncBenchmarksCursorIDPage[BenchmarkView]</a></code>
3738
- <code title="post /v1/benchmarks/start_run">client.benchmarks.<a href="./src/runloop_api_client/resources/benchmarks/benchmarks.py">start_run</a>(\*\*<a href="src/runloop_api_client/types/benchmark_start_run_params.py">params</a>) -> <a href="./src/runloop_api_client/types/benchmark_run_view.py">BenchmarkRunView</a></code>
39+
- <code title="post /v1/benchmarks/{id}/scenarios">client.benchmarks.<a href="./src/runloop_api_client/resources/benchmarks/benchmarks.py">update_scenarios</a>(id, \*\*<a href="src/runloop_api_client/types/benchmark_update_scenarios_params.py">params</a>) -> <a href="./src/runloop_api_client/types/benchmark_view.py">BenchmarkView</a></code>
3840

3941
## Runs
4042

src/runloop_api_client/resources/benchmarks/benchmarks.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
benchmark_start_run_params,
2222
benchmark_definitions_params,
2323
benchmark_list_public_params,
24+
benchmark_update_scenarios_params,
2425
)
2526
from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
2627
from ..._utils import maybe_transform, async_maybe_transform
@@ -453,6 +454,59 @@ def start_run(
453454
cast_to=BenchmarkRunView,
454455
)
455456

457+
def update_scenarios(
458+
self,
459+
id: str,
460+
*,
461+
scenarios_to_add: Optional[SequenceNotStr[str]] | Omit = omit,
462+
scenarios_to_remove: Optional[SequenceNotStr[str]] | Omit = omit,
463+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
464+
# The extra values given here take precedence over values defined on the client or passed to this method.
465+
extra_headers: Headers | None = None,
466+
extra_query: Query | None = None,
467+
extra_body: Body | None = None,
468+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
469+
idempotency_key: str | None = None,
470+
) -> BenchmarkView:
471+
"""
472+
Add and/or remove Scenario IDs from an existing Benchmark.
473+
474+
Args:
475+
scenarios_to_add: Scenario IDs to add to the Benchmark.
476+
477+
scenarios_to_remove: Scenario IDs to remove from the Benchmark.
478+
479+
extra_headers: Send extra headers
480+
481+
extra_query: Add additional query parameters to the request
482+
483+
extra_body: Add additional JSON properties to the request
484+
485+
timeout: Override the client-level default timeout for this request, in seconds
486+
487+
idempotency_key: Specify a custom idempotency key for this request
488+
"""
489+
if not id:
490+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
491+
return self._post(
492+
f"/v1/benchmarks/{id}/scenarios",
493+
body=maybe_transform(
494+
{
495+
"scenarios_to_add": scenarios_to_add,
496+
"scenarios_to_remove": scenarios_to_remove,
497+
},
498+
benchmark_update_scenarios_params.BenchmarkUpdateScenariosParams,
499+
),
500+
options=make_request_options(
501+
extra_headers=extra_headers,
502+
extra_query=extra_query,
503+
extra_body=extra_body,
504+
timeout=timeout,
505+
idempotency_key=idempotency_key,
506+
),
507+
cast_to=BenchmarkView,
508+
)
509+
456510

457511
class AsyncBenchmarksResource(AsyncAPIResource):
458512
@cached_property
@@ -865,6 +919,59 @@ async def start_run(
865919
cast_to=BenchmarkRunView,
866920
)
867921

922+
async def update_scenarios(
923+
self,
924+
id: str,
925+
*,
926+
scenarios_to_add: Optional[SequenceNotStr[str]] | Omit = omit,
927+
scenarios_to_remove: Optional[SequenceNotStr[str]] | Omit = omit,
928+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
929+
# The extra values given here take precedence over values defined on the client or passed to this method.
930+
extra_headers: Headers | None = None,
931+
extra_query: Query | None = None,
932+
extra_body: Body | None = None,
933+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
934+
idempotency_key: str | None = None,
935+
) -> BenchmarkView:
936+
"""
937+
Add and/or remove Scenario IDs from an existing Benchmark.
938+
939+
Args:
940+
scenarios_to_add: Scenario IDs to add to the Benchmark.
941+
942+
scenarios_to_remove: Scenario IDs to remove from the Benchmark.
943+
944+
extra_headers: Send extra headers
945+
946+
extra_query: Add additional query parameters to the request
947+
948+
extra_body: Add additional JSON properties to the request
949+
950+
timeout: Override the client-level default timeout for this request, in seconds
951+
952+
idempotency_key: Specify a custom idempotency key for this request
953+
"""
954+
if not id:
955+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
956+
return await self._post(
957+
f"/v1/benchmarks/{id}/scenarios",
958+
body=await async_maybe_transform(
959+
{
960+
"scenarios_to_add": scenarios_to_add,
961+
"scenarios_to_remove": scenarios_to_remove,
962+
},
963+
benchmark_update_scenarios_params.BenchmarkUpdateScenariosParams,
964+
),
965+
options=make_request_options(
966+
extra_headers=extra_headers,
967+
extra_query=extra_query,
968+
extra_body=extra_body,
969+
timeout=timeout,
970+
idempotency_key=idempotency_key,
971+
),
972+
cast_to=BenchmarkView,
973+
)
974+
868975

869976
class BenchmarksResourceWithRawResponse:
870977
def __init__(self, benchmarks: BenchmarksResource) -> None:
@@ -891,6 +998,9 @@ def __init__(self, benchmarks: BenchmarksResource) -> None:
891998
self.start_run = to_raw_response_wrapper(
892999
benchmarks.start_run,
8931000
)
1001+
self.update_scenarios = to_raw_response_wrapper(
1002+
benchmarks.update_scenarios,
1003+
)
8941004

8951005
@cached_property
8961006
def runs(self) -> RunsResourceWithRawResponse:
@@ -922,6 +1032,9 @@ def __init__(self, benchmarks: AsyncBenchmarksResource) -> None:
9221032
self.start_run = async_to_raw_response_wrapper(
9231033
benchmarks.start_run,
9241034
)
1035+
self.update_scenarios = async_to_raw_response_wrapper(
1036+
benchmarks.update_scenarios,
1037+
)
9251038

9261039
@cached_property
9271040
def runs(self) -> AsyncRunsResourceWithRawResponse:
@@ -953,6 +1066,9 @@ def __init__(self, benchmarks: BenchmarksResource) -> None:
9531066
self.start_run = to_streamed_response_wrapper(
9541067
benchmarks.start_run,
9551068
)
1069+
self.update_scenarios = to_streamed_response_wrapper(
1070+
benchmarks.update_scenarios,
1071+
)
9561072

9571073
@cached_property
9581074
def runs(self) -> RunsResourceWithStreamingResponse:
@@ -984,6 +1100,9 @@ def __init__(self, benchmarks: AsyncBenchmarksResource) -> None:
9841100
self.start_run = async_to_streamed_response_wrapper(
9851101
benchmarks.start_run,
9861102
)
1103+
self.update_scenarios = async_to_streamed_response_wrapper(
1104+
benchmarks.update_scenarios,
1105+
)
9871106

9881107
@cached_property
9891108
def runs(self) -> AsyncRunsResourceWithStreamingResponse:

src/runloop_api_client/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
from .repository_connection_list_view import RepositoryConnectionListView as RepositoryConnectionListView
9898
from .repository_inspection_list_view import RepositoryInspectionListView as RepositoryInspectionListView
9999
from .devbox_read_file_contents_params import DevboxReadFileContentsParams as DevboxReadFileContentsParams
100+
from .benchmark_update_scenarios_params import BenchmarkUpdateScenariosParams as BenchmarkUpdateScenariosParams
100101
from .devbox_list_disk_snapshots_params import DevboxListDiskSnapshotsParams as DevboxListDiskSnapshotsParams
101102
from .devbox_snapshot_disk_async_params import DevboxSnapshotDiskAsyncParams as DevboxSnapshotDiskAsyncParams
102103
from .devbox_write_file_contents_params import DevboxWriteFileContentsParams as DevboxWriteFileContentsParams
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Optional
6+
from typing_extensions import TypedDict
7+
8+
from .._types import SequenceNotStr
9+
10+
__all__ = ["BenchmarkUpdateScenariosParams"]
11+
12+
13+
class BenchmarkUpdateScenariosParams(TypedDict, total=False):
14+
scenarios_to_add: Optional[SequenceNotStr[str]]
15+
"""Scenario IDs to add to the Benchmark."""
16+
17+
scenarios_to_remove: Optional[SequenceNotStr[str]]
18+
"""Scenario IDs to remove from the Benchmark."""

tests/api_resources/test_benchmarks.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,53 @@ def test_streaming_response_start_run(self, client: Runloop) -> None:
345345

346346
assert cast(Any, response.is_closed) is True
347347

348+
@parametrize
349+
def test_method_update_scenarios(self, client: Runloop) -> None:
350+
benchmark = client.benchmarks.update_scenarios(
351+
id="id",
352+
)
353+
assert_matches_type(BenchmarkView, benchmark, path=["response"])
354+
355+
@parametrize
356+
def test_method_update_scenarios_with_all_params(self, client: Runloop) -> None:
357+
benchmark = client.benchmarks.update_scenarios(
358+
id="id",
359+
scenarios_to_add=["string"],
360+
scenarios_to_remove=["string"],
361+
)
362+
assert_matches_type(BenchmarkView, benchmark, path=["response"])
363+
364+
@parametrize
365+
def test_raw_response_update_scenarios(self, client: Runloop) -> None:
366+
response = client.benchmarks.with_raw_response.update_scenarios(
367+
id="id",
368+
)
369+
370+
assert response.is_closed is True
371+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
372+
benchmark = response.parse()
373+
assert_matches_type(BenchmarkView, benchmark, path=["response"])
374+
375+
@parametrize
376+
def test_streaming_response_update_scenarios(self, client: Runloop) -> None:
377+
with client.benchmarks.with_streaming_response.update_scenarios(
378+
id="id",
379+
) as response:
380+
assert not response.is_closed
381+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
382+
383+
benchmark = response.parse()
384+
assert_matches_type(BenchmarkView, benchmark, path=["response"])
385+
386+
assert cast(Any, response.is_closed) is True
387+
388+
@parametrize
389+
def test_path_params_update_scenarios(self, client: Runloop) -> None:
390+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
391+
client.benchmarks.with_raw_response.update_scenarios(
392+
id="",
393+
)
394+
348395

349396
class TestAsyncBenchmarks:
350397
parametrize = pytest.mark.parametrize(
@@ -673,3 +720,50 @@ async def test_streaming_response_start_run(self, async_client: AsyncRunloop) ->
673720
assert_matches_type(BenchmarkRunView, benchmark, path=["response"])
674721

675722
assert cast(Any, response.is_closed) is True
723+
724+
@parametrize
725+
async def test_method_update_scenarios(self, async_client: AsyncRunloop) -> None:
726+
benchmark = await async_client.benchmarks.update_scenarios(
727+
id="id",
728+
)
729+
assert_matches_type(BenchmarkView, benchmark, path=["response"])
730+
731+
@parametrize
732+
async def test_method_update_scenarios_with_all_params(self, async_client: AsyncRunloop) -> None:
733+
benchmark = await async_client.benchmarks.update_scenarios(
734+
id="id",
735+
scenarios_to_add=["string"],
736+
scenarios_to_remove=["string"],
737+
)
738+
assert_matches_type(BenchmarkView, benchmark, path=["response"])
739+
740+
@parametrize
741+
async def test_raw_response_update_scenarios(self, async_client: AsyncRunloop) -> None:
742+
response = await async_client.benchmarks.with_raw_response.update_scenarios(
743+
id="id",
744+
)
745+
746+
assert response.is_closed is True
747+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
748+
benchmark = await response.parse()
749+
assert_matches_type(BenchmarkView, benchmark, path=["response"])
750+
751+
@parametrize
752+
async def test_streaming_response_update_scenarios(self, async_client: AsyncRunloop) -> None:
753+
async with async_client.benchmarks.with_streaming_response.update_scenarios(
754+
id="id",
755+
) as response:
756+
assert not response.is_closed
757+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
758+
759+
benchmark = await response.parse()
760+
assert_matches_type(BenchmarkView, benchmark, path=["response"])
761+
762+
assert cast(Any, response.is_closed) is True
763+
764+
@parametrize
765+
async def test_path_params_update_scenarios(self, async_client: AsyncRunloop) -> None:
766+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
767+
await async_client.benchmarks.with_raw_response.update_scenarios(
768+
id="",
769+
)

0 commit comments

Comments
 (0)