Skip to content

Commit

Permalink
fix: use api for latest runs instead of local filtering (#81)
Browse files Browse the repository at this point in the history
* fix: use api for latest runs instead of local filtering

* docs: add comment explaining the workaround
  • Loading branch information
jfrer authored Jul 12, 2024
1 parent 4044c44 commit 9f6177f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/components/Workflows.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
}
workflowsStore.runs = await api.getRuns()
workflowsStore.latestRuns = await api.getLatestRuns()
workflowsStore.gt = await api.getGroundTruth()
workflowsStore.workflows = await api.getWorkflows()
Expand All @@ -58,6 +59,11 @@
if (!workflowsStore.gt.find(gt => gt.id === gtId)) console.log(gtId)
})
workflowsStore.latestRuns.forEach(run => {
const gtId = mapGtId(run.metadata.gt_workspace.id)
if (!workflowsStore.gt.find(gt => gt.id === gtId)) console.log(gtId)
})
const releasesObj = workflowsStore.runs.reduce((acc, cur) => {
acc[cur.metadata.release_info.tag_name] = cur.metadata.release_info
Expand Down
10 changes: 8 additions & 2 deletions src/helpers/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ async function getLatestRuns(gtId?: string, workflowId?: string): Promise<Evalua
if (workflowId) path += `/${workflowId}`

path += '/latest'

return await request(path)
/*
TODO: Remove flattening when bug in the backend is fixed.
Bug: The data gets returned as an array of arrays that each contain a single object.
It should have the same structure as the data at the /runs endpoint. (array of objects)
Workaround:
Flatten the returned list to match the data structure of the /runs endpoint.
*/
return (await request(path)).flat(1)
}

async function request (url: string) {
Expand Down
9 changes: 3 additions & 6 deletions src/store/workflows-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default reactive<{
gt: GroundTruth[],
workflows: Workflow[],
runs: EvaluationRun[],
latestRuns: EvaluationRun[],
releases: ReleaseInfo[],
getRuns: (gtId: string, workflowId?: string) => EvaluationRun[]
getLatestRuns: () => EvaluationRun[],
Expand All @@ -19,6 +20,7 @@ export default reactive<{
gt: [],
workflows: [],
runs: [],
latestRuns: [],
releases: [],
getRuns(gtId: string, workflowId?: string) {
return this.runs
Expand All @@ -32,12 +34,7 @@ export default reactive<{
)
},
getLatestRuns() {
const dates = Object.keys(this.runs.reduce((acc, cur) => {
acc[normalizeDate(cur.metadata.timestamp)] = null
return acc
}, <{ [key: string]: null}>{}))

return this.runs.filter(({ metadata }) => normalizeDate(metadata.timestamp) === dates[dates.length - 1])
return this.latestRuns
},
getGtById(id: string): GroundTruth | null {
return this.gt.find((item) => item.id === id) ?? null
Expand Down

0 comments on commit 9f6177f

Please sign in to comment.