Skip to content

Commit

Permalink
[ML] DF Analytics jobs list: improve job details analysis stats view …
Browse files Browse the repository at this point in the history
…in expanded row (#76196) (#76550)

* move analysis stats to own section in expanded row

* fix type errors

* move stats to separate tab in expanded row

* handle parameters and hyperparameters not defined
  • Loading branch information
alvarezmelissa87 authored Sep 2, 2020
1 parent a8f6c5c commit f0bcbca
Showing 1 changed file with 68 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { i18n } from '@kbn/i18n';
import { formatHumanReadableDateTimeSeconds } from '../../../../../util/date_utils';

import { DataFrameAnalyticsListRow } from './common';
import { ExpandedRowDetailsPane, SectionConfig } from './expanded_row_details_pane';
import { ExpandedRowDetailsPane, SectionConfig, SectionItem } from './expanded_row_details_pane';
import { ExpandedRowJsonPane } from './expanded_row_json_pane';
import { ProgressBar } from './progress_bar';
import {
Expand All @@ -28,6 +28,7 @@ import { getTaskStateBadge } from './use_columns';
import { getDataFrameAnalyticsProgressPhase, isCompletedAnalyticsJob } from './common';
import {
isRegressionAnalysis,
getAnalysisType,
ANALYSIS_CONFIG_TYPE,
REGRESSION_STATS,
isRegressionEvaluateResponse,
Expand Down Expand Up @@ -76,6 +77,7 @@ export const ExpandedRow: FC<Props> = ({ item }) => {
const resultsField = item.config.dest.results_field;
const jobIsCompleted = isCompletedAnalyticsJob(item.stats);
const isRegressionJob = isRegressionAnalysis(item.config.analysis);
const analysisType = getAnalysisType(item.config.analysis);

const loadData = async () => {
setIsLoadingGeneralization(true);
Expand Down Expand Up @@ -160,25 +162,34 @@ export const ExpandedRow: FC<Props> = ({ item }) => {

const stateValues: any = { ...item.stats };

const analysisStatsValues = stateValues.analysis_stats
? stateValues.analysis_stats[`${analysisType}_stats`]
: undefined;

if (item.config?.description) {
stateValues.description = item.config.description;
}
delete stateValues.progress;

const state: SectionConfig = {
title: i18n.translate('xpack.ml.dataframe.analyticsList.expandedRow.tabs.jobSettings.state', {
defaultMessage: 'State',
}),
items: Object.entries(stateValues).map(([stateKey, stateValue]) => {
const stateItems = Object.entries(stateValues)
.map(([stateKey, stateValue]) => {
const title = stateKey.toString();
if (title === 'state') {
return {
title,
description: getTaskStateBadge(getItemDescription(stateValue)),
};
} else if (title !== 'analysis_stats') {
return { title, description: getItemDescription(stateValue) };
}
return { title, description: getItemDescription(stateValue) };
})
.filter((stateItem) => stateItem !== undefined);

const state: SectionConfig = {
title: i18n.translate('xpack.ml.dataframe.analyticsList.expandedRow.tabs.jobSettings.state', {
defaultMessage: 'State',
}),
items: stateItems as SectionItem[],
position: 'left',
};

Expand All @@ -204,7 +215,7 @@ export const ExpandedRow: FC<Props> = ({ item }) => {
};
}),
],
position: 'left',
position: 'right',
};

const stats: SectionConfig = {
Expand All @@ -221,9 +232,39 @@ export const ExpandedRow: FC<Props> = ({ item }) => {
{ title: 'model_memory_limit', description: item.config.model_memory_limit },
{ title: 'version', description: item.config.version },
],
position: 'right',
position: 'left',
};

const analysisStats: SectionConfig | undefined = analysisStatsValues
? {
title: i18n.translate(
'xpack.ml.dataframe.analyticsList.expandedRow.tabs.jobSettings.analysisStats',
{
defaultMessage: 'Analysis stats',
}
),
items: [
{
title: 'timestamp',
description: formatHumanReadableDateTimeSeconds(
moment(analysisStatsValues.timestamp).unix() * 1000
),
},
{
title: 'timing_stats',
description: getItemDescription(analysisStatsValues.timing_stats),
},
...Object.entries(
analysisStatsValues.parameters || analysisStatsValues.hyperparameters || {}
).map(([stateKey, stateValue]) => {
const title = stateKey.toString();
return { title, description: getItemDescription(stateValue) };
}),
],
position: 'right',
}
: undefined;

if (jobIsCompleted && isRegressionJob) {
stats.items.push(
{
Expand Down Expand Up @@ -309,13 +350,30 @@ export const ExpandedRow: FC<Props> = ({ item }) => {
);
}

const detailsSections: SectionConfig[] = [state, progress];
const statsSections: SectionConfig[] = [stats];

if (analysisStats !== undefined) {
statsSections.push(analysisStats);
}

const tabs = [
{
id: 'ml-analytics-job-details',
name: i18n.translate('xpack.ml.dataframe.analyticsList.expandedRow.tabs.jobSettingsLabel', {
defaultMessage: 'Job details',
}),
content: <ExpandedRowDetailsPane sections={[state, progress, stats]} />,
content: <ExpandedRowDetailsPane sections={detailsSections} />,
},
{
id: 'ml-analytics-job-stats',
name: i18n.translate(
'xpack.ml.dataframe.analyticsList.analyticsDetails.tabs.analyticsStatsLabel',
{
defaultMessage: 'Job stats',
}
),
content: <ExpandedRowDetailsPane sections={statsSections} />,
},
{
id: 'ml-analytics-job-json',
Expand Down

0 comments on commit f0bcbca

Please sign in to comment.