Skip to content
Open
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
72 changes: 70 additions & 2 deletions DashAI/front/src/components/models/SessionInfoContent.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import React from "react";
import React, { useEffect, useState } from "react";
import PropTypes from "prop-types";
import { Box, Typography, Chip } from "@mui/material";
import { useTranslation } from "react-i18next";
import { formatDate } from "../../utils";
import ParamInfoList from "./ParamInfoBox";
import { getComponents } from "../../api/component";
import ParamInfoList, { ParamInfoBox } from "./ParamInfoBox";
import {
buildStepDisplayNames,
buildColumnKeysAndTypes,
refToKey,
} from "./modelSession/sessionColumnRefs";

const SPLIT_TYPE_LABEL_KEYS = {
random: "experiments:label.random",
Expand All @@ -24,9 +30,41 @@ export default function SessionInfoContent({
tasks = [],
}) {
const { t } = useTranslation(["common", "experiments", "models"]);
const [convertersMeta, setConvertersMeta] = useState({});

useEffect(() => {
let cancelled = false;
getComponents({ selectTypes: ["Converter"] })
.then((data) => {
if (cancelled) return;
setConvertersMeta(
Object.fromEntries((data || []).map((c) => [c.name, c])),
);
})
.catch((error) =>
console.error("Failed to fetch converter metadata:", error),
);
return () => {
cancelled = true;
};
}, []);

if (!session) return null;

const preprocessingSteps = session.preprocessing?.steps || [];
const stepDisplayNames = buildStepDisplayNames(
preprocessingSteps,
convertersMeta,
);
// datasetTypes isn't needed here: a raw scope ref is shown as its own
// column name regardless, and a group scope ref's label only depends on
// the earlier step it points to (see buildColumnKeysAndTypes).
const { optionLabels: scopeOptionLabels } = buildColumnKeysAndTypes({
datasetTypes: {},
preprocessing: preprocessingSteps,
convertersMeta,
});

const getDatasetName = () => {
if (!session.dataset_id || !datasets.length) return t("common:unknown");
const dataset = datasets.find((d) => d.id === session.dataset_id);
Expand Down Expand Up @@ -150,6 +188,28 @@ export default function SessionInfoContent({
<ParamInfoList rows={configRows} />
</Box>

{preprocessingSteps.length > 0 && (
<Box>
<Typography variant="subtitle2" gutterBottom>
{t("models:label.appliedConverters")}
</Typography>
<Box sx={{ display: "flex", flexDirection: "column", gap: 2 }}>
{preprocessingSteps.map((step, index) => (
<ParamInfoBox
key={`${step.converter}-${index}`}
label={stepDisplayNames[index]}
value={(step.scope || [])
.map((ref) => {
const key = refToKey(ref);
return scopeOptionLabels[key] || key;
})
.join(", ")}
/>
))}
</Box>
</Box>
)}

<Box>
<Typography variant="subtitle2" gutterBottom>
{t("common:metadata")}
Expand All @@ -172,6 +232,14 @@ SessionInfoContent.propTypes = {
created: PropTypes.string,
last_modified: PropTypes.string,
description: PropTypes.string,
preprocessing: PropTypes.shape({
steps: PropTypes.arrayOf(
PropTypes.shape({
converter: PropTypes.string,
scope: PropTypes.array,
}),
),
}),
}),
datasets: PropTypes.array,
tasks: PropTypes.array,
Expand Down
6 changes: 5 additions & 1 deletion DashAI/front/src/components/shared/InfoModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export default function InfoModal({
left: "50%",
transform: "translate(-50%, -50%)",
width: { xs: "90%", sm: 500 },
maxHeight: "85vh",
display: "flex",
flexDirection: "column",
bgcolor: "background.paper",
borderRadius: 2,
boxShadow: 12,
Expand All @@ -50,6 +53,7 @@ export default function InfoModal({
justifyContent: "space-between",
alignItems: "center",
borderBottom: "1px solid rgba(255, 255, 255, 0.1)",
flexShrink: 0,
}}
>
<Box>
Expand All @@ -71,7 +75,7 @@ export default function InfoModal({
</IconButton>
</Box>

<Box sx={{ p: 6 }}>
<Box sx={{ p: 6, overflowY: "auto", flex: 1, minHeight: 0 }}>
{extraContent}

{rows.length > 0 && (
Expand Down
1 change: 1 addition & 0 deletions DashAI/front/src/utils/i18n/locales/de/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"addModelToSession": "Modell zur Sitzung hinzufügen",
"allRepetitions": "Alle Wiederholungen",
"alternativeHypothesis": "Alternativhypothese",
"appliedConverters": "Angewendete Converter",
"applyPreprocessing": "Vorverarbeitung anwenden",
"applyPreprocessingDescription": "Die ausgewählten Converter werden nur anhand der Trainingsdaten angepasst und auf den Rest angewendet, um Datenlecks zu vermeiden. Wird dies nicht angewendet, trainiert das Modell mit den Daten wie sie sind.",
"availableExplainers": "Verfügbare Erklärungsmodelle",
Expand Down
1 change: 1 addition & 0 deletions DashAI/front/src/utils/i18n/locales/en/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
"predictionsCount_other": "• <1>{{count}}</1> predictions",
"divideColumnsAndSplits": "Divide columns and configure dataset splits",
"prepareDataset": "Prepare Dataset",
"appliedConverters": "Applied Converters",
"applyPreprocessing": "Apply preprocessing",
"applyPreprocessingDescription": "Selected converters are fit only on training data and applied to the rest, to avoid data leakage. If not applied, the model trains on the data as-is.",
"preprocessingOptional": "Preprocessing (optional)",
Expand Down
1 change: 1 addition & 0 deletions DashAI/front/src/utils/i18n/locales/es/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
"predictionsCount_other": "• <1>{{count}}</1> predicciones",
"divideColumnsAndSplits": "Divide columnas y configura las particiones del dataset",
"prepareDataset": "Preparar Dataset",
"appliedConverters": "Converters Aplicados",
"applyPreprocessing": "Aplicar preprocesamiento",
"applyPreprocessingDescription": "Los converters seleccionados se ajustan solo sobre los datos de entrenamiento y se aplican al resto, para evitar fuga de datos. Si no se aplica, el modelo se entrena con los datos tal como están.",
"preprocessingOptional": "Preprocesamiento (opcional)",
Expand Down
1 change: 1 addition & 0 deletions DashAI/front/src/utils/i18n/locales/pt/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"addModelToSession": "Adicionar Modelo à Sessão",
"allRepetitions": "Todas as Repetições",
"alternativeHypothesis": "Hipótese Alternativa",
"appliedConverters": "Conversores Aplicados",
"applyPreprocessing": "Aplicar pré-processamento",
"applyPreprocessingDescription": "Os conversores selecionados são ajustados apenas com os dados de treinamento e aplicados ao restante, para evitar vazamento de dados. Se não for aplicado, o modelo treina com os dados como estão.",
"availableExplainers": "Explicadores Disponíveis",
Expand Down
1 change: 1 addition & 0 deletions DashAI/front/src/utils/i18n/locales/zh/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"addModelToSession": "将模型添加到会话",
"allRepetitions": "所有重复",
"alternativeHypothesis": "备择假设",
"appliedConverters": "已应用的转换器",
"applyPreprocessing": "应用预处理",
"applyPreprocessingDescription": "所选的转换器仅在训练数据上拟合,然后应用于其余数据,以避免数据泄漏。如果不应用,模型将按原样使用数据进行训练。",
"availableExplainers": "可用解释器",
Expand Down
Loading