Skip to content
代码片段 群组 项目
未验证 提交 61e2644c 编辑于 作者: Illya Klymov's avatar Illya Klymov 提交者: GitLab
浏览文件

Merge branch '509272-model-experiment-empty-state-for-performance-graph' into 'master'

Model Experiment: Empty state for performance graph

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/175688



Merged-by: default avatarIllya Klymov <iklymov@gitlab.com>
Approved-by: default avatarAlper Akgun <aakgun@gitlab.com>
Reviewed-by: default avatarAlper Akgun <aakgun@gitlab.com>
Reviewed-by: default avatarFred de Gier <fdegier@gitlab.com>
Co-authored-by: default avatarfdegier <fdegier@gitlab.com>
No related branches found
No related tags found
无相关合并请求
<script> <script>
import { GlLineChart } from '@gitlab/ui/dist/charts'; import { GlLineChart } from '@gitlab/ui/dist/charts';
import { GlEmptyState } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { CREATE_EXPERIMENT_HELP_PATH } from '~/ml/experiment_tracking/routes/experiments/index/constants';
export default { export default {
name: 'PerformanceGraph', name: 'PerformanceGraph',
components: { GlLineChart }, components: { GlLineChart, GlEmptyState },
props: { props: {
candidates: { candidates: {
type: Array, type: Array,
...@@ -14,6 +16,11 @@ export default { ...@@ -14,6 +16,11 @@ export default {
type: Array, type: Array,
required: true, required: true,
}, },
emptyStateSvgPath: {
type: String,
required: false,
default: '',
},
}, },
data() { data() {
return { return {
...@@ -24,6 +31,11 @@ export default { ...@@ -24,6 +31,11 @@ export default {
i18n: { i18n: {
xAxisLabel: s__('ExperimentTracking|Candidate'), xAxisLabel: s__('ExperimentTracking|Candidate'),
yAxisLabel: s__('ExperimentTracking|Metric value'), yAxisLabel: s__('ExperimentTracking|Metric value'),
createNewCandidateLabel: s__('ExperimentTracking|Create candidate using MLflow'),
emptyStateLabel: s__('ExperimentTracking|No candidates'),
emptyStateDescriptionLabel: s__(
'ExperimentTracking|Performance graph will be shown when candidates with logged metrics are available',
),
}, },
computed: { computed: {
graphData() { graphData() {
...@@ -55,6 +67,12 @@ export default { ...@@ -55,6 +67,12 @@ export default {
toolbox: { show: true }, toolbox: { show: true },
}; };
}, },
showGraph() {
return this.candidates.length > 0 && this.metricNames.length > 0;
},
},
constants: {
CREATE_EXPERIMENT_HELP_PATH,
}, },
methods: { methods: {
formatTooltipText(params) { formatTooltipText(params) {
...@@ -70,6 +88,7 @@ export default { ...@@ -70,6 +88,7 @@ export default {
<template> <template>
<gl-line-chart <gl-line-chart
v-if="showGraph"
:data="graphData" :data="graphData"
:option="graphOptions" :option="graphOptions"
show-legend show-legend
...@@ -87,4 +106,14 @@ export default { ...@@ -87,4 +106,14 @@ export default {
</div> </div>
</template> </template>
</gl-line-chart> </gl-line-chart>
<gl-empty-state
v-else
:title="$options.i18n.emptyStateLabel"
:secondary-button-text="$options.i18n.createNewCandidateLabel"
:secondary-button-link="$options.constants.CREATE_EXPERIMENT_HELP_PATH"
:svg-path="emptyStateSvgPath"
:svg-height="null"
:description="$options.i18n.emptyStateDescriptionLabel"
class="gl-py-8"
/>
</template> </template>
...@@ -22932,12 +22932,21 @@ msgstr "" ...@@ -22932,12 +22932,21 @@ msgstr ""
msgid "ExperimentTracking|Candidate" msgid "ExperimentTracking|Candidate"
msgstr "" msgstr ""
   
msgid "ExperimentTracking|Create candidate using MLflow"
msgstr ""
msgid "ExperimentTracking|Metric value" msgid "ExperimentTracking|Metric value"
msgstr "" msgstr ""
   
msgid "ExperimentTracking|No candidates"
msgstr ""
msgid "ExperimentTracking|Performance" msgid "ExperimentTracking|Performance"
msgstr "" msgstr ""
   
msgid "ExperimentTracking|Performance graph will be shown when candidates with logged metrics are available"
msgstr ""
msgid "Experiments" msgid "Experiments"
msgstr "" msgstr ""
   
import { GlLineChart } from '@gitlab/ui/dist/charts'; import { GlLineChart } from '@gitlab/ui/dist/charts';
import { GlEmptyState } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import PerformanceGraph from '~/ml/experiment_tracking/components/performance_graph.vue'; import PerformanceGraph from '~/ml/experiment_tracking/components/performance_graph.vue';
import { MOCK_CANDIDATES } from '../routes/experiments/show/mock_data'; import { MOCK_CANDIDATES } from '../routes/experiments/show/mock_data';
...@@ -12,12 +13,14 @@ describe('PerformanceGraph', () => { ...@@ -12,12 +13,14 @@ describe('PerformanceGraph', () => {
propsData: { propsData: {
candidates, candidates,
metricNames, metricNames,
emptyStateSvgPath: 'illustrations/status/status-new-md.svg',
}, },
}); });
}; };
const findGraph = () => wrapper.findComponent(PerformanceGraph); const findGraph = () => wrapper.findComponent(PerformanceGraph);
const findLineChart = () => findGraph().findComponent(GlLineChart); const findLineChart = () => findGraph().findComponent(GlLineChart);
const findEmptyState = () => wrapper.findComponent(GlEmptyState);
describe('rendering', () => { describe('rendering', () => {
it('renders the component', () => { it('renders the component', () => {
...@@ -25,6 +28,7 @@ describe('PerformanceGraph', () => { ...@@ -25,6 +28,7 @@ describe('PerformanceGraph', () => {
expect(findGraph().props('candidates')).toEqual(MOCK_CANDIDATES); expect(findGraph().props('candidates')).toEqual(MOCK_CANDIDATES);
expect(findGraph().props('metricNames')).toEqual(MOCK_METRICS); expect(findGraph().props('metricNames')).toEqual(MOCK_METRICS);
expect(findEmptyState().exists()).toBe(false);
}); });
it('renders the correct data', () => { it('renders the correct data', () => {
...@@ -39,4 +43,27 @@ describe('PerformanceGraph', () => { ...@@ -39,4 +43,27 @@ describe('PerformanceGraph', () => {
expect(findLineChart().props('data')[2].data.length).toBe(1); expect(findLineChart().props('data')[2].data.length).toBe(1);
}); });
}); });
describe('empty state', () => {
it('should show empty state if candidates are missing', () => {
createWrapper([], MOCK_METRICS);
expect(findLineChart().exists()).toBe(false);
expect(findEmptyState().exists()).toBe(true);
});
it('should show empty state if metric names are missing', () => {
createWrapper(MOCK_CANDIDATES, []);
expect(findLineChart().exists()).toBe(false);
expect(findEmptyState().exists()).toBe(true);
});
it('should show empty state if candidates and metric names are missing', () => {
createWrapper([], []);
expect(findLineChart().exists()).toBe(false);
expect(findEmptyState().exists()).toBe(true);
});
});
}); });
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册