runloop_api_client 0.61.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. runloop_api_client/__init__.py +92 -0
  2. runloop_api_client/_base_client.py +1995 -0
  3. runloop_api_client/_client.py +668 -0
  4. runloop_api_client/_compat.py +219 -0
  5. runloop_api_client/_constants.py +14 -0
  6. runloop_api_client/_exceptions.py +108 -0
  7. runloop_api_client/_files.py +123 -0
  8. runloop_api_client/_models.py +835 -0
  9. runloop_api_client/_qs.py +150 -0
  10. runloop_api_client/_resource.py +43 -0
  11. runloop_api_client/_response.py +832 -0
  12. runloop_api_client/_streaming.py +520 -0
  13. runloop_api_client/_types.py +260 -0
  14. runloop_api_client/_utils/__init__.py +64 -0
  15. runloop_api_client/_utils/_compat.py +45 -0
  16. runloop_api_client/_utils/_datetime_parse.py +136 -0
  17. runloop_api_client/_utils/_logs.py +25 -0
  18. runloop_api_client/_utils/_proxy.py +65 -0
  19. runloop_api_client/_utils/_reflection.py +42 -0
  20. runloop_api_client/_utils/_resources_proxy.py +24 -0
  21. runloop_api_client/_utils/_streams.py +12 -0
  22. runloop_api_client/_utils/_sync.py +86 -0
  23. runloop_api_client/_utils/_transform.py +457 -0
  24. runloop_api_client/_utils/_typing.py +156 -0
  25. runloop_api_client/_utils/_utils.py +421 -0
  26. runloop_api_client/_version.py +4 -0
  27. runloop_api_client/lib/.keep +4 -0
  28. runloop_api_client/lib/polling.py +75 -0
  29. runloop_api_client/lib/polling_async.py +60 -0
  30. runloop_api_client/pagination.py +761 -0
  31. runloop_api_client/py.typed +0 -0
  32. runloop_api_client/resources/__init__.py +103 -0
  33. runloop_api_client/resources/benchmarks/__init__.py +33 -0
  34. runloop_api_client/resources/benchmarks/benchmarks.py +982 -0
  35. runloop_api_client/resources/benchmarks/runs.py +587 -0
  36. runloop_api_client/resources/blueprints.py +1206 -0
  37. runloop_api_client/resources/devboxes/__init__.py +89 -0
  38. runloop_api_client/resources/devboxes/browsers.py +267 -0
  39. runloop_api_client/resources/devboxes/computers.py +648 -0
  40. runloop_api_client/resources/devboxes/devboxes.py +3414 -0
  41. runloop_api_client/resources/devboxes/disk_snapshots.py +519 -0
  42. runloop_api_client/resources/devboxes/executions.py +1059 -0
  43. runloop_api_client/resources/devboxes/logs.py +197 -0
  44. runloop_api_client/resources/objects.py +860 -0
  45. runloop_api_client/resources/repositories.py +717 -0
  46. runloop_api_client/resources/scenarios/__init__.py +47 -0
  47. runloop_api_client/resources/scenarios/runs.py +949 -0
  48. runloop_api_client/resources/scenarios/scenarios.py +1079 -0
  49. runloop_api_client/resources/scenarios/scorers.py +629 -0
  50. runloop_api_client/resources/secrets.py +500 -0
  51. runloop_api_client/types/__init__.py +95 -0
  52. runloop_api_client/types/benchmark_create_params.py +40 -0
  53. runloop_api_client/types/benchmark_definitions_params.py +15 -0
  54. runloop_api_client/types/benchmark_list_params.py +15 -0
  55. runloop_api_client/types/benchmark_list_public_params.py +15 -0
  56. runloop_api_client/types/benchmark_run_list_view.py +19 -0
  57. runloop_api_client/types/benchmark_run_view.py +51 -0
  58. runloop_api_client/types/benchmark_start_run_params.py +25 -0
  59. runloop_api_client/types/benchmark_update_params.py +40 -0
  60. runloop_api_client/types/benchmark_view.py +45 -0
  61. runloop_api_client/types/benchmarks/__init__.py +6 -0
  62. runloop_api_client/types/benchmarks/run_list_params.py +18 -0
  63. runloop_api_client/types/benchmarks/run_list_scenario_runs_params.py +18 -0
  64. runloop_api_client/types/blueprint_build_log.py +16 -0
  65. runloop_api_client/types/blueprint_build_logs_list_view.py +16 -0
  66. runloop_api_client/types/blueprint_build_parameters.py +87 -0
  67. runloop_api_client/types/blueprint_create_params.py +90 -0
  68. runloop_api_client/types/blueprint_list_params.py +18 -0
  69. runloop_api_client/types/blueprint_list_public_params.py +18 -0
  70. runloop_api_client/types/blueprint_list_view.py +19 -0
  71. runloop_api_client/types/blueprint_preview_params.py +90 -0
  72. runloop_api_client/types/blueprint_preview_view.py +10 -0
  73. runloop_api_client/types/blueprint_view.py +86 -0
  74. runloop_api_client/types/devbox_async_execution_detail_view.py +40 -0
  75. runloop_api_client/types/devbox_create_params.py +70 -0
  76. runloop_api_client/types/devbox_create_ssh_key_response.py +16 -0
  77. runloop_api_client/types/devbox_create_tunnel_params.py +12 -0
  78. runloop_api_client/types/devbox_download_file_params.py +15 -0
  79. runloop_api_client/types/devbox_execute_async_params.py +25 -0
  80. runloop_api_client/types/devbox_execute_params.py +34 -0
  81. runloop_api_client/types/devbox_execute_sync_params.py +25 -0
  82. runloop_api_client/types/devbox_execution_detail_view.py +24 -0
  83. runloop_api_client/types/devbox_list_disk_snapshots_params.py +29 -0
  84. runloop_api_client/types/devbox_list_params.py +20 -0
  85. runloop_api_client/types/devbox_list_view.py +19 -0
  86. runloop_api_client/types/devbox_read_file_contents_params.py +15 -0
  87. runloop_api_client/types/devbox_read_file_contents_response.py +7 -0
  88. runloop_api_client/types/devbox_remove_tunnel_params.py +12 -0
  89. runloop_api_client/types/devbox_snapshot_disk_async_params.py +16 -0
  90. runloop_api_client/types/devbox_snapshot_disk_params.py +16 -0
  91. runloop_api_client/types/devbox_snapshot_list_view.py +19 -0
  92. runloop_api_client/types/devbox_snapshot_view.py +24 -0
  93. runloop_api_client/types/devbox_tunnel_view.py +16 -0
  94. runloop_api_client/types/devbox_update_params.py +16 -0
  95. runloop_api_client/types/devbox_upload_file_params.py +19 -0
  96. runloop_api_client/types/devbox_view.py +94 -0
  97. runloop_api_client/types/devbox_wait_for_command_params.py +25 -0
  98. runloop_api_client/types/devbox_write_file_contents_params.py +18 -0
  99. runloop_api_client/types/devboxes/__init__.py +32 -0
  100. runloop_api_client/types/devboxes/browser_create_params.py +13 -0
  101. runloop_api_client/types/devboxes/browser_view.py +25 -0
  102. runloop_api_client/types/devboxes/computer_create_params.py +24 -0
  103. runloop_api_client/types/devboxes/computer_keyboard_interaction_params.py +16 -0
  104. runloop_api_client/types/devboxes/computer_keyboard_interaction_response.py +15 -0
  105. runloop_api_client/types/devboxes/computer_mouse_interaction_params.py +30 -0
  106. runloop_api_client/types/devboxes/computer_mouse_interaction_response.py +15 -0
  107. runloop_api_client/types/devboxes/computer_screen_interaction_params.py +12 -0
  108. runloop_api_client/types/devboxes/computer_screen_interaction_response.py +15 -0
  109. runloop_api_client/types/devboxes/computer_view.py +19 -0
  110. runloop_api_client/types/devboxes/devbox_logs_list_view.py +39 -0
  111. runloop_api_client/types/devboxes/devbox_snapshot_async_status_view.py +20 -0
  112. runloop_api_client/types/devboxes/disk_snapshot_list_params.py +29 -0
  113. runloop_api_client/types/devboxes/disk_snapshot_update_params.py +16 -0
  114. runloop_api_client/types/devboxes/execution_execute_async_params.py +25 -0
  115. runloop_api_client/types/devboxes/execution_execute_sync_params.py +25 -0
  116. runloop_api_client/types/devboxes/execution_kill_params.py +18 -0
  117. runloop_api_client/types/devboxes/execution_retrieve_params.py +14 -0
  118. runloop_api_client/types/devboxes/execution_stream_stderr_updates_params.py +14 -0
  119. runloop_api_client/types/devboxes/execution_stream_stdout_updates_params.py +14 -0
  120. runloop_api_client/types/devboxes/execution_update_chunk.py +15 -0
  121. runloop_api_client/types/devboxes/log_list_params.py +15 -0
  122. runloop_api_client/types/input_context.py +15 -0
  123. runloop_api_client/types/input_context_param.py +16 -0
  124. runloop_api_client/types/input_context_update_param.py +16 -0
  125. runloop_api_client/types/object_create_params.py +19 -0
  126. runloop_api_client/types/object_download_params.py +12 -0
  127. runloop_api_client/types/object_download_url_view.py +10 -0
  128. runloop_api_client/types/object_list_params.py +27 -0
  129. runloop_api_client/types/object_list_public_params.py +27 -0
  130. runloop_api_client/types/object_list_view.py +22 -0
  131. runloop_api_client/types/object_view.py +28 -0
  132. runloop_api_client/types/repository_connection_list_view.py +19 -0
  133. runloop_api_client/types/repository_connection_view.py +16 -0
  134. runloop_api_client/types/repository_create_params.py +22 -0
  135. runloop_api_client/types/repository_inspection_details.py +77 -0
  136. runloop_api_client/types/repository_inspection_list_view.py +13 -0
  137. runloop_api_client/types/repository_list_params.py +21 -0
  138. runloop_api_client/types/repository_manifest_view.py +158 -0
  139. runloop_api_client/types/repository_refresh_params.py +16 -0
  140. runloop_api_client/types/scenario_create_params.py +53 -0
  141. runloop_api_client/types/scenario_definition_list_view.py +19 -0
  142. runloop_api_client/types/scenario_environment.py +25 -0
  143. runloop_api_client/types/scenario_environment_param.py +27 -0
  144. runloop_api_client/types/scenario_list_params.py +21 -0
  145. runloop_api_client/types/scenario_list_public_params.py +18 -0
  146. runloop_api_client/types/scenario_run_list_view.py +19 -0
  147. runloop_api_client/types/scenario_run_view.py +50 -0
  148. runloop_api_client/types/scenario_start_run_params.py +28 -0
  149. runloop_api_client/types/scenario_update_params.py +46 -0
  150. runloop_api_client/types/scenario_view.py +57 -0
  151. runloop_api_client/types/scenarios/__init__.py +14 -0
  152. runloop_api_client/types/scenarios/run_list_params.py +18 -0
  153. runloop_api_client/types/scenarios/scorer_create_params.py +18 -0
  154. runloop_api_client/types/scenarios/scorer_create_response.py +16 -0
  155. runloop_api_client/types/scenarios/scorer_list_params.py +15 -0
  156. runloop_api_client/types/scenarios/scorer_list_response.py +16 -0
  157. runloop_api_client/types/scenarios/scorer_retrieve_response.py +16 -0
  158. runloop_api_client/types/scenarios/scorer_update_params.py +18 -0
  159. runloop_api_client/types/scenarios/scorer_update_response.py +16 -0
  160. runloop_api_client/types/scenarios/scorer_validate_params.py +17 -0
  161. runloop_api_client/types/scenarios/scorer_validate_response.py +23 -0
  162. runloop_api_client/types/scoring_contract.py +13 -0
  163. runloop_api_client/types/scoring_contract_param.py +15 -0
  164. runloop_api_client/types/scoring_contract_result_view.py +16 -0
  165. runloop_api_client/types/scoring_contract_update_param.py +15 -0
  166. runloop_api_client/types/scoring_function.py +135 -0
  167. runloop_api_client/types/scoring_function_param.py +131 -0
  168. runloop_api_client/types/scoring_function_result_view.py +21 -0
  169. runloop_api_client/types/secret_create_params.py +23 -0
  170. runloop_api_client/types/secret_list_params.py +12 -0
  171. runloop_api_client/types/secret_list_view.py +22 -0
  172. runloop_api_client/types/secret_update_params.py +16 -0
  173. runloop_api_client/types/secret_view.py +22 -0
  174. runloop_api_client/types/shared/__init__.py +6 -0
  175. runloop_api_client/types/shared/after_idle.py +15 -0
  176. runloop_api_client/types/shared/code_mount_parameters.py +24 -0
  177. runloop_api_client/types/shared/launch_parameters.py +79 -0
  178. runloop_api_client/types/shared/run_profile.py +33 -0
  179. runloop_api_client/types/shared_params/__init__.py +6 -0
  180. runloop_api_client/types/shared_params/after_idle.py +15 -0
  181. runloop_api_client/types/shared_params/code_mount_parameters.py +25 -0
  182. runloop_api_client/types/shared_params/launch_parameters.py +81 -0
  183. runloop_api_client/types/shared_params/run_profile.py +34 -0
  184. runloop_api_client-0.61.0.dist-info/METADATA +496 -0
  185. runloop_api_client-0.61.0.dist-info/RECORD +187 -0
  186. runloop_api_client-0.61.0.dist-info/WHEEL +4 -0
  187. runloop_api_client-0.61.0.dist-info/licenses/LICENSE +7 -0
