Skip to content

Commit

Permalink
Fix parsing request from aim UI
Browse files Browse the repository at this point in the history
  • Loading branch information
suprjinx committed Aug 1, 2024
1 parent 71ec47b commit 6926e02
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
14 changes: 7 additions & 7 deletions pkg/api/aim/api/request/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ type SearchAlignedMetricsRequest struct {
// SearchArtifactsRequest is a request struct for `POST /runs/search/image` endpoint.
type SearchArtifactsRequest struct {
BaseSearchRequest
Query string `params:"q"`
SkipSystem bool `params:"skip_system"`
RecordDensity int `params:"record_density"`
IndexDensity int `params:"index_density"`
RecordRange string `params:"record_range"`
IndexRange string `params:"index_range"`
CalcRanges bool `params:"calc_ranges"`
Query string `json:"q"`
SkipSystem bool `json:"skip_system"`
RecordDensity any `json:"record_density"`
IndexDensity any `json:"index_density"`
RecordRange string `json:"record_range"`
IndexRange string `json:"index_range"`
CalcRanges bool `json:"calc_ranges"`
}

// DeleteRunRequest is a request struct for `DELETE /runs/:id` endpoint.
Expand Down
16 changes: 10 additions & 6 deletions pkg/api/aim/api/response/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ func NewStreamArtifactsResponse(ctx *fiber.Ctx, rows *sql.Rows, runs map[string]
"width": img.Width,
"format": img.Format,
"iter": img.Iter,
"index": img.Index,
"index": imgIndex, // calculated
"step": img.Step,
}

Expand Down Expand Up @@ -632,17 +632,21 @@ func NewStreamArtifactsResponse(ctx *fiber.Ctx, rows *sql.Rows, runs map[string]
return w.Flush()
}
includeStep := func(img models.Artifact) bool {
if req.RecordDensity == 0 {
switch v := req.RecordDensity.(type) {
case int:
return img.Step%int64(v) == 0
default:
return true
}
return img.Step%int64(req.RecordDensity) == 0
}
includeIndex := func(img models.Artifact) bool {
if req.IndexDensity == 0 {
switch v := req.IndexDensity.(type) {
case int:
interval := summary.StepImageCount(img.RunID, img.Name, int(img.Step)) / v
return imgIndex%interval == 0
default:
return true
}
interval := summary.StepImageCount(img.RunID, img.Name, int(img.Step)) / req.IndexDensity
return imgIndex%interval == 0
}
hasRows := false
for rows.Next() {
Expand Down

0 comments on commit 6926e02

Please sign in to comment.