Unverified Commit ac232be5 authored by liuzhe-lz's avatar liuzhe-lz Committed by GitHub
Browse files

Fix web UI bugs found in bug bash (#1613)

* bugfix

* trigger pipeline

* trigger pipeline

* fix failed trial not shown issue
parent 1d960d45
...@@ -8,89 +8,46 @@ import MonacoHTML from '../public-child/MonacoEditor'; ...@@ -8,89 +8,46 @@ import MonacoHTML from '../public-child/MonacoEditor';
import '../../static/style/logDrawer.scss'; import '../../static/style/logDrawer.scss';
interface LogDrawerProps { interface LogDrawerProps {
isVisble: boolean;
closeDrawer: () => void; closeDrawer: () => void;
activeTab?: string; activeTab?: string;
} }
interface LogDrawerState { interface LogDrawerState {
nniManagerLogStr: string; nniManagerLogStr: string | null;
dispatcherLogStr: string; dispatcherLogStr: string | null;
isLoading: boolean; isLoading: boolean;
isLoadispatcher: boolean;
} }
class LogDrawer extends React.Component<LogDrawerProps, LogDrawerState> { class LogDrawer extends React.Component<LogDrawerProps, LogDrawerState> {
private timerId: number | undefined;
public _isLogDrawer: boolean;
constructor(props: LogDrawerProps) { constructor(props: LogDrawerProps) {
super(props); super(props);
this.state = { this.state = {
nniManagerLogStr: 'nnimanager', nniManagerLogStr: null,
dispatcherLogStr: 'dispatcher', dispatcherLogStr: null,
isLoading: false, isLoading: true,
isLoadispatcher: false
}; };
} }
getNNImanagerLogmessage = () => {
if (this._isLogDrawer === true) {
this.setState({ isLoading: true }, () => {
axios(`${DOWNLOAD_IP}/nnimanager.log`, {
method: 'GET'
})
.then(res => {
if (res.status === 200) {
setTimeout(() => { this.setNNImanager(res.data); }, 300);
}
});
});
}
}
setDispatcher = (value: string) => {
if (this._isLogDrawer === true) {
this.setState({ isLoadispatcher: false, dispatcherLogStr: value });
}
}
setNNImanager = (val: string) => {
if (this._isLogDrawer === true) {
this.setState({ isLoading: false, nniManagerLogStr: val });
}
}
getdispatcherLogmessage = () => {
if (this._isLogDrawer === true) {
this.setState({ isLoadispatcher: true }, () => {
axios(`${DOWNLOAD_IP}/dispatcher.log`, {
method: 'GET'
})
.then(res => {
if (res.status === 200) {
setTimeout(() => { this.setDispatcher(res.data); }, 300);
}
});
});
}
}
downloadNNImanager = () => { downloadNNImanager = () => {
const { nniManagerLogStr } = this.state; if (this.state.nniManagerLogStr !== null) {
downFile(nniManagerLogStr, 'nnimanager.log'); downFile(this.state.nniManagerLogStr, 'nnimanager.log');
}
} }
downloadDispatcher = () => { downloadDispatcher = () => {
const { dispatcherLogStr } = this.state; if (this.state.dispatcherLogStr !== null) {
downFile(dispatcherLogStr, 'dispatcher.log'); downFile(this.state.dispatcherLogStr, 'dispatcher.log');
}
} }
dispatcherHTML = () => { dispatcherHTML = () => {
return ( return (
<div> <div>
<span>Dispatcher Log</span> <span>Dispatcher Log</span>
<span className="refresh" onClick={this.getdispatcherLogmessage}> <span className="refresh" onClick={this.manualRefresh}>
<Icon type="sync" /> <Icon type="sync" />
</span> </span>
</div> </div>
...@@ -101,36 +58,22 @@ class LogDrawer extends React.Component<LogDrawerProps, LogDrawerState> { ...@@ -101,36 +58,22 @@ class LogDrawer extends React.Component<LogDrawerProps, LogDrawerState> {
return ( return (
<div> <div>
<span>NNImanager Log</span> <span>NNImanager Log</span>
<span className="refresh" onClick={this.getNNImanagerLogmessage}><Icon type="sync" /></span> <span className="refresh" onClick={this.manualRefresh}><Icon type="sync" /></span>
</div> </div>
); );
} }
componentDidMount() { async componentDidMount() {
this._isLogDrawer = true; this.refresh();
this.getNNImanagerLogmessage();
this.getdispatcherLogmessage();
}
componentWillReceiveProps(nextProps: LogDrawerProps) {
const { isVisble, activeTab } = nextProps;
if (isVisble === true) {
if (activeTab === 'nnimanager') {
this.getNNImanagerLogmessage();
}
if (activeTab === 'dispatcher') {
this.getdispatcherLogmessage();
}
}
} }
componentWillUnmount() { componentWillUnmount() {
this._isLogDrawer = false; window.clearTimeout(this.timerId);
} }
render() { render() {
const { isVisble, closeDrawer, activeTab } = this.props; const { closeDrawer, activeTab } = this.props;
const { nniManagerLogStr, dispatcherLogStr, isLoadispatcher, isLoading } = this.state; const { nniManagerLogStr, dispatcherLogStr, isLoading } = this.state;
const heights: number = window.innerHeight - 48; // padding top and bottom const heights: number = window.innerHeight - 48; // padding top and bottom
return ( return (
<Row> <Row>
...@@ -139,7 +82,7 @@ class LogDrawer extends React.Component<LogDrawerProps, LogDrawerState> { ...@@ -139,7 +82,7 @@ class LogDrawer extends React.Component<LogDrawerProps, LogDrawerState> {
closable={false} closable={false}
destroyOnClose={true} destroyOnClose={true}
onClose={closeDrawer} onClose={closeDrawer}
visible={isVisble} visible={true}
width="76%" width="76%"
height={heights} height={heights}
// className="logDrawer" // className="logDrawer"
...@@ -150,7 +93,7 @@ class LogDrawer extends React.Component<LogDrawerProps, LogDrawerState> { ...@@ -150,7 +93,7 @@ class LogDrawer extends React.Component<LogDrawerProps, LogDrawerState> {
{/* <TabPane tab="Dispatcher Log" key="dispatcher"> */} {/* <TabPane tab="Dispatcher Log" key="dispatcher"> */}
<TabPane tab={this.dispatcherHTML()} key="dispatcher"> <TabPane tab={this.dispatcherHTML()} key="dispatcher">
<div> <div>
<MonacoHTML content={dispatcherLogStr} loading={isLoadispatcher} /> <MonacoHTML content={dispatcherLogStr || 'Loading...'} loading={isLoading} />
</div> </div>
<Row className="buttons"> <Row className="buttons">
<Col span={12} className="download"> <Col span={12} className="download">
...@@ -174,7 +117,7 @@ class LogDrawer extends React.Component<LogDrawerProps, LogDrawerState> { ...@@ -174,7 +117,7 @@ class LogDrawer extends React.Component<LogDrawerProps, LogDrawerState> {
<TabPane tab={this.nnimanagerHTML()} key="nnimanager"> <TabPane tab={this.nnimanagerHTML()} key="nnimanager">
{/* <TabPane tab="NNImanager Log" key="nnimanager"> */} {/* <TabPane tab="NNImanager Log" key="nnimanager"> */}
<div> <div>
<MonacoHTML content={nniManagerLogStr} loading={isLoading} /> <MonacoHTML content={nniManagerLogStr || 'Loading...'} loading={isLoading} />
</div> </div>
<Row className="buttons"> <Row className="buttons">
<Col span={12} className="download"> <Col span={12} className="download">
...@@ -201,6 +144,31 @@ class LogDrawer extends React.Component<LogDrawerProps, LogDrawerState> { ...@@ -201,6 +144,31 @@ class LogDrawer extends React.Component<LogDrawerProps, LogDrawerState> {
</Row> </Row>
); );
} }
private refresh = () => {
window.clearTimeout(this.timerId);
const dispatcherPromise = axios.get(`${DOWNLOAD_IP}/dispatcher.log`);
const nniManagerPromise = axios.get(`${DOWNLOAD_IP}/nnimanager.log`);
dispatcherPromise.then(res => {
if (res.status === 200) {
this.setState({ dispatcherLogStr: res.data });
}
});
nniManagerPromise.then(res => {
if (res.status === 200) {
this.setState({ nniManagerLogStr: res.data });
}
});
Promise.all([ dispatcherPromise, nniManagerPromise ]).then(() => {
this.setState({ isLoading: false });
this.timerId = window.setTimeout(this.refresh, 300);
});
}
private manualRefresh = () => {
this.setState({ isLoading: true });
this.refresh();
}
} }
export default LogDrawer; export default LogDrawer;
...@@ -338,11 +338,12 @@ class SlideBar extends React.Component<SliderProps, SliderState> { ...@@ -338,11 +338,12 @@ class SlideBar extends React.Component<SliderProps, SliderState> {
{tablet} {tablet}
{desktop} {desktop}
{/* the drawer for dispatcher & nnimanager log message */} {/* the drawer for dispatcher & nnimanager log message */}
{isvisibleLogDrawer ? (
<LogDrawer <LogDrawer
isVisble={isvisibleLogDrawer}
closeDrawer={this.closeLogDrawer} closeDrawer={this.closeLogDrawer}
activeTab={activeKey} activeTab={activeKey}
/> />
) : null}
<ExperimentDrawer <ExperimentDrawer
isVisble={isvisibleExperimentDrawer} isVisble={isvisibleExperimentDrawer}
closeExpDrawer={this.closeExpDrawer} closeExpDrawer={this.closeExpDrawer}
......
...@@ -100,10 +100,6 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState> ...@@ -100,10 +100,6 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState>
this.setState({ whichGraph: activeKey }); this.setState({ whichGraph: activeKey });
} }
test = () => {
alert('TableList component was not properly initialized.');
}
updateSearchFilterType = (value: string) => { updateSearchFilterType = (value: string) => {
// clear input value and re-render table // clear input value and re-render table
if (this.searchInput !== null) { if (this.searchInput !== null) {
...@@ -167,14 +163,14 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState> ...@@ -167,14 +163,14 @@ class TrialsDetail extends React.Component<TrialsDetailProps, TrialDetailState>
<Col span={14} className="right"> <Col span={14} className="right">
<Button <Button
className="common" className="common"
onClick={this.tableList ? this.tableList.addColumn : this.test} onClick={() => { if (this.tableList) { this.tableList.addColumn(); }}}
> >
Add column Add column
</Button> </Button>
<Button <Button
className="mediateBtn common" className="mediateBtn common"
// use child-component tableList's function, the function is in child-component. // use child-component tableList's function, the function is in child-component.
onClick={this.tableList ? this.tableList.compareBtn : this.test} onClick={() => { if (this.tableList) { this.tableList.compareBtn(); }}}
> >
Compare Compare
</Button> </Button>
......
...@@ -184,11 +184,12 @@ class Progressed extends React.Component<ProgressProps, ProgressState> { ...@@ -184,11 +184,12 @@ class Progressed extends React.Component<ProgressProps, ProgressState> {
</Col> </Col>
</Row> </Row>
{/* learn about click -> default active key is dispatcher. */} {/* learn about click -> default active key is dispatcher. */}
{isShowLogDrawer ? (
<LogDrawer <LogDrawer
isVisble={isShowLogDrawer}
closeDrawer={this.closeDrawer} closeDrawer={this.closeDrawer}
activeTab="dispatcher" activeTab="dispatcher"
/> />
) : null}
</Row> </Row>
); );
} }
......
...@@ -251,13 +251,15 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -251,13 +251,15 @@ class TableList extends React.Component<TableListProps, TableListState> {
const showColumn: Array<object> = []; const showColumn: Array<object> = [];
// parameter as table column // parameter as table column
const parameterStr: Array<string> = [];
if (tableSource.length > 0) {
const trialMess = TRIALS.getTrial(tableSource[0].id); const trialMess = TRIALS.getTrial(tableSource[0].id);
const trial = trialMess.description.parameters; const trial = trialMess.description.parameters;
const parameterColumn: Array<string> = Object.keys(trial); const parameterColumn: Array<string> = Object.keys(trial);
const parameterStr: Array<string> = [];
parameterColumn.forEach(value => { parameterColumn.forEach(value => {
parameterStr.push(`${value} (search space)`); parameterStr.push(`${value} (search space)`);
}); });
}
showTitle = COLUMNPro.concat(parameterStr); showTitle = COLUMNPro.concat(parameterStr);
// only succeed trials have final keys // only succeed trials have final keys
......
...@@ -43,7 +43,7 @@ class Trial implements TableObj { ...@@ -43,7 +43,7 @@ class Trial implements TableObj {
} }
get sortable(): boolean { get sortable(): boolean {
return this.finalAcc !== undefined && !isNaN(this.finalAcc); return this.metricsInitialized && this.finalAcc !== undefined && !isNaN(this.finalAcc);
} }
/* table obj start */ /* table obj start */
...@@ -132,7 +132,7 @@ class Trial implements TableObj { ...@@ -132,7 +132,7 @@ class Trial implements TableObj {
/* table obj end */ /* table obj end */
public initialized(): boolean { public initialized(): boolean {
return !!(this.infoField && this.metricsInitialized); return Boolean(this.infoField);
} }
public updateMetrics(metrics: MetricDataRecord[]): boolean { public updateMetrics(metrics: MetricDataRecord[]): boolean {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment