22
33from __future__ import annotations
44
5+ from typing import Optional
6+
57import 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
911from .._utils import maybe_transform , async_maybe_transform
1012from .._compat import cached_property
1113from .._resource import SyncAPIResource , AsyncAPIResource
1719)
1820from .._base_client import make_request_options
1921from ..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
105181class 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
184333class 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
195347class 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
204359class 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
215373class 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+ )
0 commit comments