Skip to content

Commit 208192c

Browse files
feat(closes OPEN-8532): expose 'tests/{id}/results' endpoint
1 parent 2846afd commit 208192c

File tree

9 files changed

+1105
-11
lines changed

9 files changed

+1105
-11
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
configured_endpoints: 24
2-
openapi_spec_hash: c97a5263afcc72ca5a47bc5a87683a78
3-
config_hash: f0743196c68fb84cbd06a95f134702b3
1+
configured_endpoints: 25
2+
openapi_spec_hash: 4eff18b3478c98a9b257ac27fdeb6b49
3+
config_hash: b415187e3925c414fb2597cdd0a11859

api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,10 @@ Methods:
182182
Types:
183183

184184
```python
185-
from openlayer.types import TestEvaluateResponse
185+
from openlayer.types import TestEvaluateResponse, TestListResultsResponse
186186
```
187187

188188
Methods:
189189

190190
- <code title="post /tests/{testId}/evaluate">client.tests.<a href="./src/openlayer/resources/tests.py">evaluate</a>(test_id, \*\*<a href="src/openlayer/types/test_evaluate_params.py">params</a>) -> <a href="./src/openlayer/types/test_evaluate_response.py">TestEvaluateResponse</a></code>
191+
- <code title="get /tests/{testId}/results">client.tests.<a href="./src/openlayer/resources/tests.py">list_results</a>(test_id, \*\*<a href="src/openlayer/types/test_list_results_params.py">params</a>) -> <a href="./src/openlayer/types/test_list_results_response.py">TestListResultsResponse</a></code>

src/openlayer/resources/tests.py

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

33
from __future__ import annotations
44

5+
from typing import Optional
6+
57
import httpx
68

7-
from ..types import test_evaluate_params
8-
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
9+
from ..types import test_evaluate_params, test_list_results_params
10+
from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
911
from .._utils import maybe_transform, async_maybe_transform
1012
from .._compat import cached_property
1113
from .._resource import SyncAPIResource, AsyncAPIResource
@@ -17,6 +19,7 @@
1719
)
1820
from .._base_client import make_request_options
1921
from ..types.test_evaluate_response import TestEvaluateResponse
22+
from ..types.test_list_results_response import TestListResultsResponse
2023

2124
__all__ = ["TestsResource", "AsyncTestsResource"]
2225

@@ -101,6 +104,79 @@ def evaluate(
101104
cast_to=TestEvaluateResponse,
102105
)
103106

107+
def list_results(
108+
self,
109+
test_id: str,
110+
*,
111+
end_timestamp: float | Omit = omit,
112+
include_insights: bool | Omit = omit,
113+
inference_pipeline_id: Optional[str] | Omit = omit,
114+
page: int | Omit = omit,
115+
per_page: int | Omit = omit,
116+
project_version_id: Optional[str] | Omit = omit,
117+
start_timestamp: float | Omit = omit,
118+
status: SequenceNotStr[str] | Omit = omit,
119+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
120+
# The extra values given here take precedence over values defined on the client or passed to this method.
121+
extra_headers: Headers | None = None,
122+
extra_query: Query | None = None,
123+
extra_body: Body | None = None,
124+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
125+
) -> TestListResultsResponse:
126+
"""
127+
List the test results for a test.
128+
129+
Args:
130+
end_timestamp: Filter for results that use data starting before the end timestamp.
131+
132+
include_insights: Include the insights linked to each test result
133+
134+
inference_pipeline_id: Retrive test results for a specific inference pipeline.
135+
136+
page: The page to return in a paginated query.
137+
138+
per_page: Maximum number of items to return per page.
139+
140+
project_version_id: Retrive test results for a specific project version.
141+
142+
start_timestamp: Filter for results that use data ending after the start timestamp.
143+
144+
status: Filter by status(es).
145+
146+
extra_headers: Send extra headers
147+
148+
extra_query: Add additional query parameters to the request
149+
150+
extra_body: Add additional JSON properties to the request
151+
152+
timeout: Override the client-level default timeout for this request, in seconds
153+
"""
154+
if not test_id:
155+
raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}")
156+
return self._get(
157+
f"/tests/{test_id}/results",
158+
options=make_request_options(
159+
extra_headers=extra_headers,
160+
extra_query=extra_query,
161+
extra_body=extra_body,
162+
timeout=timeout,
163+
query=maybe_transform(
164+
{
165+
"end_timestamp": end_timestamp,
166+
"include_insights": include_insights,
167+
"inference_pipeline_id": inference_pipeline_id,
168+
"page": page,
169+
"per_page": per_page,
170+
"project_version_id": project_version_id,
171+
"start_timestamp": start_timestamp,
172+
"status": status,
173+
},
174+
test_list_results_params.TestListResultsParams,
175+
),
176+
),
177+
cast_to=TestListResultsResponse,
178+
)
179+
104180

