Skip to content

Commit

Permalink
Baisc boxplot
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Oct 28, 2024
1 parent 31404dd commit 42e56ff
Show file tree
Hide file tree
Showing 6 changed files with 579 additions and 188 deletions.
3 changes: 3 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
"tus-js-client": "^3.1.1",
"underscore": "^1.13.6",
"util": "^0.12.5",
"vega": "^5.30.0",
"vega-embed": "^6.26.0",
"vega-lite": "^5.21.0",
"vue": "^2.7.14",
"vue-echarts": "^7.0.3",
"vue-infinite-scroll": "^2.0.2",
Expand Down
145 changes: 0 additions & 145 deletions client/src/components/WorkflowInvocationState/MetricsBoxPlots.vue

This file was deleted.

43 changes: 43 additions & 0 deletions client/src/components/WorkflowInvocationState/VegaWrapper.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<template>
<div ref="chartContainer" class="chart"></div>
</template>

<script setup lang="ts">
import embed, { type VisualizationSpec } from "vega-embed";
import { onBeforeUnmount, onMounted, ref, watch } from "vue";

Check failure on line 7 in client/src/components/WorkflowInvocationState/VegaWrapper.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

'onMounted' is defined but never used. Allowed unused vars must match /_.+/u
export interface VisSpec {
spec: VisualizationSpec;
}
const props = defineProps<VisSpec>();
const chartContainer = ref<HTMLDivElement | null>(null);
let vegaView: any;
watch(
props,
async () => {
console.log(props.spec);
if (chartContainer.value) {
const result = await embed(chartContainer.value, props.spec);
vegaView = result.view;
}
},
{ immediate: true }
);
// Cleanup the chart when the component is unmounted
onBeforeUnmount(() => {
if (vegaView) {
vegaView.finalize();
}
});
</script>

<style scoped>
.chart {
width: 100%;
height: 300rem;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { BCard } from "bootstrap-vue";
import { GalaxyApi, type components } from "@/api";
import { computed, ref, watch } from "vue";
import type JobMetrics from "../JobMetrics/JobMetrics.vue";
import { type components, GalaxyApi } from "@/api";
import { errorMessageAsString } from "@/utils/simple-error";
import MetricsBoxPlot from "./MetricsBoxPlots.vue";
import VegaWrapper from "./VegaWrapper.vue";
const props = defineProps({
invocationId: {
Expand All @@ -13,40 +13,85 @@ const props = defineProps({
},
});
const jobMetrics = ref<components["schemas"]["JobMetric"][]>()
const fetchError = ref<string>()
const jobMetrics = ref<components["schemas"]["WorkflowJobMetric"][]>();
const fetchError = ref<string>();
async function fetchMetrics() {
const {data, error} = await GalaxyApi().GET("/api/invocations/{invocation_id}/metrics", {
const { data, error } = await GalaxyApi().GET("/api/invocations/{invocation_id}/metrics", {
params: {
path: {
invocation_id: props.invocationId
}
}
})
invocation_id: props.invocationId,
},
},
});
console.log("data", data, error);
if (error) {
fetchError.value = errorMessageAsString(error)
fetchError.value = errorMessageAsString(error);
} else {
jobMetrics.value = data
jobMetrics.value = data;
}
}
watch((props), () => fetchMetrics(), { immediate: true })
watch(props, () => fetchMetrics(), { immediate: true });
const wallclock = computed(() => {
return jobMetrics.value?.filter((jobMetric) => jobMetric.name == "runtime_seconds")
})
const wallclock = jobMetrics.value?.filter((jobMetric) => jobMetric.name == "runtime_seconds");
return wallclock?.map((item) => {
return {
raw_value: parseFloat(item.raw_value),
tool_id: item.tool_id,
};
});
});
const spec = computed(() => {
console.log(wallclock.value);
return {
$schema: "https://vega.github.io/schema/vega-lite/v5.json",
description: "A boxplot with jittered points.",
data: {
values: wallclock.value,
},
transform: [
{
calculate: "random() - 0.5",
as: "random_jitter",
},
],
layer: [
{
mark: { type: "boxplot", opacity: 0.5 },
encoding: {
x: { field: "tool_id", type: "ordinal" },
y: { field: "raw_value", type: "quantitative" },
},
width: "container",
},
{
mark: {
type: "point",
opacity: 0.7,
},
encoding: {
x: {
field: "tool_id",
type: "ordinal",
},
xOffset: { field: "random_jitter", type: "quantitative", scale: { domain: [-2, 2] } },
y: {
field: "raw_value",
type: "quantitative",
axis: { title: "Raw Value" },
scale: { zero: false },
},
},
width: "container",
},
],
};
});
</script>

<template>
<MetricsBoxPlot v-if="wallclock" :job-data="wallclock"/>
<!--
<div>
{{ jobMetrics }}
</div>
-->
<VegaWrapper v-if="spec" :spec="spec" />
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { isTerminal, jobCount, runningCount } from "./util";
import InvocationReport from "../Workflow/InvocationReport.vue";
import WorkflowInvocationExportOptions from "./WorkflowInvocationExportOptions.vue";
import WorkflowInvocationMetrics from "./WorkflowInvocationMetrics.vue";
import WorkflowInvocationHeader from "./WorkflowInvocationHeader.vue";
import WorkflowInvocationInputOutputTabs from "./WorkflowInvocationInputOutputTabs.vue";
import WorkflowInvocationMetrics from "./WorkflowInvocationMetrics.vue";
import WorkflowInvocationOverview from "./WorkflowInvocationOverview.vue";
import LoadingSpan from "@/components/LoadingSpan.vue";
Expand Down Expand Up @@ -186,7 +186,7 @@ function cancelWorkflowSchedulingLocal() {
<LoadingSpan message="Waiting to complete invocation" />
</BAlert>
</BTab>
<BTab title="Metrics">
<BTab title="Metrics" :lazy="true">
<WorkflowInvocationMetrics :invocation-id="invocation.id"></WorkflowInvocationMetrics>
</BTab>
</BTabs>
Expand Down
Loading

0 comments on commit 42e56ff

Please sign in to comment.