From d75253a2d98ebde0fff7724a8fd3dddebf4421cf Mon Sep 17 00:00:00 2001 From: "amtul.noor" Date: Thu, 1 Feb 2024 19:06:32 +0100 Subject: [PATCH 01/26] feat: filter by workflow and processor --- .../workflows/WorkflowsTimeline.vue | 73 ++++++- src/components/workflows/filters/Filters.vue | 3 + .../workflows/timeline/TimelineItem.vue | 202 +++++++++--------- src/helpers/utils.ts | 14 +- src/store/filters-store.ts | 6 +- 5 files changed, 196 insertions(+), 102 deletions(-) diff --git a/src/components/workflows/WorkflowsTimeline.vue b/src/components/workflows/WorkflowsTimeline.vue index e957da8..fa18f82 100644 --- a/src/components/workflows/WorkflowsTimeline.vue +++ b/src/components/workflows/WorkflowsTimeline.vue @@ -6,18 +6,40 @@ import {EvaluationMetrics, getMaxValueByMetric} from '@/helpers/metrics' import { useI18n } from "vue-i18n" import type { DropdownOption, EvaluationResultsDocumentWide, Workflow, GroundTruth } from "@/types" import { DropdownPassThroughStyles } from '@/helpers/pt' +import { deduplicateStepIds } from '@/helpers/utils' import workflowsStore from '@/store/workflows-store' import filtersStore from '@/store/filters-store' import timelineStore from "@/store/timeline-store" import TrendLegend from "@/components/workflows/TrendLegend.vue"; const { t } = useI18n() -const gtList = computed(() => workflowsStore.gt.filter(({ id }) => filtersStore.gt.findIndex(({ value }) => value === id) > -1)) const workflows = ref([]) + const selectedMetric = ref(null) const metrics = computed(() => Object.keys(EvaluationMetrics).map(key => ({ value: EvaluationMetrics[key], label: t(EvaluationMetrics[key]) }))) const selectedMetricValue = computed(() => selectedMetric.value?.value || EvaluationMetrics.CER_MEAN) +const workflowOptions = computed(() => filtersStore.workflow) +const selectedWorkflow = ref(null) + +const workflowStepOptions = ref([]) +const selectedWorkflowStep = ref(null) + +const gtList = computed(() => { + return workflowsStore.gt.filter(({ id }) => { + let flag = filtersStore.gt.findIndex(({ value }) => value === id) > -1 + if (selectedWorkflow.value) { + flag = flag && workflowsStore.getRuns(id, selectedWorkflow.value.value).length > 0 + } + if (selectedWorkflowStep.value) { + flag = flag && workflowsStore.getRuns(id).findIndex(({ metadata }) => { + return metadata.workflow_steps.findIndex(({ id }) => id === selectedWorkflowStep.value?.value) > -1 + }) > -1 + } + return flag + }) +}) + onMounted(async () => { selectedMetric.value = metrics.value[0] workflows.value = workflowsStore.workflows @@ -30,6 +52,24 @@ watch(selectedMetric, ), { immediate: true } ) + +watch( + selectedWorkflow, + (selected) => { + selectedWorkflowStep.value = null + if (!selected) { + workflowStepOptions.value = deduplicateStepIds(workflowsStore.workflows).map(id => ({ value: id, label: t(id) })) + return + } + const workflow = workflowsStore.workflows.find((item) => item.id === selected.value) + if (!workflow) { + console.error("Invalid state") + return + } + workflowStepOptions.value = workflow.steps.map(({ id }) => ({ value: id, label: t(id) })) + }, + { immediate: true } +)