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

Improved experiments results display #210

Merged
merged 2 commits into from
Jul 11, 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
2 changes: 1 addition & 1 deletion backend/swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
swagger: "2.0"
info:
version: 0.28.0-beta1
version: 0.28.0-beta2
title: DebiAI_BACKEND_API
description: DebiAI backend api
contact:
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "debiai_frontend",
"version": "0.28.0-beta1",
"version": "0.28.0-beta2",
"description": "Frontend for Debiai, made with Vuejs",
"license": "Apache-2.0",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,19 @@ export default {
});
this.algoToUse = null;

if (typeof results === "string") {
try {
// Convert to object if it's a string
// Replace 'Infinity' to avoid JSON.parse error
results = results
.replace(/ -Infinity/g, '"-Infinity"')
.replace(/ Infinity/g, '"Infinity"');
results = JSON.parse(results);
} catch (error) {
throw new Error("Results are not a valid JSON object");
}
}

const experiment = {
results,
inputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,18 @@
<td class="name">{{ result.name }}</td>
<td
class="value"
v-if="Array.isArray(result.value)"
v-if="
Array.isArray(result.value) &&
result.value.length &&
typeof result.value[0] === 'object' &&
result.value[0] !== null
"
>
<DataTable :data="result.value" />
</td>
<td
class="value"
v-else-if="Array.isArray(result.value)"
>
{{ result.value.length }} elements {{ result.value.slice(0, 5) }}...
</td>
Expand Down Expand Up @@ -216,8 +227,13 @@
</template>

<script>
import DataTable from "@/components/debiai/dataAnalysis/common/DataTable.vue";

export default {
name: "Experiments",
components: {
DataTable,
},
props: {
algorithm: { type: Object, required: true },
algoProvider: { type: Object, required: true },
Expand Down Expand Up @@ -420,7 +436,8 @@ export default {
}

td {
padding: 5px;
padding: 10px 5px;
vertical-align: top;
}

.name {
Expand Down
78 changes: 78 additions & 0 deletions frontend/src/components/debiai/dataAnalysis/common/DataTable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<template>
<div>
<table>
<thead>
<tr>
<th
v-for="key in keys"
:key="key"
>
{{ key }}
</th>
</tr>
</thead>
<tbody>
<tr
v-for="(item, index) in data.slice(0, max_length_to_show)"
:key="index"
>
<td
v-for="key in keys"
:key="key"
>
{{ item[key] }}
</td>
</tr>
<tr v-if="data.length > max_length_to_show">
<td :colspan="keys.length">
<span>
<b>And {{ data.length - max_length_to_show }} more...</b>
</span>
</td>
</tr>
</tbody>
</table>
</div>
</template>

<script>
export default {
name: "DataTable",
data() {
return {
max_length_to_show: 20,
};
},
props: {
data: {
type: Array,
required: true,
default: () => [],
},
},
computed: {
keys() {
if (this.data.length === 0) return [];
return Object.keys(this.data[0]);
},
},
};
</script>

<style scoped lang="scss">
table {
width: 100%;
border-collapse: collapse;

th,
td {
border: 1px solid #ccc;
padding: 8px;
text-align: left;
}

th {
background-color: #f2f2f2;
}
}
</style>
Loading