-
Notifications
You must be signed in to change notification settings - Fork 0
/
committestresult.go
365 lines (328 loc) · 14.3 KB
/
committestresult.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package openlayer
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"reflect"
"time"
"github.com/openlayer-ai/openlayer-go/internal/apijson"
"github.com/openlayer-ai/openlayer-go/internal/apiquery"
"github.com/openlayer-ai/openlayer-go/internal/param"
"github.com/openlayer-ai/openlayer-go/internal/requestconfig"
"github.com/openlayer-ai/openlayer-go/option"
"github.com/openlayer-ai/openlayer-go/shared"
"github.com/tidwall/gjson"
)
// CommitTestResultService contains methods and other services that help with
// interacting with the openlayer API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewCommitTestResultService] method instead.
type CommitTestResultService struct {
Options []option.RequestOption
}
// NewCommitTestResultService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewCommitTestResultService(opts ...option.RequestOption) (r *CommitTestResultService) {
r = &CommitTestResultService{}
r.Options = opts
return
}
// List the test results for a project commit (project version).
func (r *CommitTestResultService) List(ctx context.Context, projectVersionID string, query CommitTestResultListParams, opts ...option.RequestOption) (res *CommitTestResultListResponse, err error) {
opts = append(r.Options[:], opts...)
if projectVersionID == "" {
err = errors.New("missing required projectVersionId parameter")
return
}
path := fmt.Sprintf("versions/%s/results", projectVersionID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return
}
type CommitTestResultListResponse struct {
Items []CommitTestResultListResponseItem `json:"items,required"`
JSON commitTestResultListResponseJSON `json:"-"`
}
// commitTestResultListResponseJSON contains the JSON metadata for the struct
// [CommitTestResultListResponse]
type commitTestResultListResponseJSON struct {
Items apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CommitTestResultListResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r commitTestResultListResponseJSON) RawJSON() string {
return r.raw
}
type CommitTestResultListResponseItem struct {
// Project version (commit) id.
ID string `json:"id,required" format:"uuid"`
// The creation date.
DateCreated time.Time `json:"dateCreated,required" format:"date-time"`
// The data end date.
DateDataEnds time.Time `json:"dateDataEnds,required,nullable" format:"date-time"`
// The data start date.
DateDataStarts time.Time `json:"dateDataStarts,required,nullable" format:"date-time"`
// The last updated date.
DateUpdated time.Time `json:"dateUpdated,required" format:"date-time"`
// The inference pipeline id.
InferencePipelineID string `json:"inferencePipelineId,required,nullable" format:"uuid"`
// The project version (commit) id.
ProjectVersionID string `json:"projectVersionId,required,nullable" format:"uuid"`
// The status of the test.
Status CommitTestResultListResponseItemsStatus `json:"status,required"`
// The status message.
StatusMessage string `json:"statusMessage,required,nullable"`
Goal CommitTestResultListResponseItemsGoal `json:"goal"`
// The test id.
GoalID string `json:"goalId,nullable" format:"uuid"`
JSON commitTestResultListResponseItemJSON `json:"-"`
}
// commitTestResultListResponseItemJSON contains the JSON metadata for the struct
// [CommitTestResultListResponseItem]
type commitTestResultListResponseItemJSON struct {
ID apijson.Field
DateCreated apijson.Field
DateDataEnds apijson.Field
DateDataStarts apijson.Field
DateUpdated apijson.Field
InferencePipelineID apijson.Field
ProjectVersionID apijson.Field
Status apijson.Field
StatusMessage apijson.Field
Goal apijson.Field
GoalID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CommitTestResultListResponseItem) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r commitTestResultListResponseItemJSON) RawJSON() string {
return r.raw
}
// The status of the test.
type CommitTestResultListResponseItemsStatus string
const (
CommitTestResultListResponseItemsStatusRunning CommitTestResultListResponseItemsStatus = "running"
CommitTestResultListResponseItemsStatusPassing CommitTestResultListResponseItemsStatus = "passing"
CommitTestResultListResponseItemsStatusFailing CommitTestResultListResponseItemsStatus = "failing"
CommitTestResultListResponseItemsStatusSkipped CommitTestResultListResponseItemsStatus = "skipped"
CommitTestResultListResponseItemsStatusError CommitTestResultListResponseItemsStatus = "error"
)
func (r CommitTestResultListResponseItemsStatus) IsKnown() bool {
switch r {
case CommitTestResultListResponseItemsStatusRunning, CommitTestResultListResponseItemsStatusPassing, CommitTestResultListResponseItemsStatusFailing, CommitTestResultListResponseItemsStatusSkipped, CommitTestResultListResponseItemsStatusError:
return true
}
return false
}
type CommitTestResultListResponseItemsGoal struct {
// The test id.
ID string `json:"id,required" format:"uuid"`
// The number of comments on the test.
CommentCount int64 `json:"commentCount,required"`
// The test creator id.
CreatorID string `json:"creatorId,required,nullable" format:"uuid"`
// The date the test was archived.
DateArchived time.Time `json:"dateArchived,required,nullable" format:"date-time"`
// The creation date.
DateCreated time.Time `json:"dateCreated,required" format:"date-time"`
// The last updated date.
DateUpdated time.Time `json:"dateUpdated,required" format:"date-time"`
// The test description.
Description interface{} `json:"description,required,nullable"`
// The test name.
Name string `json:"name,required"`
// The test number.
Number int64 `json:"number,required"`
// The project version (commit) id where the test was created.
OriginProjectVersionID string `json:"originProjectVersionId,required,nullable" format:"uuid"`
// The test subtype.
Subtype string `json:"subtype,required"`
// Whether the test is suggested or user-created.
Suggested bool `json:"suggested,required"`
Thresholds []CommitTestResultListResponseItemsGoalThreshold `json:"thresholds,required"`
// The test type.
Type string `json:"type,required"`
// Whether the test is archived.
Archived bool `json:"archived"`
// The delay window in seconds. Only applies to tests that use production data.
DelayWindow float64 `json:"delayWindow,nullable"`
// The evaluation window in seconds. Only applies to tests that use production
// data.
EvaluationWindow float64 `json:"evaluationWindow,nullable"`
// Whether the test uses an ML model.
UsesMlModel bool `json:"usesMlModel"`
// Whether the test uses production data (monitoring mode only).
UsesProductionData bool `json:"usesProductionData"`
// Whether the test uses a reference dataset (monitoring mode only).
UsesReferenceDataset bool `json:"usesReferenceDataset"`
// Whether the test uses a training dataset.
UsesTrainingDataset bool `json:"usesTrainingDataset"`
// Whether the test uses a validation dataset.
UsesValidationDataset bool `json:"usesValidationDataset"`
JSON commitTestResultListResponseItemsGoalJSON `json:"-"`
}
// commitTestResultListResponseItemsGoalJSON contains the JSON metadata for the
// struct [CommitTestResultListResponseItemsGoal]
type commitTestResultListResponseItemsGoalJSON struct {
ID apijson.Field
CommentCount apijson.Field
CreatorID apijson.Field
DateArchived apijson.Field
DateCreated apijson.Field
DateUpdated apijson.Field
Description apijson.Field
Name apijson.Field
Number apijson.Field
OriginProjectVersionID apijson.Field
Subtype apijson.Field
Suggested apijson.Field
Thresholds apijson.Field
Type apijson.Field
Archived apijson.Field
DelayWindow apijson.Field
EvaluationWindow apijson.Field
UsesMlModel apijson.Field
UsesProductionData apijson.Field
UsesReferenceDataset apijson.Field
UsesTrainingDataset apijson.Field
UsesValidationDataset apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CommitTestResultListResponseItemsGoal) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r commitTestResultListResponseItemsGoalJSON) RawJSON() string {
return r.raw
}
type CommitTestResultListResponseItemsGoalThreshold struct {
// The insight name to be evaluated.
InsightName string `json:"insightName"`
InsightParameters []interface{} `json:"insightParameters"`
// The measurement to be evaluated.
Measurement string `json:"measurement"`
// The operator to be used for the evaluation.
Operator string `json:"operator"`
// The value to be compared.
Value CommitTestResultListResponseItemsGoalThresholdsValueUnion `json:"value"`
JSON commitTestResultListResponseItemsGoalThresholdJSON `json:"-"`
}
// commitTestResultListResponseItemsGoalThresholdJSON contains the JSON metadata
// for the struct [CommitTestResultListResponseItemsGoalThreshold]
type commitTestResultListResponseItemsGoalThresholdJSON struct {
InsightName apijson.Field
InsightParameters apijson.Field
Measurement apijson.Field
Operator apijson.Field
Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *CommitTestResultListResponseItemsGoalThreshold) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r commitTestResultListResponseItemsGoalThresholdJSON) RawJSON() string {
return r.raw
}
// The value to be compared.
//
// Union satisfied by [shared.UnionFloat], [shared.UnionBool], [shared.UnionString]
// or [CommitTestResultListResponseItemsGoalThresholdsValueArray].
type CommitTestResultListResponseItemsGoalThresholdsValueUnion interface {
ImplementsCommitTestResultListResponseItemsGoalThresholdsValueUnion()
}
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*CommitTestResultListResponseItemsGoalThresholdsValueUnion)(nil)).Elem(),
"",
apijson.UnionVariant{
TypeFilter: gjson.Number,
Type: reflect.TypeOf(shared.UnionFloat(0)),
},
apijson.UnionVariant{
TypeFilter: gjson.True,
Type: reflect.TypeOf(shared.UnionBool(false)),
},
apijson.UnionVariant{
TypeFilter: gjson.False,
Type: reflect.TypeOf(shared.UnionBool(false)),
},
apijson.UnionVariant{
TypeFilter: gjson.String,
Type: reflect.TypeOf(shared.UnionString("")),
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(CommitTestResultListResponseItemsGoalThresholdsValueArray{}),
},
)
}
type CommitTestResultListResponseItemsGoalThresholdsValueArray []string
func (r CommitTestResultListResponseItemsGoalThresholdsValueArray) ImplementsCommitTestResultListResponseItemsGoalThresholdsValueUnion() {
}
type CommitTestResultListParams struct {
// Include archived goals.
IncludeArchived param.Field[bool] `query:"includeArchived"`
// The page to return in a paginated query.
Page param.Field[int64] `query:"page"`
// Maximum number of items to return per page.
PerPage param.Field[int64] `query:"perPage"`
// Filter list of test results by status. Available statuses are `running`,
// `passing`, `failing`, `skipped`, and `error`.
Status param.Field[CommitTestResultListParamsStatus] `query:"status"`
// Filter objects by test type. Available types are `integrity`, `consistency`,
// `performance`, `fairness`, and `robustness`.
Type param.Field[CommitTestResultListParamsType] `query:"type"`
}
// URLQuery serializes [CommitTestResultListParams]'s query parameters as
// `url.Values`.
func (r CommitTestResultListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// Filter list of test results by status. Available statuses are `running`,
// `passing`, `failing`, `skipped`, and `error`.
type CommitTestResultListParamsStatus string
const (
CommitTestResultListParamsStatusRunning CommitTestResultListParamsStatus = "running"
CommitTestResultListParamsStatusPassing CommitTestResultListParamsStatus = "passing"
CommitTestResultListParamsStatusFailing CommitTestResultListParamsStatus = "failing"
CommitTestResultListParamsStatusSkipped CommitTestResultListParamsStatus = "skipped"
CommitTestResultListParamsStatusError CommitTestResultListParamsStatus = "error"
)
func (r CommitTestResultListParamsStatus) IsKnown() bool {
switch r {
case CommitTestResultListParamsStatusRunning, CommitTestResultListParamsStatusPassing, CommitTestResultListParamsStatusFailing, CommitTestResultListParamsStatusSkipped, CommitTestResultListParamsStatusError:
return true
}
return false
}
// Filter objects by test type. Available types are `integrity`, `consistency`,
// `performance`, `fairness`, and `robustness`.
type CommitTestResultListParamsType string
const (
CommitTestResultListParamsTypeIntegrity CommitTestResultListParamsType = "integrity"
CommitTestResultListParamsTypeConsistency CommitTestResultListParamsType = "consistency"
CommitTestResultListParamsTypePerformance CommitTestResultListParamsType = "performance"
CommitTestResultListParamsTypeFairness CommitTestResultListParamsType = "fairness"
CommitTestResultListParamsTypeRobustness CommitTestResultListParamsType = "robustness"
)
func (r CommitTestResultListParamsType) IsKnown() bool {
switch r {
case CommitTestResultListParamsTypeIntegrity, CommitTestResultListParamsTypeConsistency, CommitTestResultListParamsTypePerformance, CommitTestResultListParamsTypeFairness, CommitTestResultListParamsTypeRobustness:
return true
}
return false
}