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

Show error message when final result doesn't have default metric #2162

Merged
merged 5 commits into from
Mar 25, 2020
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 src/webui/src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@
color: #333;
}
}

.warning{
padding-bottom: 15px;
background-color: #f2f2f2;
}
43 changes: 40 additions & 3 deletions src/webui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Stack } from 'office-ui-fabric-react';
import { COLUMN } from './static/const';
import { EXPERIMENT, TRIALS } from './static/datamodel';
import NavCon from './components/NavCon';
import MessageInfo from './components/Modals/MessageInfo';
import './App.scss';

interface AppState {
Expand All @@ -11,10 +12,13 @@ interface AppState {
experimentUpdateBroadcast: number;
trialsUpdateBroadcast: number;
metricGraphMode: 'max' | 'min'; // tuner's optimize_mode filed
isillegalFinal: boolean;
expWarningMessage: string;
}

class App extends React.Component<{}, AppState> {
private timerId!: number | null;
private dataFormatimer!: number;

constructor(props: {}) {
super(props);
Expand All @@ -23,7 +27,9 @@ class App extends React.Component<{}, AppState> {
columnList: COLUMN,
experimentUpdateBroadcast: 0,
trialsUpdateBroadcast: 0,
metricGraphMode: 'max'
metricGraphMode: 'max',
isillegalFinal: false,
expWarningMessage: ''
};
}

Expand All @@ -33,8 +39,34 @@ class App extends React.Component<{}, AppState> {
this.setState(state => ({ trialsUpdateBroadcast: state.trialsUpdateBroadcast + 1 }));
this.timerId = window.setTimeout(this.refresh, this.state.interval * 1000);
this.setState({ metricGraphMode: (EXPERIMENT.optimizeMode === 'minimize' ? 'min' : 'max') });
// final result is legal
// get a succeed trial,see final result data's format
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.dataFormatimer = window.setInterval(this.getFinalDataFormat, this.state.interval * 1000);
}

getFinalDataFormat = (): void => {
for(let i = 0; this.state.isillegalFinal === false; i++){
if(TRIALS.succeededTrials()[0] !== undefined && TRIALS.succeededTrials()[0].final !== undefined){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we don't have succeeded trials?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 64, quit for loop.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean TRIALS.succeddedTrials() will return an empty array, right? What happens to x[0] if x is an empty array?

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const oneSucceedTrial = JSON.parse(JSON.parse(TRIALS.succeededTrials()[0].final!.data));
if (typeof oneSucceedTrial === 'number' || oneSucceedTrial.hasOwnProperty('default')) {
window.clearInterval(this.dataFormatimer);
break;
} else {
// illegal final data
this.setState(() => ({
isillegalFinal: true,
expWarningMessage: 'WebUI support final result as number and dictornary includes default keys, your experiment final result is illegal, please check your data.'
}));
window.clearInterval(this.dataFormatimer);
}
} else {
break;
}
}
}

changeInterval = (interval: number): void => {
this.setState({ interval });
if (this.timerId === null && interval !== 0) {
Expand All @@ -54,7 +86,9 @@ class App extends React.Component<{}, AppState> {
}

render(): React.ReactNode {
const { interval, columnList, experimentUpdateBroadcast, trialsUpdateBroadcast, metricGraphMode } = this.state;
const { interval, columnList, experimentUpdateBroadcast, trialsUpdateBroadcast,
metricGraphMode, isillegalFinal, expWarningMessage
} = this.state;
if (experimentUpdateBroadcast === 0 || trialsUpdateBroadcast === 0) {
return null; // TODO: render a loading page
}
Expand All @@ -73,11 +107,14 @@ class App extends React.Component<{}, AppState> {
<Stack className="nni" style={{ minHeight: window.innerHeight }}>
<div className="header">
<div className="headerCon">
<NavCon changeInterval={this.changeInterval} refreshFunction={this.lastRefresh}/>
<NavCon changeInterval={this.changeInterval} refreshFunction={this.lastRefresh} />
</div>
</div>
<Stack className="contentBox">
<Stack className="content">
{isillegalFinal && <div className="warning">
<MessageInfo info={expWarningMessage} typeInfo="warning" />
</div>}
{reactPropsChildren}
</Stack>
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion src/webui/src/static/model/trial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Trial implements TableObj {
private metricsInitialized: boolean = false;
private infoField: TrialJobInfo | undefined;
private intermediates: (MetricDataRecord | undefined)[] = [ ];
private final: MetricDataRecord | undefined;
public final: MetricDataRecord | undefined;
private finalAcc: number | undefined;

constructor(info?: TrialJobInfo, metrics?: MetricDataRecord[]) {
Expand Down