Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

[webui] Update default metric tooltip #3316

Merged
merged 5 commits into from
Jan 29, 2021
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
5 changes: 5 additions & 0 deletions ts/webui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ import { isManagerExperimentPage } from './static/function';
import NavCon from './components/NavCon';
import MessageInfo from './components/modals/MessageInfo';
import { SlideNavBtns } from './components/slideNav/SlideNavBtns';
const echarts = require('echarts/lib/echarts');
echarts.registerTheme('nni_theme', {
color: '#3c8dbc'
});
import './App.scss';
import './static/style/common.scss';
import './static/style/trialsDetail.scss';

interface AppState {
interval: number;
Expand Down
12 changes: 7 additions & 5 deletions ts/webui/src/components/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Trial } from '../static/model/trial';
import { AppContext } from '../App';
import { Title } from './overview/Title';
import SuccessTable from './overview/table/SuccessTable';
import Accuracy from './overview/Accuracy';
import DefaultPoint from './trial-detail/DefaultMetricPoint';
import { BasicInfo } from './overview/params/BasicInfo';
import { ExpDuration } from './overview/count/ExpDuration';
import { ExpDurationContext } from './overview/count/ExpDurationContext';
Expand Down Expand Up @@ -60,11 +60,9 @@ class Overview extends React.Component<{}, OverviewState> {
const bestTrials = this.findBestTrials();
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const bestAccuracy = bestTrials.length > 0 ? bestTrials[0].accuracy! : NaN;
const accuracyGraphData = this.generateAccuracyGraph(bestTrials);
const noDataMessage = bestTrials.length > 0 ? '' : 'No data';

const maxExecDuration = EXPERIMENT.profile.params.maxExecDuration;
const execDuration = EXPERIMENT.profile.execDuration;

return (
<AppContext.Consumer>
{(value): React.ReactNode => {
Expand Down Expand Up @@ -167,7 +165,11 @@ class Overview extends React.Component<{}, OverviewState> {
</div>
</Stack>
<div className='overviewChart'>
<Accuracy accuracyData={accuracyGraphData} accNodata={noDataMessage} />
<DefaultPoint
trialIds={bestTrials.map(trial => trial.info.trialJobId)}
chartHeight={300}
hasBestCurve={false}
/>
<SuccessTable
trialIds={bestTrials.map(trial => trial.info.trialJobId)}
updateOverviewPage={updateOverviewPage}
Expand Down
13 changes: 4 additions & 9 deletions ts/webui/src/components/TrialsDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Duration from './trial-detail/Duration';
import Para from './trial-detail/Para';
import Intermediate from './trial-detail/Intermediate';
import TableList from './trial-detail/TableList';
import '../static/style/trialsDetail.scss';
import '../static/style/search.scss';

interface TrialDetailState {
Expand Down Expand Up @@ -53,22 +52,18 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
{/* <PivotItem tab={this.titleOfacc} key="1"> doesn't work*/}
<PivotItem headerText='Default metric' itemIcon='HomeGroup' key='Default metric'>
<Stack className='graph'>
<DefaultPoint trialIds={trialIds} visible={whichChart === 'Default metric'} />
<DefaultPoint trialIds={trialIds} hasBestCurve={true} chartHeight={402} />
</Stack>
</PivotItem>
{/* <PivotItem tab={this.titleOfhyper} key="2"> */}
<PivotItem headerText='Hyper-parameter' itemIcon='Equalizer' key='Hyper-parameter'>
<Stack className='graph'>
<Para
trials={source}
searchSpace={EXPERIMENT.searchSpaceNew}
whichChart={whichChart}
/>
<Para trials={source} searchSpace={EXPERIMENT.searchSpaceNew} />
</Stack>
</PivotItem>
{/* <PivotItem tab={this.titleOfDuration} key="3"> */}
<PivotItem headerText='Duration' itemIcon='BarChartHorizontal' key='Duration'>
<Duration source={source} whichChart={whichChart} />
<Duration source={source} />
</PivotItem>
{/* <PivotItem tab={this.titleOfIntermediate} key="4"> */}
<PivotItem
Expand All @@ -77,7 +72,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
key='Intermediate result'
>
{/* *why this graph has small footprint? */}
<Intermediate source={source} whichChart={whichChart} />
<Intermediate source={source} />
</PivotItem>
</Pivot>
</div>
Expand Down
32 changes: 0 additions & 32 deletions ts/webui/src/components/overview/Accuracy.tsx

This file was deleted.

1 change: 1 addition & 0 deletions ts/webui/src/components/public-child/DefaultMetric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import { TRIALS } from '../../static/datamodel';
import { formatAccuracy } from '../../static/function';

// oview page table: default metric column render
interface DefaultMetricProps {
trialId: string;
}
Expand Down
21 changes: 11 additions & 10 deletions ts/webui/src/components/trial-detail/DefaultMetricPoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const EmptyGraph = {

interface DefaultPointProps {
trialIds: string[];
visible: boolean;
chartHeight: number;
hasBestCurve: boolean;
}

interface DefaultPointState {
Expand All @@ -47,10 +48,6 @@ class DefaultPoint extends React.Component<DefaultPointProps, DefaultPointState>
this.setState({ bestCurveEnabled: checked });
};

shouldComponentUpdate(nextProps: DefaultPointProps): boolean {
return nextProps.visible;
}

metricDataZoom = (e: EventMap): void => {
if (e.batch !== undefined) {
this.setState(() => ({
Expand All @@ -69,6 +66,7 @@ class DefaultPoint extends React.Component<DefaultPointProps, DefaultPointState>
tooltip: {
trigger: 'item',
enterable: true,
confine: true, // confirm always show tooltip box rather than hidden by background
position: (point: number[], data: TooltipForAccuracy): number[] => [
data.data[0] < maxSequenceId ? point[0] : point[0] - 300,
80
Expand Down Expand Up @@ -149,24 +147,27 @@ class DefaultPoint extends React.Component<DefaultPointProps, DefaultPointState>
}

render(): React.ReactNode {
const { hasBestCurve, chartHeight } = this.props;
const graph = this.generateGraph();
const accNodata = graph === EmptyGraph ? 'No data' : '';
const onEvents = { dataZoom: this.metricDataZoom };

return (
<div>
<Stack horizontalAlign='end' className='default-metric'>
<Toggle label='Optimization curve' inlineLabel onChange={this.loadDefault} />
</Stack>
{hasBestCurve && (
<Stack horizontalAlign='end' className='default-metric'>
<Toggle label='Optimization curve' inlineLabel onChange={this.loadDefault} />
</Stack>
)}
<div className='default-metric-graph'>
<ReactEcharts
option={graph}
style={{
width: '100%',
height: 402,
height: chartHeight,
margin: '0 auto'
}}
theme='my_theme'
theme='nni_theme'
notMerge={true} // update now
onEvents={onEvents}
/>
Expand Down
8 changes: 3 additions & 5 deletions ts/webui/src/components/trial-detail/Duration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ interface Runtrial {

interface DurationProps {
source: Array<TableObj>;
whichChart: string;
}

interface DurationState {
Expand Down Expand Up @@ -177,21 +176,20 @@ class Duration extends React.Component<DurationProps, DurationState> {
componentDidUpdate(prevProps: DurationProps): void {
// add this if to prevent endless loop
if (this.props.source !== prevProps.source) {
if (this.props.whichChart === 'Duration') {
this.drawDurationGraph(this.props.source);
}
this.drawDurationGraph(this.props.source);
}
}

render(): React.ReactNode {
const { durationSource } = this.state;
const onEvents = { dataZoom: this.durationDataZoom };

return (
<div>
<ReactEcharts
option={durationSource}
style={{ width: '94%', height: 412, margin: '0 auto', marginTop: 15 }}
theme='my_theme'
theme='nni_theme'
notMerge={true} // update now
onEvents={onEvents}
/>
Expand Down
21 changes: 9 additions & 12 deletions ts/webui/src/components/trial-detail/Intermediate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface IntermediateState {

interface IntermediateProps {
source: Array<TableObj>;
whichChart: string;
}

class Intermediate extends React.Component<IntermediateProps, IntermediateState> {
Expand Down Expand Up @@ -230,20 +229,18 @@ class Intermediate extends React.Component<IntermediateProps, IntermediateState>
componentDidUpdate(prevProps: IntermediateProps, prevState: any): void {
if (this.props.source !== prevProps.source || this.state.isFilter !== prevState.isFilter) {
const { isFilter, filterSource } = this.state;
const { whichChart, source } = this.props;
const { source } = this.props;

if (whichChart === 'Intermediate result') {
if (isFilter === true) {
const pointVal = this.pointInput !== null ? this.pointInput.value : '';
const minVal = this.minValInput !== null ? this.minValInput.value : '';
if (pointVal === '' && minVal === '') {
this.drawIntermediate(source);
} else {
this.drawIntermediate(filterSource);
}
} else {
if (isFilter === true) {
const pointVal = this.pointInput !== null ? this.pointInput.value : '';
const minVal = this.minValInput !== null ? this.minValInput.value : '';
if (pointVal === '' && minVal === '') {
this.drawIntermediate(source);
} else {
this.drawIntermediate(filterSource);
}
} else {
this.drawIntermediate(source);
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions ts/webui/src/components/trial-detail/Para.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface ParaState {
interface ParaProps {
trials: Array<TableObj>;
searchSpace: SearchSpace;
whichChart: string;
}

class Para extends React.Component<ParaProps, ParaState> {
Expand Down Expand Up @@ -81,10 +80,7 @@ class Para extends React.Component<ParaProps, ParaState> {
componentDidUpdate(prevProps: ParaProps): void {
// FIXME: redundant update
if (this.props.trials !== prevProps.trials || this.props.searchSpace !== prevProps.searchSpace) {
const { whichChart } = this.props;
if (whichChart === 'Hyper-parameter') {
this.renderParallelCoordinates();
}
this.renderParallelCoordinates();
}
}

Expand Down
4 changes: 0 additions & 4 deletions ts/webui/src/components/trial-detail/TableList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ import ExpandableDetails from '../public-child/ExpandableDetails';
import PaginationTable from '../public-child/PaginationTable';
import { Trial } from '../../static/model/trial';

const echarts = require('echarts/lib/echarts');
require('echarts/lib/chart/line');
require('echarts/lib/component/tooltip');
require('echarts/lib/component/title');
echarts.registerTheme('my_theme', {
color: '#3c8dbc'
});

type SearchOptionType = 'id' | 'trialnum' | 'status' | 'parameters';
const searchOptionLiterals = {
Expand Down
10 changes: 0 additions & 10 deletions ts/webui/src/static/style/overview/overview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,3 @@ $boxGapPadding: 10px;
.overviewChart {
margin-top: 20px;
}

.defaultMetricContainer {
position: relative;

.showMess {
position: absolute;
top: 42%;
left: 48%;
}
}