105181
class AsyncTestsResource(AsyncAPIResource):
106182
@cached_property
@@ -180,6 +256,79 @@ async def evaluate(
180256
cast_to=TestEvaluateResponse,
181257
)
182258

259+
async def list_results(
260+
self,
261+
test_id: str,
262+
*,
263+
end_timestamp: float | Omit = omit,
264+
include_insights: bool | Omit = omit,
265+
inference_pipeline_id: Optional[str] | Omit = omit,
266+
page: int | Omit = omit,
267+
per_page: int | Omit = omit,
268+
project_version_id: Optional[str] | Omit = omit,
269+
start_timestamp: float | Omit = omit,
270+
status: SequenceNotStr[str] | Omit = omit,
271+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
272+
# The extra values given here take precedence over values defined on the client or passed to this method.
273+
extra_headers: Headers | None = None,
274+
extra_query: Query | None = None,
275+
extra_body: Body | None = None,
276+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
277+
) -> TestListResultsResponse:
278+
"""
279+
List the test results for a test.
280+
281+
Args:
282+
end_timestamp: Filter for results that use data starting before the end timestamp.
283+
284+
include_insights: Include the insights linked to each test result
285+
286+
inference_pipeline_id: Retrive test results for a specific inference pipeline.
287+
288+
page: The page to return in a paginated query.
289+
290+
per_page: Maximum number of items to return per page.
291+
292+
project_version_id: Retrive test results for a specific project version.
293+
294+
start_timestamp: Filter for results that use data ending after the start timestamp.
295+
296+
status: Filter by status(es).
297+
298+
extra_headers: Send extra headers
299+
300+
extra_query: Add additional query parameters to the request
301+
302+
extra_body: Add additional JSON properties to the request
303+
304+
timeout: Override the client-level default timeout for this request, in seconds
305+
"""
306+
if not test_id:
307+
raise ValueError(f"Expected a non-empty value for `test_id` but received {test_id!r}")
308+
return await self._get(
309+
f"/tests/{test_id}/results",
310+
options=make_request_options(
311+
extra_headers=extra_headers,
312+
extra_query=extra_query,
313+
extra_body=extra_body,
314+
timeout=timeout,
315+
query=await async_maybe_transform(
316+
{
317+
"end_timestamp": end_timestamp,
318+
"include_insights": include_insights,
319+
"inference_pipeline_id": inference_pipeline_id,
320+
"page": page,
321+
"per_page": per_page,
322+
"project_version_id": project_version_id,
323+
"start_timestamp": start_timestamp,
324+
"status": status,
325+
},
326+
test_list_results_params.TestListResultsParams,
327+
),
328+
),
329+
cast_to=TestListResultsResponse,
330+
)
331+
183332

184333
class TestsResourceWithRawResponse:
185334
__test__ = False
@@ -190,6 +339,9 @@ def __init__(self, tests: TestsResource) -> None:
190339
self.evaluate = to_raw_response_wrapper(
191340
tests.evaluate,
192341
)
342+
self.list_results = to_raw_response_wrapper(
343+
tests.list_results,
344+
)
193345

194346

195347
class AsyncTestsResourceWithRawResponse:
@@ -199,6 +351,9 @@ def __init__(self, tests: AsyncTestsResource) -> None:
199351
self.evaluate = async_to_raw_response_wrapper(
200352
tests.evaluate,
201353
)
354+
self.list_results = async_to_raw_response_wrapper(
355+
tests.list_results,
356+
)
202357

203358

204359
class TestsResourceWithStreamingResponse:
@@ -210,6 +365,9 @@ def __init__(self, tests: TestsResource) -> None:
210365
self.evaluate = to_streamed_response_wrapper(
211366
tests.evaluate,
212367
)
368+
self.list_results = to_streamed_response_wrapper(
369+
tests.list_results,
370+
)
213371

214372

215373
class AsyncTestsResourceWithStreamingResponse:
@@ -219,3 +377,6 @@ def __init__(self, tests: AsyncTestsResource) -> None:
219377
self.evaluate = async_to_streamed_response_wrapper(
220378
tests.evaluate,
221379
)
380+
self.list_results = async_to_streamed_response_wrapper(
381+
tests.list_results,
382+
)

src/openlayer/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
from .project_create_response import ProjectCreateResponse as ProjectCreateResponse
1111
from .workspace_update_params import WorkspaceUpdateParams as WorkspaceUpdateParams
1212
from .commit_retrieve_response import CommitRetrieveResponse as CommitRetrieveResponse
13+
from .test_list_results_params import TestListResultsParams as TestListResultsParams
1314
from .workspace_update_response import WorkspaceUpdateResponse as WorkspaceUpdateResponse
15+
from .test_list_results_response import TestListResultsResponse as TestListResultsResponse
1416
from .workspace_retrieve_response import WorkspaceRetrieveResponse as WorkspaceRetrieveResponse
1517
from .inference_pipeline_update_params import InferencePipelineUpdateParams as InferencePipelineUpdateParams
1618
from .inference_pipeline_retrieve_params import InferencePipelineRetrieveParams as InferencePipelineRetrieveParams

