Commit ed2f1bdf authored by Lijiao's avatar Lijiao Committed by fishyds
Browse files

Fix bugs for v0.3 (#315)

* Fix bugs

* update
parent f56f688b
...@@ -4,11 +4,8 @@ import { Row, Col } from 'antd'; ...@@ -4,11 +4,8 @@ import { Row, Col } from 'antd';
import { MANAGER_IP, overviewItem } from '../static/const'; import { MANAGER_IP, overviewItem } from '../static/const';
import { import {
Experiment, TableObj, Experiment, TableObj,
Parameters, AccurPoint, TrialNumber Parameters, TrialNumber
} from '../static/interface'; } from '../static/interface';
import {
getAccuracyData
} from '../static/function';
import SuccessTable from './overview/SuccessTable'; import SuccessTable from './overview/SuccessTable';
import Title1 from './overview/Title1'; import Title1 from './overview/Title1';
import Progressed from './overview/Progress'; import Progressed from './overview/Progress';
...@@ -42,7 +39,6 @@ class Overview extends React.Component<{}, SessionState> { ...@@ -42,7 +39,6 @@ class Overview extends React.Component<{}, SessionState> {
public _isMounted = false; public _isMounted = false;
public intervalID = 0; public intervalID = 0;
public intervalProfile = 1; public intervalProfile = 1;
public intervalAccuracy = 2;
constructor(props: {}) { constructor(props: {}) {
super(props); super(props);
...@@ -212,8 +208,16 @@ class Overview extends React.Component<{}, SessionState> { ...@@ -212,8 +208,16 @@ class Overview extends React.Component<{}, SessionState> {
}; };
const duration = (tableData[item].endTime - tableData[item].startTime) / 1000; const duration = (tableData[item].endTime - tableData[item].startTime) / 1000;
let acc; let acc;
let tableAcc = 0;
if (tableData[item].finalMetricData) { if (tableData[item].finalMetricData) {
acc = parseFloat(tableData[item].finalMetricData.data); acc = JSON.parse(tableData[item].finalMetricData.data);
if (typeof (acc) === 'object') {
if (acc.default) {
tableAcc = acc.default;
}
} else {
tableAcc = acc;
}
} }
// if hyperparameters is undefine, show error message, else, show parameters value // if hyperparameters is undefine, show error message, else, show parameters value
if (tableData[item].hyperParameters) { if (tableData[item].hyperParameters) {
...@@ -234,7 +238,7 @@ class Overview extends React.Component<{}, SessionState> { ...@@ -234,7 +238,7 @@ class Overview extends React.Component<{}, SessionState> {
id: tableData[item].id, id: tableData[item].id,
duration: duration, duration: duration,
status: tableData[item].status, status: tableData[item].status,
acc: acc, acc: tableAcc,
description: desJobDetail description: desJobDetail
}); });
break; break;
...@@ -255,6 +259,8 @@ class Overview extends React.Component<{}, SessionState> { ...@@ -255,6 +259,8 @@ class Overview extends React.Component<{}, SessionState> {
trialNumber: profile trialNumber: profile
}); });
} }
// draw accuracy
this.drawPointGraph();
} }
}); });
} }
...@@ -311,26 +317,45 @@ class Overview extends React.Component<{}, SessionState> { ...@@ -311,26 +317,45 @@ class Overview extends React.Component<{}, SessionState> {
// trial accuracy graph // trial accuracy graph
drawPointGraph = () => { drawPointGraph = () => {
axios(`${MANAGER_IP}/trial-jobs`, { const { tableData } = this.state;
method: 'GET' const sourcePoint = JSON.parse(JSON.stringify(tableData));
}) sourcePoint.sort((a: TableObj, b: TableObj) => {
.then(res => { if (a.sequenceId && b.sequenceId) {
if (res.status === 200 && this._isMounted) { return a.sequenceId - b.sequenceId;
const accData = res.data; } else {
const accArr: Array<number> = []; return NaN;
const accY: Array<AccurPoint> = [];
Object.keys(accData).map(item => {
if (accData[item].status === 'SUCCEEDED' && accData[item].finalMetricData) {
accArr.push(parseFloat(accData[item].finalMetricData.data));
} }
}); });
accArr.sort((a, b) => { return a - b; }); const accarr: Array<number> = [];
accArr.length = Math.min(10, accArr.length); const indexarr: Array<number> = [];
accY.push({ yAxis: accArr }); Object.keys(sourcePoint).map(item => {
let optionObj = getAccuracyData(accY[0]); const items = sourcePoint[item];
const bestAccnum = Math.max(...accArr); accarr.push(items.acc);
this.setState({ accuracyData: optionObj }, () => { indexarr.push(items.sequenceId);
if (accArr.length === 0) { });
const bestAccnum = Math.max(...accarr);
const accOption = {
tooltip: {
trigger: 'item'
},
xAxis: {
name: 'Trial',
type: 'category',
data: indexarr
},
yAxis: {
name: 'Accuracy',
type: 'value',
data: accarr
},
series: [{
symbolSize: 6,
type: 'scatter',
data: accarr
}]
};
this.setState({ accuracyData: accOption }, () => {
if (accarr.length === 0) {
this.setState({ this.setState({
accNodata: 'No data' accNodata: 'No data'
}); });
...@@ -342,15 +367,11 @@ class Overview extends React.Component<{}, SessionState> { ...@@ -342,15 +367,11 @@ class Overview extends React.Component<{}, SessionState> {
} }
}); });
} }
});
}
componentDidMount() { componentDidMount() {
this._isMounted = true;
this.showSessionPro(); this.showSessionPro();
this.showTrials(); this.showTrials();
this.drawPointGraph();
this.intervalAccuracy = window.setInterval(this.drawPointGraph, 10000);
this._isMounted = true;
this.intervalID = window.setInterval(this.showTrials, 10000); this.intervalID = window.setInterval(this.showTrials, 10000);
this.intervalProfile = window.setInterval(this.showSessionPro, 60000); this.intervalProfile = window.setInterval(this.showSessionPro, 60000);
} }
...@@ -359,7 +380,6 @@ class Overview extends React.Component<{}, SessionState> { ...@@ -359,7 +380,6 @@ class Overview extends React.Component<{}, SessionState> {
this._isMounted = false; this._isMounted = false;
window.clearInterval(this.intervalID); window.clearInterval(this.intervalID);
window.clearInterval(this.intervalProfile); window.clearInterval(this.intervalProfile);
window.clearInterval(this.intervalAccuracy);
} }
render() { render() {
......
...@@ -2,7 +2,6 @@ import * as React from 'react'; ...@@ -2,7 +2,6 @@ import * as React from 'react';
import axios from 'axios'; import axios from 'axios';
import { MANAGER_IP } from '../static/const'; import { MANAGER_IP } from '../static/const';
import { Row, Tabs } from 'antd'; import { Row, Tabs } from 'antd';
import { getAccuracyData } from '../static/function';
import { TableObj, Parameters, AccurPoint } from '../static/interface'; import { TableObj, Parameters, AccurPoint } from '../static/interface';
import Accuracy from './overview/Accuracy'; import Accuracy from './overview/Accuracy';
import Duration from './trial-detail/Duration'; import Duration from './trial-detail/Duration';
...@@ -42,17 +41,57 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -42,17 +41,57 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
.then(res => { .then(res => {
if (res.status === 200 && this._isMounted) { if (res.status === 200 && this._isMounted) {
const accData = res.data; const accData = res.data;
const accArr: Array<number> = []; const accSource: Array<AccurPoint> = [];
const accY: Array<AccurPoint> = [];
Object.keys(accData).map(item => { Object.keys(accData).map(item => {
if (accData[item].status === 'SUCCEEDED' && accData[item].finalMetricData) { if (accData[item].status === 'SUCCEEDED' && accData[item].finalMetricData) {
accArr.push(parseFloat(accData[item].finalMetricData.data)); let acc;
let tableAcc;
if (accData[item].finalMetricData) {
acc = JSON.parse(accData[item].finalMetricData.data);
if (typeof (acc) === 'object') {
if (acc.default) {
tableAcc = acc.default;
} }
} else {
tableAcc = acc;
}
}
accSource.push({
acc: tableAcc,
index: accData[item].sequenceId
});
}
});
const accarr: Array<number> = [];
const indexarr: Array<number> = [];
Object.keys(accSource).map(item => {
const items = accSource[item];
accarr.push(items.acc);
indexarr.push(items.index);
}); });
accY.push({ yAxis: accArr }); const allAcuracy = {
const optionObj = getAccuracyData(accY[0]); tooltip: {
this.setState({ accSource: optionObj }, () => { trigger: 'item'
if (accArr.length === 0) { },
xAxis: {
name: 'Trial',
type: 'category',
data: indexarr
},
yAxis: {
name: 'Accuracy',
type: 'value',
data: accarr
},
series: [{
symbolSize: 6,
type: 'scatter',
data: accarr
}]
};
this.setState({ accSource: allAcuracy }, () => {
if (accarr.length === 0) {
this.setState({ this.setState({
accNodata: 'No data' accNodata: 'No data'
}); });
...@@ -80,7 +119,8 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -80,7 +119,8 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
let desc: Parameters = { let desc: Parameters = {
parameters: {} parameters: {}
}; };
let acc = 0; let acc;
let tableAcc = 0;
let duration = 0; let duration = 0;
const id = trialJobs[item].id !== undefined const id = trialJobs[item].id !== undefined
? trialJobs[item].id ? trialJobs[item].id
...@@ -110,7 +150,14 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -110,7 +150,14 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
} }
} }
if (trialJobs[item].finalMetricData !== undefined) { if (trialJobs[item].finalMetricData !== undefined) {
acc = parseFloat(trialJobs[item].finalMetricData.data); acc = JSON.parse(trialJobs[item].finalMetricData.data);
if (typeof (acc) === 'object') {
if (acc.default) {
tableAcc = acc.default;
}
} else {
tableAcc = acc;
}
} }
trialTable.push({ trialTable.push({
key: trialTable.length, key: trialTable.length,
...@@ -118,7 +165,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> { ...@@ -118,7 +165,7 @@ class TrialsDetail extends React.Component<{}, TrialDetailState> {
id: id, id: id,
status: status, status: status,
duration: duration, duration: duration,
acc: acc, acc: tableAcc,
description: desc description: desc
}); });
}); });
......
...@@ -21,34 +21,34 @@ class SuccessTable extends React.Component<SuccessTableProps, {}> { ...@@ -21,34 +21,34 @@ class SuccessTable extends React.Component<SuccessTableProps, {}> {
let bgColor = ''; let bgColor = '';
const columns = [{ const columns = [{
title: 'Number', title: 'Trial No.',
dataIndex: 'sequenceId', dataIndex: 'sequenceId',
key: 'sequenceId', key: 'sequenceId',
width: 60, width: 140,
className: 'tableHead', className: 'tableHead'
render: (text: string, record: TableObj) => {
return (
<span>#{record.sequenceId}</span>
);
}
}, { }, {
title: 'Id', title: 'Id',
dataIndex: 'id', dataIndex: 'id',
key: 'id', key: 'id',
width: 150, width: 60,
className: 'tableHead' className: 'tableHead idtitle',
render: (text: string, record: TableObj) => {
return (
<div>{record.id}</div>
);
},
}, { }, {
title: 'Duration', title: 'Duration',
dataIndex: 'duration', dataIndex: 'duration',
key: 'duration', key: 'duration',
width: 150, width: 140,
render: (text: string, record: TableObj) => { render: (text: string, record: TableObj) => {
let duration; let duration;
if (record.duration) { if (record.duration) {
duration = convertDuration(record.duration); duration = convertDuration(record.duration);
} }
return ( return (
<div>{duration}</div> <div className="durationsty"><div>{duration}</div></div>
); );
}, },
}, { }, {
......
...@@ -80,7 +80,17 @@ class Para extends React.Component<{}, ParaState> { ...@@ -80,7 +80,17 @@ class Para extends React.Component<{}, ParaState> {
if (accParaData[item].status === 'SUCCEEDED') { if (accParaData[item].status === 'SUCCEEDED') {
if (accParaData[item].finalMetricData && accParaData[item].hyperParameters) { if (accParaData[item].finalMetricData && accParaData[item].hyperParameters) {
// get acc array // get acc array
accPara.push(parseFloat(accParaData[item].finalMetricData.data)); let acc;
let accReal;
acc = JSON.parse(accParaData[item].finalMetricData.data);
if (typeof (acc) === 'object') {
if (acc.default) {
accReal = acc.default;
}
} else {
accReal = acc;
}
accPara.push(accReal);
// get dim and every line specific number // get dim and every line specific number
const temp = JSON.parse(accParaData[item].hyperParameters).parameters; const temp = JSON.parse(accParaData[item].hyperParameters).parameters;
speValue.push(temp); speValue.push(temp);
......
...@@ -167,34 +167,33 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -167,34 +167,33 @@ class TableList extends React.Component<TableListProps, TableListState> {
}); });
}); });
const columns = [{ const columns = [{
title: 'Number', title: 'Trial No.',
dataIndex: 'sequenceId', dataIndex: 'sequenceId',
key: 'sequenceId', key: 'sequenceId',
width: 120, width: 120,
className: 'tableHead', className: 'tableHead',
sorter: (a: TableObj, b: TableObj) => (a.sequenceId as number) - (b.sequenceId as number), sorter: (a: TableObj, b: TableObj) => (a.sequenceId as number) - (b.sequenceId as number)
render: (text: string, record: TableObj) => {
return (
<span>#{record.sequenceId}</span>
);
}
}, { }, {
title: 'Id', title: 'Id',
dataIndex: 'id', dataIndex: 'id',
key: 'id', key: 'id',
width: 150, width: 60,
className: 'tableHead', className: 'tableHead idtitle',
// the sort of string // the sort of string
sorter: (a: TableObj, b: TableObj): number => a.id.localeCompare(b.id) sorter: (a: TableObj, b: TableObj): number => a.id.localeCompare(b.id),
render: (text: string, record: TableObj) => {
return (
<div>{record.id}</div>
);
}
}, { }, {
title: 'Duration', title: 'Duration',
dataIndex: 'duration', dataIndex: 'duration',
key: 'duration', key: 'duration',
width: 150, width: 140,
// the sort of number // the sort of number
sorter: (a: TableObj, b: TableObj) => (a.duration as number) - (b.duration as number), sorter: (a: TableObj, b: TableObj) => (a.duration as number) - (b.duration as number),
render: (text: string, record: TableObj) => { render: (text: string, record: TableObj) => {
const bg = record.color;
let duration; let duration;
if (record.duration !== undefined && record.duration > 0) { if (record.duration !== undefined && record.duration > 0) {
duration = convertDuration(record.duration); duration = convertDuration(record.duration);
...@@ -202,7 +201,7 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -202,7 +201,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
duration = 0; duration = 0;
} }
return ( return (
<div style={{ background: bg }}>{duration}</div> <div className="durationsty"><div>{duration}</div></div>
); );
}, },
}, { }, {
......
import { AccurPoint } from './interface';
export const convertTime = (num: number) => { export const convertTime = (num: number) => {
if (num % 3600 === 0) { if (num % 3600 === 0) {
return num / 3600 + 'h'; return num / 3600 + 'h';
...@@ -26,32 +24,3 @@ export const convertDuration = (num: number) => { ...@@ -26,32 +24,3 @@ export const convertDuration = (num: number) => {
return result; return result;
} }
}; };
\ No newline at end of file
// ACCURACY point graph option format
export const getAccuracyData = (dataObj: AccurPoint) => {
const yAxis = dataObj.yAxis;
const xAxis: Array<number> = [];
for (let i = 1; i <= yAxis.length; i++) {
xAxis.push(i);
}
return {
tooltip: {
trigger: 'item'
},
xAxis: {
name: 'Trial',
type: 'category',
data: xAxis
},
yAxis: {
name: 'Accuracy',
type: 'value',
data: yAxis
},
series: [{
symbolSize: 6,
type: 'scatter',
data: yAxis
}]
};
};
\ No newline at end of file
...@@ -37,7 +37,8 @@ interface Experiment { ...@@ -37,7 +37,8 @@ interface Experiment {
// trial accuracy // trial accuracy
interface AccurPoint { interface AccurPoint {
yAxis: Array<number>; acc: number;
index: number;
} }
interface TrialNumber { interface TrialNumber {
......
...@@ -12,7 +12,19 @@ ...@@ -12,7 +12,19 @@
} }
} }
#succeTable, #tableList{
.commonTableStyle .idtitle div{
text-align: left;
}
.durationsty{
width: 80%;
margin: 0 auto;
div{
text-align: right;
margin-right: 9px;
}
}
}
/* add the brother selector to increase the priority */ /* add the brother selector to increase the priority */
#succeTable .commonTableStyle, #tableList .commonTableStyle { #succeTable .commonTableStyle, #tableList .commonTableStyle {
......
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