@@ -0,0 +1,1079 @@
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 Dict, Optional
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from .runs import (
11
+ RunsResource,
12
+ AsyncRunsResource,
13
+ RunsResourceWithRawResponse,
14
+ AsyncRunsResourceWithRawResponse,
15
+ RunsResourceWithStreamingResponse,
16
+ AsyncRunsResourceWithStreamingResponse,
17
+ )
18
+ from ...types import (
19
+ scenario_list_params,
20
+ scenario_create_params,
21
+ scenario_update_params,
22
+ scenario_start_run_params,
23
+ scenario_list_public_params,
24
+ )
25
+ from .scorers import (
26
+ ScorersResource,
27
+ AsyncScorersResource,
28
+ ScorersResourceWithRawResponse,
29
+ AsyncScorersResourceWithRawResponse,
30
+ ScorersResourceWithStreamingResponse,
31
+ AsyncScorersResourceWithStreamingResponse,
32
+ )
33
+ from ..._types import NOT_GIVEN, Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
34
+ from ..._utils import maybe_transform, async_maybe_transform
35
+ from ..._compat import cached_property
36
+ from ..._resource import SyncAPIResource, AsyncAPIResource
37
+ from ..._response import (
38
+ to_raw_response_wrapper,
39
+ to_streamed_response_wrapper,
40
+ async_to_raw_response_wrapper,
41
+ async_to_streamed_response_wrapper,
42
+ )
43
+ from ...pagination import SyncScenariosCursorIDPage, AsyncScenariosCursorIDPage
44
+ from ...lib.polling import PollingConfig
45
+ from ..._base_client import AsyncPaginator, make_request_options
46
+ from ...types.scenario_view import ScenarioView
47
+ from ...types.scenario_run_view import ScenarioRunView
48
+ from ...types.input_context_param import InputContextParam
49
+ from ...types.scoring_contract_param import ScoringContractParam
50
+ from ...types.shared_params.run_profile import RunProfile
51
+ from ...types.input_context_update_param import InputContextUpdateParam
52
+ from ...types.scenario_environment_param import ScenarioEnvironmentParam
53
+ from ...types.scoring_contract_update_param import ScoringContractUpdateParam
54
+
55
+ __all__ = ["ScenariosResource", "AsyncScenariosResource"]
56
+
57
+
58
+ class ScenariosResource(SyncAPIResource):
59
+ @cached_property
60
+ def runs(self) -> RunsResource:
61
+ return RunsResource(self._client)
62
+
63
+ @cached_property
64
+ def scorers(self) -> ScorersResource:
65
+ return ScorersResource(self._client)
66
+
67
+ @cached_property
68
+ def with_raw_response(self) -> ScenariosResourceWithRawResponse:
69
+ """
70
+ This property can be used as a prefix for any HTTP method call to return
71
+ the raw response object instead of the parsed content.
72
+
73
+ For more information, see https://www.github.com/runloopai/api-client-python#accessing-raw-response-data-eg-headers
74
+ """
75
+ return ScenariosResourceWithRawResponse(self)
76
+
77
+ @cached_property
78
+ def with_streaming_response(self) -> ScenariosResourceWithStreamingResponse:
79
+ """
80
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
81
+
82
+ For more information, see https://www.github.com/runloopai/api-client-python#with_streaming_response
83
+ """
84
+ return ScenariosResourceWithStreamingResponse(self)
85
+
86
+ def create(
87
+ self,
88
+ *,
89
+ input_context: InputContextParam,
90
+ name: str,
91
+ scoring_contract: ScoringContractParam,
92
+ environment_parameters: Optional[ScenarioEnvironmentParam] | Omit = omit,
93
+ metadata: Optional[Dict[str, str]] | Omit = omit,
94
+ reference_output: Optional[str] | Omit = omit,
95
+ required_environment_variables: Optional[SequenceNotStr[str]] | Omit = omit,
96
+ required_secret_names: Optional[SequenceNotStr[str]] | Omit = omit,
97
+ validation_type: Optional[Literal["UNSPECIFIED", "FORWARD", "REVERSE", "EVALUATION"]] | Omit = omit,
98
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
99
+ # The extra values given here take precedence over values defined on the client or passed to this method.
100
+ extra_headers: Headers | None = None,
101
+ extra_query: Query | None = None,
102
+ extra_body: Body | None = None,
103
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
104
+ idempotency_key: str | None = None,
105
+ ) -> ScenarioView:
106
+ """
107
+ Create a Scenario, a repeatable AI coding evaluation test that defines the
108
+ starting environment as well as evaluation success criteria.
109
+
110
+ Args:
111
+ input_context: The input context for the Scenario.
112
+
113
+ name: Name of the scenario.
114
+
115
+ scoring_contract: The scoring contract for the Scenario.
116
+
117
+ environment_parameters: The Environment in which the Scenario will run.
118
+
119
+ metadata: User defined metadata to attach to the scenario for organization.
120
+
121
+ reference_output: A string representation of the reference output to solve the scenario. Commonly
122
+ can be the result of a git diff or a sequence of command actions to apply to the
123
+ environment.
124
+
125
+ required_environment_variables: Environment variables required to run the scenario. If these variables are not
126
+ provided, the scenario will fail to start.
127
+
128
+ required_secret_names: Secrets required to run the scenario (user secret name to scenario required
129
+ secret name). If these secrets are not provided or the mapping is incorrect, the
130
+ scenario will fail to start.
131
+
132
+ validation_type: Validation strategy.
133
+
134
+ extra_headers: Send extra headers
135
+
136
+ extra_query: Add additional query parameters to the request
137
+
138
+ extra_body: Add additional JSON properties to the request
139
+
140
+ timeout: Override the client-level default timeout for this request, in seconds
141
+
142
+ idempotency_key: Specify a custom idempotency key for this request
143
+ """
144
+ return self._post(
145
+ "/v1/scenarios",
146
+ body=maybe_transform(
147
+ {
148
+ "input_context": input_context,
149
+ "name": name,
150
+ "scoring_contract": scoring_contract,
151
+ "environment_parameters": environment_parameters,
152
+ "metadata": metadata,
153
+ "reference_output": reference_output,
154
+ "required_environment_variables": required_environment_variables,
155
+ "required_secret_names": required_secret_names,
156
+ "validation_type": validation_type,
157
+ },
158
+ scenario_create_params.ScenarioCreateParams,
159
+ ),
160
+ options=make_request_options(
161
+ extra_headers=extra_headers,
162
+ extra_query=extra_query,
163
+ extra_body=extra_body,
164
+ timeout=timeout,
165
+ idempotency_key=idempotency_key,
166
+ ),
167
+ cast_to=ScenarioView,
168
+ )
169
+
170
+ def retrieve(
171
+ self,
172
+ id: str,
173
+ *,
174
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
175
+ # The extra values given here take precedence over values defined on the client or passed to this method.
176
+ extra_headers: Headers | None = None,
177
+ extra_query: Query | None = None,
178
+ extra_body: Body | None = None,
179
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
180
+ ) -> ScenarioView:
181
+ """
182
+ Get a previously created scenario.
183
+
184
+ Args:
185
+ extra_headers: Send extra headers
186
+
187
+ extra_query: Add additional query parameters to the request
188
+
189
+ extra_body: Add additional JSON properties to the request
190
+
191
+ timeout: Override the client-level default timeout for this request, in seconds
192
+ """
193
+ if not id:
194
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
195
+ return self._get(
196
+ f"/v1/scenarios/{id}",
197
+ options=make_request_options(
198
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
199
+ ),
200
+ cast_to=ScenarioView,
201
+ )
202
+
203
+ def update(
204
+ self,
205
+ id: str,
206
+ *,
207
+ environment_parameters: Optional[ScenarioEnvironmentParam] | Omit = omit,
208
+ input_context: Optional[InputContextUpdateParam] | Omit = omit,
209
+ metadata: Optional[Dict[str, str]] | Omit = omit,
210
+ name: Optional[str] | Omit = omit,
211
+ reference_output: Optional[str] | Omit = omit,
212
+ required_environment_variables: Optional[SequenceNotStr[str]] | Omit = omit,
213
+ required_secret_names: Optional[SequenceNotStr[str]] | Omit = omit,
214
+ scoring_contract: Optional[ScoringContractUpdateParam] | Omit = omit,
215
+ validation_type: Optional[Literal["UNSPECIFIED", "FORWARD", "REVERSE", "EVALUATION"]] | Omit = omit,
216
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
217
+ # The extra values given here take precedence over values defined on the client or passed to this method.
218
+ extra_headers: Headers | None = None,
219
+ extra_query: Query | None = None,
220
+ extra_body: Body | None = None,
221
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
222
+ idempotency_key: str | None = None,
223
+ ) -> ScenarioView:
224
+ """
225
+ Update a Scenario, a repeatable AI coding evaluation test that defines the
226
+ starting environment as well as evaluation success criteria. Only provided
227
+ fields will be updated.
228
+
229
+ Args:
230
+ environment_parameters: The Environment in which the Scenario will run.
231
+
232
+ input_context: The input context for the Scenario.
233
+
234
+ metadata: User defined metadata to attach to the scenario for organization.
235
+
236
+ name: Name of the scenario.
237
+
238
+ reference_output: A string representation of the reference output to solve the scenario. Commonly
239
+ can be the result of a git diff or a sequence of command actions to apply to the
240
+ environment.
241
+
242
+ required_environment_variables: Environment variables required to run the scenario.
243
+
244
+ required_secret_names: Secrets required to run the scenario.
245
+
246
+ scoring_contract: The scoring contract for the Scenario.
247
+
248
+ validation_type: Validation strategy.
249
+
250
+ extra_headers: Send extra headers
251
+
252
+ extra_query: Add additional query parameters to the request
253
+
254
+ extra_body: Add additional JSON properties to the request
255
+
256
+ timeout: Override the client-level default timeout for this request, in seconds
257
+
258
+ idempotency_key: Specify a custom idempotency key for this request
259
+ """
260
+ if not id:
261
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
262
+ return self._post(
263
+ f"/v1/scenarios/{id}",
264
+ body=maybe_transform(
265
+ {
266
+ "environment_parameters": environment_parameters,
267
+ "input_context": input_context,
268
+ "metadata": metadata,
269
+ "name": name,
270
+ "reference_output": reference_output,
271
+ "required_environment_variables": required_environment_variables,
272
+ "required_secret_names": required_secret_names,
273
+ "scoring_contract": scoring_contract,
274
+ "validation_type": validation_type,
275
+ },
276
+ scenario_update_params.ScenarioUpdateParams,
277
+ ),
278
+ options=make_request_options(
279
+ extra_headers=extra_headers,
280
+ extra_query=extra_query,
281
+ extra_body=extra_body,
282
+ timeout=timeout,
283
+ idempotency_key=idempotency_key,
284
+ ),
285
+ cast_to=ScenarioView,
286
+ )
287
+
288
+ def list(
289
+ self,
290
+ *,
291
+ benchmark_id: str | Omit = omit,
292
+ limit: int | Omit = omit,
293
+ name: str | Omit = omit,
294
+ starting_after: str | Omit = omit,
295
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
296
+ # The extra values given here take precedence over values defined on the client or passed to this method.
297
+ extra_headers: Headers | None = None,
298
+ extra_query: Query | None = None,
299
+ extra_body: Body | None = None,
300
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
301
+ ) -> SyncScenariosCursorIDPage[ScenarioView]:
302
+ """
303
+ List all Scenarios matching filter.
304
+
305
+ Args:
306
+ benchmark_id: Filter scenarios by benchmark ID.
307
+
308
+ limit: The limit of items to return. Default is 20.
309
+
310
+ name: Query for Scenarios with a given name.
311
+
312
+ starting_after: Load the next page of data starting after the item with the given ID.
313
+
314
+ extra_headers: Send extra headers
315
+
316
+ extra_query: Add additional query parameters to the request
317
+
318
+ extra_body: Add additional JSON properties to the request
319
+
320
+ timeout: Override the client-level default timeout for this request, in seconds
321
+ """
322
+ return self._get_api_list(
323
+ "/v1/scenarios",
324
+ page=SyncScenariosCursorIDPage[ScenarioView],
325
+ options=make_request_options(
326
+ extra_headers=extra_headers,
327
+ extra_query=extra_query,
328
+ extra_body=extra_body,
329
+ timeout=timeout,
330
+ query=maybe_transform(
331
+ {
332
+ "benchmark_id": benchmark_id,
333
+ "limit": limit,
334
+ "name": name,
335
+ "starting_after": starting_after,
336
+ },
337
+ scenario_list_params.ScenarioListParams,
338
+ ),
339
+ ),
340
+ model=ScenarioView,
341
+ )
342
+
343
+ def list_public(
344
+ self,
345
+ *,
346
+ limit: int | Omit = omit,
347
+ name: str | Omit = omit,
348
+ starting_after: str | Omit = omit,
349
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
350
+ # The extra values given here take precedence over values defined on the client or passed to this method.
351
+ extra_headers: Headers | None = None,
352
+ extra_query: Query | None = None,
353
+ extra_body: Body | None = None,
354
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
355
+ ) -> SyncScenariosCursorIDPage[ScenarioView]:
356
+ """
357
+ List all public scenarios matching filter.
358
+
359
+ Args:
360
+ limit: The limit of items to return. Default is 20.
361
+
362
+ name: Query for Scenarios with a given name.
363
+
364
+ starting_after: Load the next page of data starting after the item with the given ID.
365
+
366
+ extra_headers: Send extra headers
367
+
368
+ extra_query: Add additional query parameters to the request
369
+
370
+ extra_body: Add additional JSON properties to the request
371
+
372
+ timeout: Override the client-level default timeout for this request, in seconds
373
+ """
374
+ return self._get_api_list(
375
+ "/v1/scenarios/list_public",
376
+ page=SyncScenariosCursorIDPage[ScenarioView],
377
+ options=make_request_options(
378
+ extra_headers=extra_headers,
379
+ extra_query=extra_query,
380
+ extra_body=extra_body,
381
+ timeout=timeout,
382
+ query=maybe_transform(
383
+ {
384
+ "limit": limit,
385
+ "name": name,
386
+ "starting_after": starting_after,
387
+ },
388
+ scenario_list_public_params.ScenarioListPublicParams,
389
+ ),
390
+ ),
391
+ model=ScenarioView,
392
+ )
393
+
394
+ def start_run(
395
+ self,
396
+ *,
397
+ scenario_id: str,
398
+ benchmark_run_id: Optional[str] | Omit = omit,
399
+ metadata: Optional[Dict[str, str]] | Omit = omit,
400
+ run_name: Optional[str] | Omit = omit,
401
+ run_profile: Optional[RunProfile] | Omit = omit,
402
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
403
+ # The extra values given here take precedence over values defined on the client or passed to this method.
404
+ extra_headers: Headers | None = None,
405
+ extra_query: Query | None = None,
406
+ extra_body: Body | None = None,
407
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
408
+ idempotency_key: str | None = None,
409
+ ) -> ScenarioRunView:
410
+ """
411
+ Start a new ScenarioRun based on the provided Scenario.
412
+
413
+ Args:
414
+ scenario_id: ID of the Scenario to run.
415
+
416
+ benchmark_run_id: Benchmark to associate the run.
417
+
418
+ metadata: User defined metadata to attach to the run for organization.
419
+
420
+ run_name: Display name of the run.
421
+
422
+ run_profile: Runtime configuration to use for this benchmark run
423
+
424
+ extra_headers: Send extra headers
425
+
426
+ extra_query: Add additional query parameters to the request
427
+
428
+ extra_body: Add additional JSON properties to the request
429
+
430
+ timeout: Override the client-level default timeout for this request, in seconds
431
+
432
+ idempotency_key: Specify a custom idempotency key for this request
433
+ """
434
+ return self._post(
435
+ "/v1/scenarios/start_run",
436
+ body=maybe_transform(
437
+ {
438
+ "scenario_id": scenario_id,
439
+ "benchmark_run_id": benchmark_run_id,
440
+ "metadata": metadata,
441
+ "run_name": run_name,
442
+ "run_profile": run_profile,
443
+ },
444
+ scenario_start_run_params.ScenarioStartRunParams,
445
+ ),
446
+ options=make_request_options(
447
+ extra_headers=extra_headers,
448
+ extra_query=extra_query,
449
+ extra_body=extra_body,
450
+ timeout=timeout,
451
+ idempotency_key=idempotency_key,
452
+ ),
453
+ cast_to=ScenarioRunView,
454
+ )
455
+
456
+ def start_run_and_await_env_ready(
457
+ self,
458
+ *,
459
+ scenario_id: str,
460
+ benchmark_run_id: Optional[str] | NotGiven = NOT_GIVEN,
461
+ metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
462
+ run_name: Optional[str] | NotGiven = NOT_GIVEN,
463
+ run_profile: Optional[scenario_start_run_params.RunProfile] | NotGiven = NOT_GIVEN,
464
+ polling_config: PollingConfig | None = None,
465
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
466
+ # The extra values given here take precedence over values defined on the client or passed to this method.
467
+ extra_headers: Headers | None = None,
468
+ extra_query: Query | None = None,
469
+ extra_body: Body | None = None,
470
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
471
+ idempotency_key: str | None = None,
472
+ ) -> ScenarioRunView:
473
+ """Start a new ScenarioRun and wait for its environment to be ready.
474
+
475
+ Args:
476
+ scenario_id: ID of the Scenario to run
477
+ benchmark_run_id: Benchmark to associate the run
478
+ run_name: Display name of the run
479
+ run_profile: Runtime configuration to use for this benchmark run
480
+ polling_config: Optional polling configuration
481
+ extra_headers: Send extra headers
482
+ extra_query: Add additional query parameters to the request
483
+ extra_body: Add additional JSON properties to the request
484
+ timeout: Override the client-level default timeout for this request, in seconds
485
+ idempotency_key: Specify a custom idempotency key for this request
486
+
487
+ Returns:
488
+ The scenario run in running state
489
+
490
+ Raises:
491
+ PollingTimeout: If polling times out before environment is ready
492
+ RunloopError: If environment enters a non-running terminal state
493
+ """
494
+ run = self.start_run(
495
+ scenario_id=scenario_id,
496
+ benchmark_run_id=benchmark_run_id,
497
+ metadata=metadata,
498
+ run_name=run_name,
499
+ run_profile=run_profile,
500
+ extra_headers=extra_headers,
501
+ extra_query=extra_query,
502
+ extra_body=extra_body,
503
+ timeout=timeout,
504
+ idempotency_key=idempotency_key,
505
+ )
506
+
507
+ self._client.devboxes.await_running(
508
+ run.devbox_id,
509
+ polling_config=polling_config,
510
+ )
511
+
512
+ return run
513
+
514
+
515
+ class AsyncScenariosResource(AsyncAPIResource):
516
+ @cached_property
517
+ def runs(self) -> AsyncRunsResource:
518
+ return AsyncRunsResource(self._client)
519
+
520
+ @cached_property
521
+ def scorers(self) -> AsyncScorersResource:
522
+ return AsyncScorersResource(self._client)
523
+
524
+ @cached_property
525
+ def with_raw_response(self) -> AsyncScenariosResourceWithRawResponse:
526
+ """
527
+ This property can be used as a prefix for any HTTP method call to return
528
+ the raw response object instead of the parsed content.
529
+
530
+ For more information, see https://www.github.com/runloopai/api-client-python#accessing-raw-response-data-eg-headers
531
+ """
532
+ return AsyncScenariosResourceWithRawResponse(self)
533
+
534
+ @cached_property
535
+ def with_streaming_response(self) -> AsyncScenariosResourceWithStreamingResponse:
536
+ """
537
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
538
+
539
+ For more information, see https://www.github.com/runloopai/api-client-python#with_streaming_response
540
+ """
541
+ return AsyncScenariosResourceWithStreamingResponse(self)
542
+
543
+ async def create(
544
+ self,
545
+ *,
546
+ input_context: InputContextParam,
547
+ name: str,
548
+ scoring_contract: ScoringContractParam,
549
+ environment_parameters: Optional[ScenarioEnvironmentParam] | Omit = omit,
550
+ metadata: Optional[Dict[str, str]] | Omit = omit,
551
+ reference_output: Optional[str] | Omit = omit,
552
+ required_environment_variables: Optional[SequenceNotStr[str]] | Omit = omit,
553
+ required_secret_names: Optional[SequenceNotStr[str]] | Omit = omit,
554
+ validation_type: Optional[Literal["UNSPECIFIED", "FORWARD", "REVERSE", "EVALUATION"]] | Omit = omit,
555
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
556
+ # The extra values given here take precedence over values defined on the client or passed to this method.
557
+ extra_headers: Headers | None = None,
558
+ extra_query: Query | None = None,
559
+ extra_body: Body | None = None,
560
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
561
+ idempotency_key: str | None = None,
562
+ ) -> ScenarioView:
563
+ """
564
+ Create a Scenario, a repeatable AI coding evaluation test that defines the
565
+ starting environment as well as evaluation success criteria.
566
+
567
+ Args:
568
+ input_context: The input context for the Scenario.
569
+
570
+ name: Name of the scenario.
571
+
572
+ scoring_contract: The scoring contract for the Scenario.
573
+
574
+ environment_parameters: The Environment in which the Scenario will run.
575
+
576
+ metadata: User defined metadata to attach to the scenario for organization.
577
+
578
+ reference_output: A string representation of the reference output to solve the scenario. Commonly
579
+ can be the result of a git diff or a sequence of command actions to apply to the
580
+ environment.
581
+
582
+ required_environment_variables: Environment variables required to run the scenario. If these variables are not
583
+ provided, the scenario will fail to start.
584
+
585
+ required_secret_names: Secrets required to run the scenario (user secret name to scenario required
586
+ secret name). If these secrets are not provided or the mapping is incorrect, the
587
+ scenario will fail to start.
588
+
589
+ validation_type: Validation strategy.
590
+
591
+ extra_headers: Send extra headers
592
+
593
+ extra_query: Add additional query parameters to the request
594
+
595
+ extra_body: Add additional JSON properties to the request
596
+
597
+ timeout: Override the client-level default timeout for this request, in seconds
598
+
599
+ idempotency_key: Specify a custom idempotency key for this request
600
+ """
601
+ return await self._post(
602
+ "/v1/scenarios",
603
+ body=await async_maybe_transform(
604
+ {
605
+ "input_context": input_context,
606
+ "name": name,
607
+ "scoring_contract": scoring_contract,
608
+ "environment_parameters": environment_parameters,
609
+ "metadata": metadata,
610
+ "reference_output": reference_output,
611
+ "required_environment_variables": required_environment_variables,
612
+ "required_secret_names": required_secret_names,
613
+ "validation_type": validation_type,
614
+ },
615
+ scenario_create_params.ScenarioCreateParams,
616
+ ),
617
+ options=make_request_options(
618
+ extra_headers=extra_headers,
619
+ extra_query=extra_query,
620
+ extra_body=extra_body,
621
+ timeout=timeout,
622
+ idempotency_key=idempotency_key,
623
+ ),
624
+ cast_to=ScenarioView,
625
+ )
626
+
627
+ async def retrieve(
628
+ self,
629
+ id: str,
630
+ *,
631
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
632
+ # The extra values given here take precedence over values defined on the client or passed to this method.
633
+ extra_headers: Headers | None = None,
634
+ extra_query: Query | None = None,
635
+ extra_body: Body | None = None,
636
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
637
+ ) -> ScenarioView:
638
+ """
639
+ Get a previously created scenario.
640
+
641
+ Args:
642
+ extra_headers: Send extra headers
643
+
644
+ extra_query: Add additional query parameters to the request
645
+
646
+ extra_body: Add additional JSON properties to the request
647
+
648
+ timeout: Override the client-level default timeout for this request, in seconds
649
+ """
650
+ if not id:
651
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
652
+ return await self._get(
653
+ f"/v1/scenarios/{id}",
654
+ options=make_request_options(
655
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
656
+ ),
657
+ cast_to=ScenarioView,
658
+ )
659
+
660
+ async def update(
661
+ self,
662
+ id: str,
663
+ *,
664
+ environment_parameters: Optional[ScenarioEnvironmentParam] | Omit = omit,
665
+ input_context: Optional[InputContextUpdateParam] | Omit = omit,
666
+ metadata: Optional[Dict[str, str]] | Omit = omit,
667
+ name: Optional[str] | Omit = omit,
668
+ reference_output: Optional[str] | Omit = omit,
669
+ required_environment_variables: Optional[SequenceNotStr[str]] | Omit = omit,
670
+ required_secret_names: Optional[SequenceNotStr[str]] | Omit = omit,
671
+ scoring_contract: Optional[ScoringContractUpdateParam] | Omit = omit,
672
+ validation_type: Optional[Literal["UNSPECIFIED", "FORWARD", "REVERSE", "EVALUATION"]] | Omit = omit,
673
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
674
+ # The extra values given here take precedence over values defined on the client or passed to this method.
675
+ extra_headers: Headers | None = None,
676
+ extra_query: Query | None = None,
677
+ extra_body: Body | None = None,
678
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
679
+ idempotency_key: str | None = None,
680
+ ) -> ScenarioView:
681
+ """
682
+ Update a Scenario, a repeatable AI coding evaluation test that defines the
683
+ starting environment as well as evaluation success criteria. Only provided
684
+ fields will be updated.
685
+
686
+ Args:
687
+ environment_parameters: The Environment in which the Scenario will run.
688
+
689
+ input_context: The input context for the Scenario.
690
+
691
+ metadata: User defined metadata to attach to the scenario for organization.
692
+
693
+ name: Name of the scenario.
694
+
695
+ reference_output: A string representation of the reference output to solve the scenario. Commonly
696
+ can be the result of a git diff or a sequence of command actions to apply to the
697
+ environment.
698
+
699
+ required_environment_variables: Environment variables required to run the scenario.
700
+
701
+ required_secret_names: Secrets required to run the scenario.
702
+
703
+ scoring_contract: The scoring contract for the Scenario.
704
+
705
+ validation_type: Validation strategy.
706
+
707
+ extra_headers: Send extra headers
708
+
709
+ extra_query: Add additional query parameters to the request
710
+
711
+ extra_body: Add additional JSON properties to the request
712
+
713
+ timeout: Override the client-level default timeout for this request, in seconds
714
+
715
+ idempotency_key: Specify a custom idempotency key for this request
716
+ """
717
+ if not id:
718
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
719
+ return await self._post(
720
+ f"/v1/scenarios/{id}",
721
+ body=await async_maybe_transform(
722
+ {
723
+ "environment_parameters": environment_parameters,
724
+ "input_context": input_context,
725
+ "metadata": metadata,
726
+ "name": name,
727
+ "reference_output": reference_output,
728
+ "required_environment_variables": required_environment_variables,
729
+ "required_secret_names": required_secret_names,
730
+ "scoring_contract": scoring_contract,
731
+ "validation_type": validation_type,
732
+ },
733
+ scenario_update_params.ScenarioUpdateParams,
734
+ ),
735
+ options=make_request_options(
736
+ extra_headers=extra_headers,
737
+ extra_query=extra_query,
738
+ extra_body=extra_body,
739
+ timeout=timeout,
740
+ idempotency_key=idempotency_key,
741
+ ),
742
+ cast_to=ScenarioView,
743
+ )
744
+
745
+ def list(
746
+ self,
747
+ *,
748
+ benchmark_id: str | Omit = omit,
749
+ limit: int | Omit = omit,
750
+ name: str | Omit = omit,
751
+ starting_after: str | Omit = omit,
752
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
753
+ # The extra values given here take precedence over values defined on the client or passed to this method.
754
+ extra_headers: Headers | None = None,
755
+ extra_query: Query | None = None,
756
+ extra_body: Body | None = None,
757
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
758
+ ) -> AsyncPaginator[ScenarioView, AsyncScenariosCursorIDPage[ScenarioView]]:
759
+ """
760
+ List all Scenarios matching filter.
761
+
762
+ Args:
763
+ benchmark_id: Filter scenarios by benchmark ID.
764
+
765
+ limit: The limit of items to return. Default is 20.
766
+
767
+ name: Query for Scenarios with a given name.
768
+
769
+ starting_after: Load the next page of data starting after the item with the given ID.
770
+
771
+ extra_headers: Send extra headers
772
+
773
+ extra_query: Add additional query parameters to the request
774
+
775
+ extra_body: Add additional JSON properties to the request
776
+
777
+ timeout: Override the client-level default timeout for this request, in seconds
778
+ """
779
+ return self._get_api_list(
780
+ "/v1/scenarios",
781
+ page=AsyncScenariosCursorIDPage[ScenarioView],
782
+ options=make_request_options(
783
+ extra_headers=extra_headers,
784
+ extra_query=extra_query,
785
+ extra_body=extra_body,
786
+ timeout=timeout,
787
+ query=maybe_transform(
788
+ {
789
+ "benchmark_id": benchmark_id,
790
+ "limit": limit,
791
+ "name": name,
792
+ "starting_after": starting_after,
793
+ },
794
+ scenario_list_params.ScenarioListParams,
795
+ ),
796
+ ),
797
+ model=ScenarioView,
798
+ )
799
+
800
+ def list_public(
801
+ self,
802
+ *,
803
+ limit: int | Omit = omit,
804
+ name: str | Omit = omit,
805
+ starting_after: str | Omit = omit,
806
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
807
+ # The extra values given here take precedence over values defined on the client or passed to this method.
808
+ extra_headers: Headers | None = None,
809
+ extra_query: Query | None = None,
810
+ extra_body: Body | None = None,
811
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
812
+ ) -> AsyncPaginator[ScenarioView, AsyncScenariosCursorIDPage[ScenarioView]]:
813
+ """
814
+ List all public scenarios matching filter.
815
+
816
+ Args:
817
+ limit: The limit of items to return. Default is 20.
818
+
819
+ name: Query for Scenarios with a given name.
820
+
821
+ starting_after: Load the next page of data starting after the item with the given ID.
822
+
823
+ extra_headers: Send extra headers
824
+
825
+ extra_query: Add additional query parameters to the request
826
+
827
+ extra_body: Add additional JSON properties to the request
828
+
829
+ timeout: Override the client-level default timeout for this request, in seconds
830
+ """
831
+ return self._get_api_list(
832
+ "/v1/scenarios/list_public",
833
+ page=AsyncScenariosCursorIDPage[ScenarioView],
834
+ options=make_request_options(
835
+ extra_headers=extra_headers,
836
+ extra_query=extra_query,
837
+ extra_body=extra_body,
838
+ timeout=timeout,
839
+ query=maybe_transform(
840
+ {
841
+ "limit": limit,
842
+ "name": name,
843
+ "starting_after": starting_after,
844
+ },
845
+ scenario_list_public_params.ScenarioListPublicParams,
846
+ ),
847
+ ),
848
+ model=ScenarioView,
849
+ )
850
+
851
+ async def start_run(
852
+ self,
853
+ *,
854
+ scenario_id: str,
855
+ benchmark_run_id: Optional[str] | Omit = omit,
856
+ metadata: Optional[Dict[str, str]] | Omit = omit,
857
+ run_name: Optional[str] | Omit = omit,
858
+ run_profile: Optional[RunProfile] | Omit = omit,
859
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
860
+ # The extra values given here take precedence over values defined on the client or passed to this method.
861
+ extra_headers: Headers | None = None,
862
+ extra_query: Query | None = None,
863
+ extra_body: Body | None = None,
864
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
865
+ idempotency_key: str | None = None,
866
+ ) -> ScenarioRunView:
867
+ """
868
+ Start a new ScenarioRun based on the provided Scenario.
869
+
870
+ Args:
871
+ scenario_id: ID of the Scenario to run.
872
+
873
+ benchmark_run_id: Benchmark to associate the run.
874
+
875
+ metadata: User defined metadata to attach to the run for organization.
876
+
877
+ run_name: Display name of the run.
878
+
879
+ run_profile: Runtime configuration to use for this benchmark run
880
+
881
+ extra_headers: Send extra headers
882
+
883
+ extra_query: Add additional query parameters to the request
884
+
885
+ extra_body: Add additional JSON properties to the request
886
+
887
+ timeout: Override the client-level default timeout for this request, in seconds
888
+
889
+ idempotency_key: Specify a custom idempotency key for this request
890
+ """
891
+ return await self._post(
892
+ "/v1/scenarios/start_run",
893
+ body=await async_maybe_transform(
894
+ {
895
+ "scenario_id": scenario_id,
896
+ "benchmark_run_id": benchmark_run_id,
897
+ "metadata": metadata,
898
+ "run_name": run_name,
899
+ "run_profile": run_profile,
900
+ },
901
+ scenario_start_run_params.ScenarioStartRunParams,
902
+ ),
903
+ options=make_request_options(
904
+ extra_headers=extra_headers,
905
+ extra_query=extra_query,
906
+ extra_body=extra_body,
907
+ timeout=timeout,
908
+ idempotency_key=idempotency_key,
909
+ ),
910
+ cast_to=ScenarioRunView,
911
+ )
912
+
913
+ async def start_run_and_await_env_ready(
914
+ self,
915
+ scenario_id: str,
916
+ benchmark_run_id: Optional[str] | NotGiven = NOT_GIVEN,
917
+ metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
918
+ run_name: Optional[str] | NotGiven = NOT_GIVEN,
919
+ run_profile: Optional[scenario_start_run_params.RunProfile] | NotGiven = NOT_GIVEN,
920
+ polling_config: PollingConfig | None = None,
921
+ ) -> ScenarioRunView:
922
+ """Start a new ScenarioRun and wait for its environment to be ready.
923
+
924
+ Args:
925
+ scenario_id: ID of the Scenario to run
926
+ benchmark_run_id: Benchmark to associate the run
927
+ run_name: Display name of the run
928
+ run_profile: Runtime configuration to use for this benchmark run
929
+ polling_config: Optional polling configuration
930
+
931
+ Returns:
932
+ The scenario run in running state
933
+
934
+ Raises:
935
+ PollingTimeout: If polling times out before environment is ready
936
+ RunloopError: If environment enters a non-running terminal state
937
+ """
938
+ run = await self.start_run(
939
+ scenario_id=scenario_id,
940
+ benchmark_run_id=benchmark_run_id,
941
+ metadata=metadata,
942
+ run_name=run_name,
943
+ run_profile=run_profile,
944
+ )
945
+
946
+ await self._client.devboxes.await_running(
947
+ run.devbox_id,
948
+ polling_config=polling_config,
949
+ )
950
+
951
+ return run
952
+
953
+
954
+ class ScenariosResourceWithRawResponse:
955
+ def __init__(self, scenarios: ScenariosResource) -> None:
956
+ self._scenarios = scenarios
957
+
958
+ self.create = to_raw_response_wrapper(
959
+ scenarios.create,
960
+ )
961
+ self.retrieve = to_raw_response_wrapper(
962
+ scenarios.retrieve,
963
+ )
964
+ self.update = to_raw_response_wrapper(
965
+ scenarios.update,
966
+ )
967
+ self.list = to_raw_response_wrapper(
968
+ scenarios.list,
969
+ )
970
+ self.list_public = to_raw_response_wrapper(
971
+ scenarios.list_public,
972
+ )
973
+ self.start_run = to_raw_response_wrapper(
974
+ scenarios.start_run,
975
+ )
976
+
977
+ @cached_property
978
+ def runs(self) -> RunsResourceWithRawResponse:
979
+ return RunsResourceWithRawResponse(self._scenarios.runs)
980
+
981
+ @cached_property
982
+ def scorers(self) -> ScorersResourceWithRawResponse:
983
+ return ScorersResourceWithRawResponse(self._scenarios.scorers)
984
+
985
+
986
+ class AsyncScenariosResourceWithRawResponse:
987
+ def __init__(self, scenarios: AsyncScenariosResource) -> None:
988
+ self._scenarios = scenarios
989
+
990
+ self.create = async_to_raw_response_wrapper(
991
+ scenarios.create,
992
+ )
993
+ self.retrieve = async_to_raw_response_wrapper(
994
+ scenarios.retrieve,
995
+ )
996
+ self.update = async_to_raw_response_wrapper(
997
+ scenarios.update,
998
+ )
999
+ self.list = async_to_raw_response_wrapper(
1000
+ scenarios.list,
1001
+ )
1002
+ self.list_public = async_to_raw_response_wrapper(
1003
+ scenarios.list_public,
1004
+ )
1005
+ self.start_run = async_to_raw_response_wrapper(
1006
+ scenarios.start_run,
1007
+ )
1008
+
1009
+ @cached_property
1010
+ def runs(self) -> AsyncRunsResourceWithRawResponse:
1011
+ return AsyncRunsResourceWithRawResponse(self._scenarios.runs)
1012
+
1013
+ @cached_property
1014
+ def scorers(self) -> AsyncScorersResourceWithRawResponse:
1015
+ return AsyncScorersResourceWithRawResponse(self._scenarios.scorers)
1016
+
1017
+
1018
+ class ScenariosResourceWithStreamingResponse:
1019
+ def __init__(self, scenarios: ScenariosResource) -> None:
1020
+ self._scenarios = scenarios
1021
+
1022
+ self.create = to_streamed_response_wrapper(
1023
+ scenarios.create,
1024
+ )
1025
+ self.retrieve = to_streamed_response_wrapper(
1026
+ scenarios.retrieve,
1027
+ )
1028
+ self.update = to_streamed_response_wrapper(
1029
+ scenarios.update,
1030
+ )
1031
+ self.list = to_streamed_response_wrapper(
1032
+ scenarios.list,
1033
+ )
1034
+ self.list_public = to_streamed_response_wrapper(
1035
+ scenarios.list_public,
1036
+ )
1037
+ self.start_run = to_streamed_response_wrapper(
1038
+ scenarios.start_run,
1039
+ )
1040
+
1041
+ @cached_property
1042
+ def runs(self) -> RunsResourceWithStreamingResponse:
1043
+ return RunsResourceWithStreamingResponse(self._scenarios.runs)
1044
+
1045
+ @cached_property
1046
+ def scorers(self) -> ScorersResourceWithStreamingResponse:
1047
+ return ScorersResourceWithStreamingResponse(self._scenarios.scorers)
1048
+
1049
+
1050
+ class AsyncScenariosResourceWithStreamingResponse:
1051
+ def __init__(self, scenarios: AsyncScenariosResource) -> None:
1052
+ self._scenarios = scenarios
1053
+
1054
+ self.create = async_to_streamed_response_wrapper(
1055
+ scenarios.create,
1056
+ )
1057
+ self.retrieve = async_to_streamed_response_wrapper(
1058
+ scenarios.retrieve,
1059
+ )
1060
+ self.update = async_to_streamed_response_wrapper(
1061
+ scenarios.update,
1062
+ )
1063
+ self.list = async_to_streamed_response_wrapper(
1064
+ scenarios.list,
1065
+ )
1066
+ self.list_public = async_to_streamed_response_wrapper(
1067
+ scenarios.list_public,
1068
+ )
1069
+ self.start_run = async_to_streamed_response_wrapper(
1070
+ scenarios.start_run,
1071
+ )
1072
+
1073
+ @cached_property
1074
+ def runs(self) -> AsyncRunsResourceWithStreamingResponse:
1075
+ return AsyncRunsResourceWithStreamingResponse(self._scenarios.runs)
1076
+
1077
+ @cached_property
1078
+ def scorers(self) -> AsyncScorersResourceWithStreamingResponse:
1079
+ return AsyncScorersResourceWithStreamingResponse(self._scenarios.scorers)