src/openlayer/types/commits/test_result_list_response.py

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

33
from typing import List, Union, Optional
44
from datetime import datetime
5-
from typing_extensions import Literal
5+
from typing_extensions import Literal, TypeAlias
66

77
from pydantic import Field as FieldInfo
88

99
from ..._models import BaseModel
1010

11-
__all__ = ["TestResultListResponse", "Item", "ItemGoal", "ItemGoalThreshold", "ItemGoalThresholdInsightParameter"]
11+
__all__ = [
12+
"TestResultListResponse",
13+
"Item",
14+
"ItemExpectedValue",
15+
"ItemGoal",
16+
"ItemGoalThreshold",
17+
"ItemGoalThresholdInsightParameter",
18+
"ItemRowsBody",
19+
"ItemRowsBodyColumnFilter",
20+
"ItemRowsBodyColumnFilterSetColumnFilter",
21+
"ItemRowsBodyColumnFilterNumericColumnFilter",
22+
"ItemRowsBodyColumnFilterStringColumnFilter",
23+
]
24+
25+
26+
class ItemExpectedValue(BaseModel):
27+
lower_threshold: Optional[float] = FieldInfo(alias="lowerThreshold", default=None)
28+
"""the lower threshold for the expected value"""
29+
30+
measurement: Optional[str] = None
31+
"""One of the `measurement` values in the test's thresholds"""
32+
33+
upper_threshold: Optional[float] = FieldInfo(alias="upperThreshold", default=None)
34+
"""The upper threshold for the expected value"""
1235

1336

1437
class ItemGoalThresholdInsightParameter(BaseModel):
@@ -194,6 +217,58 @@ class ItemGoal(BaseModel):
194217
"""Whether the test uses a validation dataset."""
195218

196219

220+
class ItemRowsBodyColumnFilterSetColumnFilter(BaseModel):
221+
measurement: str
222+
"""The name of the column."""
223+
224+
operator: Literal["contains_none", "contains_any", "contains_all", "one_of", "none_of"]
225+
226+
value: List[Union[str, float]]
227+
228+
229+
class ItemRowsBodyColumnFilterNumericColumnFilter(BaseModel):
230+
measurement: str
231+
"""The name of the column."""
232+
233+
operator: Literal[">", ">=", "is", "<", "<=", "!="]
234+
235+
value: Optional[float] = None
236+
237+
238+
class ItemRowsBodyColumnFilterStringColumnFilter(BaseModel):
239+
measurement: str
240+
"""The name of the column."""
241+
242+
operator: Literal["is", "!="]
243+
244+
value: Union[str, bool]
245+
246+
247+
ItemRowsBodyColumnFilter: TypeAlias = Union[
248+
ItemRowsBodyColumnFilterSetColumnFilter,
249+
ItemRowsBodyColumnFilterNumericColumnFilter,
250+
ItemRowsBodyColumnFilterStringColumnFilter,
251+
]
252+
253+
254+
class ItemRowsBody(BaseModel):
255+
"""The body of the rows request."""
256+
257+
column_filters: Optional[List[ItemRowsBodyColumnFilter]] = FieldInfo(alias="columnFilters", default=None)
258+
259+
exclude_row_id_list: Optional[List[int]] = FieldInfo(alias="excludeRowIdList", default=None)
260+
261+
not_search_query_and: Optional[List[str]] = FieldInfo(alias="notSearchQueryAnd", default=None)
262+
263+
not_search_query_or: Optional[List[str]] = FieldInfo(alias="notSearchQueryOr", default=None)
264+
265+
row_id_list: Optional[List[int]] = FieldInfo(alias="rowIdList", default=None)
266+
267+
search_query_and: Optional[List[str]] = FieldInfo(alias="searchQueryAnd", default=None)
268+
269+
search_query_or: Optional[List[str]] = FieldInfo(alias="searchQueryOr", default=None)
270+
271+
197272
class Item(BaseModel):
198273
id: str
199274
"""Project version (commit) id."""
@@ -222,11 +297,19 @@ class Item(BaseModel):
222297
status_message: Optional[str] = FieldInfo(alias="statusMessage", default=None)
223298
"""The status message."""
224299

300+
expected_values: Optional[List[ItemExpectedValue]] = FieldInfo(alias="expectedValues", default=None)
301+
225302
goal: Optional[ItemGoal] = None
226303

227304
goal_id: Optional[str] = FieldInfo(alias="goalId", default=None)
228305
"""The test id."""
229306

307+
rows: Optional[str] = None
308+
"""The URL to the rows of the test result."""
309+
310+
rows_body: Optional[ItemRowsBody] = FieldInfo(alias="rowsBody", default=None)
311+
"""The body of the rows request."""
312+
230313

231314
class TestResultListResponse(BaseModel):
232315
__test__ = False

0 commit comments

Comments
 (0)