Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use api for latest runs instead of local filtering #81

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
paulpestov marked this conversation as resolved.
Show resolved Hide resolved
}

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
Loading