Skip to content

Commit

Permalink
Add inference and total duration to trial response
Browse files Browse the repository at this point in the history
C3SR-366
  • Loading branch information
youngest committed May 17, 2022
1 parent b81e672 commit 08049d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions api/endpoints/trials.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ type trialResponse struct {
}

type trialResults struct {
Responses []responseFeatures `json:"responses,omitempty"`
TraceId traceId `json:"trace_id,omitempty"`
Duration string `json:"duration,omitempty"`
DurationForInference string `json:"duration_for_inference,omitempty"`
Responses []responseFeatures `json:"responses,omitempty"`
TraceId traceId `json:"trace_id,omitempty"`
}

type responseFeatures struct {
Expand Down
4 changes: 3 additions & 1 deletion api/endpoints/trials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestTrialRoute(t *testing.T) {
},
})
trial, _ := testDb.GetTrialById("trial2")
testDb.CompleteTrial(trial, "{\"responses\": [{\"features\": [{\"classification\":{\"index\": 933,\"label\":\"n07697313 cheeseburger\"},\"id\": \"61afb91c7cc38300018b8a74\",\"probability\": 0.64689136,\"type\": \"CLASSIFICATION\"}]}], \"trace_id\": {\"id\": \"trace\"}}")
testDb.CompleteTrial(trial, "{\"duration\": \"1s\", \"duration_for_inference\": \"0.5s\", \"responses\": [{\"features\": [{\"classification\":{\"index\": 933,\"label\":\"n07697313 cheeseburger\"},\"id\": \"61afb91c7cc38300018b8a74\",\"probability\": 0.64689136,\"type\": \"CLASSIFICATION\"}]}], \"trace_id\": {\"id\": \"trace\"}}")

w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/trial/trial2", nil)
Expand All @@ -87,6 +87,8 @@ func TestTrialRoute(t *testing.T) {
assert.Equal(t, uint(1), response.Model.ID)
assert.Equal(t, uint(1), response.Model.Framework.ID)
assert.True(t, response.CompletedAt.Equal(*trial.CompletedAt))
assert.Equal(t, "1s", response.Results.Duration)
assert.Equal(t, "0.5s", response.Results.DurationForInference)
assert.Equal(t, 1, len(response.Results.Responses))
})

Expand Down

0 comments on commit 08049d5

Please sign in to comment.