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

Commit

Permalink
[WebUI] fix issue#2530: duration and intermediate results pictures do…
Browse files Browse the repository at this point in the history
…n't update (#2531)
  • Loading branch information
Lijiaoa authored Jun 12, 2020
1 parent 89fa23c commit 54496c2
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 70 deletions.
14 changes: 8 additions & 6 deletions src/webui/src/components/Modals/CustomizedTrial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,16 @@ class Customize extends React.Component<CustomizeProps, CustomizeState> {
}
}

componentWillReceiveProps(nextProps: CustomizeProps): void {
const { copyTrialId } = nextProps;
if (copyTrialId !== undefined && TRIALS.getTrial(copyTrialId) !== undefined) {
const originCopyTrialPara = TRIALS.getTrial(copyTrialId).description.parameters;
this.setState(() => ({ copyTrialParameter: originCopyTrialPara }));
componentDidUpdate(prevProps: CustomizeProps): void {
if (this.props.copyTrialId !== prevProps.copyTrialId) {
const { copyTrialId } = this.props;
if (copyTrialId !== undefined && TRIALS.getTrial(copyTrialId) !== undefined) {
const originCopyTrialPara = TRIALS.getTrial(copyTrialId).description.parameters;
this.setState(() => ({ copyTrialParameter: originCopyTrialPara }));
}
}
}

render(): React.ReactNode {
const { closeCustomizeModal, visible } = this.props;
const { isShowSubmitSucceed, isShowSubmitFailed, isShowWarning, customID, copyTrialParameter } = this.state;
Expand Down
18 changes: 9 additions & 9 deletions src/webui/src/components/TrialsDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState>
super(props);
this.state = {
tablePageSize: 20,
whichGraph: '1',
whichGraph: 'Default metric',
searchType: 'Id',
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-function-return-type
searchFilter: trial => true
Expand Down Expand Up @@ -81,8 +81,8 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState>
}
}

handleWhichTabs = (activeKey: string): void => {
this.setState({ whichGraph: activeKey });
handleWhichTabs = (item: any): void => {
this.setState({whichGraph: item.props.headerText});
}

updateSearchFilterType = (event: React.FormEvent<HTMLDivElement>, item: IDropdownOption | undefined): void => {
Expand All @@ -109,19 +109,19 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState>
return (
<div>
<div className="trial" id="tabsty">
<Pivot defaultSelectedKey={"0"} className="detial-title">
<Pivot defaultSelectedKey={"0"} className="detial-title" onLinkClick={this.handleWhichTabs} selectedKey={whichGraph}>
{/* <PivotItem tab={this.titleOfacc} key="1"> doesn't work*/}
<PivotItem headerText="Default metric" itemIcon="HomeGroup" key="1">
<PivotItem headerText="Default metric" itemIcon="HomeGroup" key="Default metric">
<Stack className="graph">
<DefaultPoint
trialIds={trialIds}
visible={whichGraph === '1'}
visible={whichGraph === 'Default metric'}
trialsUpdateBroadcast={this.props.trialsUpdateBroadcast}
/>
</Stack>
</PivotItem>
{/* <PivotItem tab={this.titleOfhyper} key="2"> */}
<PivotItem headerText="Hyper-parameter" itemIcon="Equalizer" key="2">
<PivotItem headerText="Hyper-parameter" itemIcon="Equalizer" key="Hyper-parameter">
<Stack className="graph">
<Para
dataSource={source}
Expand All @@ -131,11 +131,11 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState>
</Stack>
</PivotItem>
{/* <PivotItem tab={this.titleOfDuration} key="3"> */}
<PivotItem headerText="Duration" itemIcon="BarChartHorizontal" key="3">
<PivotItem headerText="Duration" itemIcon="BarChartHorizontal" key="Duration">
<Duration source={source} whichGraph={whichGraph} />
</PivotItem>
{/* <PivotItem tab={this.titleOfIntermediate} key="4"> */}
<PivotItem headerText="Intermediate result" itemIcon="StackedLineChart" key="4">
<PivotItem headerText="Intermediate result" itemIcon="StackedLineChart" key="Intermediate result">
{/* *why this graph has small footprint? */}
<Intermediate source={source} whichGraph={whichGraph} />
</PivotItem>
Expand Down
8 changes: 5 additions & 3 deletions src/webui/src/components/overview/SuccessTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ class SuccessTable extends React.Component<SuccessTableProps, SuccessTableState>
}
];

componentWillReceiveProps(nextProps: SuccessTableProps): void {
const { trialIds } = nextProps;
this.setState(() => ({ source: TRIALS.table(trialIds) }));
componentDidUpdate(prevProps: SuccessTableProps): void {
if(this.props.trialIds !== prevProps.trialIds){
const { trialIds } = this.props;
this.setState(() => ({ source: TRIALS.table(trialIds) }));
}
}

render(): React.ReactNode {
Expand Down
33 changes: 5 additions & 28 deletions src/webui/src/components/trial-detail/Duration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,36 +167,13 @@ class Duration extends React.Component<DurationProps, DurationState> {
this.drawDurationGraph(source);
}

componentWillReceiveProps(nextProps: DurationProps): void {
const { whichGraph, source } = nextProps;
if (whichGraph === '3') {
this.drawDurationGraph(source);
}
}

shouldComponentUpdate(nextProps: DurationProps): boolean {

const { whichGraph, source } = nextProps;
if (whichGraph === '3') {
const beforeSource = this.props.source;
if (whichGraph !== this.props.whichGraph) {
return true;
}

if (source.length !== beforeSource.length) {
return true;
}

if (beforeSource[beforeSource.length - 1] !== undefined) {
if (source[source.length - 1].duration !== beforeSource[beforeSource.length - 1].duration) {
return true;
}
if (source[source.length - 1].status !== beforeSource[beforeSource.length - 1].status) {
return true;
}
componentDidUpdate(prevProps: DurationProps): void {
// add this if to prevent endless loop
if (this.props.source !== prevProps.source) {
if (this.props.whichGraph === 'Duration') {
this.drawDurationGraph(this.props.source);
}
}
return false;
}

render(): React.ReactNode {
Expand Down
26 changes: 14 additions & 12 deletions src/webui/src/components/trial-detail/Intermediate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,23 @@ class Intermediate extends React.Component<IntermediateProps, IntermediateState>
this.drawIntermediate(source);
}

componentWillReceiveProps(nextProps: IntermediateProps, nextState: IntermediateState): void {
const { isFilter, filterSource } = nextState;
const { whichGraph, source } = nextProps;
componentDidUpdate(prevProps: IntermediateProps, prevState: any): void {
if (this.props.source !== prevProps.source || this.state.isFilter !== prevState.isFilter) {
const { isFilter, filterSource } = this.state;
const { whichGraph, source } = this.props;

if (whichGraph === '4') {
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);
if (whichGraph === '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 {
this.drawIntermediate(filterSource);
this.drawIntermediate(source);
}
} else {
this.drawIntermediate(source);
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/webui/src/components/trial-detail/Para.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,12 @@ class Para extends React.Component<ParaProps, ParaState> {
this.reInit();
}

componentWillReceiveProps(nextProps: ParaProps): void {
const { dataSource, expSearchSpace, whichGraph } = nextProps;
if (whichGraph === '2') {
this.hyperParaPic(dataSource, expSearchSpace);
componentDidUpdate(prevProps: ParaProps): void {
if(this.props.dataSource !== prevProps.dataSource) {
const { dataSource, expSearchSpace, whichGraph } = this.props;
if (whichGraph === 'Hyper-parameter') {
this.hyperParaPic(dataSource, expSearchSpace);
}
}
}

Expand Down
18 changes: 10 additions & 8 deletions src/webui/src/components/trial-detail/TableList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -569,15 +569,17 @@ class TableList extends React.Component<TableListProps, TableListState> {
window.addEventListener('resize', this.onWindowResize);
}

UNSAFE_componentWillReceiveProps(nextProps: TableListProps): void {
const { columnList, tableSource } = nextProps;
this.setState({
tableSourceForSort: tableSource,
tableColumns: this.initTableColumnList(columnList),
allColumnList: this.getAllColumnKeys()
});

componentDidUpdate(prevProps: TableListProps): void {
if (this.props.columnList !== prevProps.columnList || this.props.tableSource !== prevProps.tableSource) {
const { columnList, tableSource } = this.props;
this.setState({
tableSourceForSort: tableSource,
tableColumns: this.initTableColumnList(columnList),
allColumnList: this.getAllColumnKeys()
});
}
}

render(): React.ReactNode {
const { intermediateKey, modalIntermediateWidth, modalIntermediateHeight,
tableColumns, allColumnList, isShowColumn, modalVisible,
Expand Down

0 comments on commit 54496c2

Please sign in to comment.