Unverified Commit a09d3581 authored by Lijiao's avatar Lijiao Committed by GitHub
Browse files

[WebUI] Support dictionary metrics includes table defatule metirc | addcolumn...

[WebUI] Support dictionary metrics includes table defatule metirc | addcolumn | intermeidate result modal (#2073)
parent f95d9ed8
...@@ -117,7 +117,6 @@ class ChangeColumnComponent extends React.Component<ChangeColumnProps, ChangeCol ...@@ -117,7 +117,6 @@ class ChangeColumnComponent extends React.Component<ChangeColumnProps, ChangeCol
}); });
return ( return (
<div> <div>
<div>Hello</div>
<Dialog <Dialog
hidden={isHideDialog} // required field! hidden={isHideDialog} // required field!
dialogContentProps={{ dialogContentProps={{
...@@ -130,7 +129,7 @@ class ChangeColumnComponent extends React.Component<ChangeColumnProps, ChangeCol ...@@ -130,7 +129,7 @@ class ChangeColumnComponent extends React.Component<ChangeColumnProps, ChangeCol
styles: { main: { maxWidth: 450 } } styles: { main: { maxWidth: 450 } }
}} }}
> >
<div> <div className="columns-height">
{renderOptions.map(item => { {renderOptions.map(item => {
return <Checkbox key={item.label} {...item} styles={{ root: { marginBottom: 8 } }} /> return <Checkbox key={item.label} {...item} styles={{ root: { marginBottom: 8 } }} />
})} })}
......
...@@ -54,7 +54,7 @@ interface TableListState { ...@@ -54,7 +54,7 @@ interface TableListState {
isShowCustomizedModal: boolean; isShowCustomizedModal: boolean;
copyTrialId: string; // user copy trial to submit a new customized trial copyTrialId: string; // user copy trial to submit a new customized trial
isCalloutVisible: boolean; // kill job button callout [kill or not kill job window] isCalloutVisible: boolean; // kill job button callout [kill or not kill job window]
intermediateKeys: string[]; // intermeidate modal: which key is choosed. intermediateKey: string; // intermeidate modal: which key is choosed.
isExpand: boolean; isExpand: boolean;
modalIntermediateWidth: number; modalIntermediateWidth: number;
modalIntermediateHeight: number; modalIntermediateHeight: number;
...@@ -86,7 +86,7 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -86,7 +86,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
isShowCustomizedModal: false, isShowCustomizedModal: false,
isCalloutVisible: false, isCalloutVisible: false,
copyTrialId: '', copyTrialId: '',
intermediateKeys: ['default'], intermediateKey: 'default',
isExpand: false, isExpand: false,
modalIntermediateWidth: window.innerWidth, modalIntermediateWidth: window.innerWidth,
modalIntermediateHeight: window.innerHeight, modalIntermediateHeight: window.innerHeight,
...@@ -294,7 +294,7 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -294,7 +294,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
const intermediate = intermediateGraphOption(intermediateArr, intermediateId); const intermediate = intermediateGraphOption(intermediateArr, intermediateId);
// re-render // re-render
this.setState({ this.setState({
intermediateKeys: [value], intermediateKey: value,
intermediateOption: intermediate intermediateOption: intermediate
}); });
} }
...@@ -388,14 +388,12 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -388,14 +388,12 @@ class TableList extends React.Component<TableListProps, TableListState> {
parameterStr.push(`${value} (search space)`); parameterStr.push(`${value} (search space)`);
}); });
} }
let allColumnList = COLUMNPro; // eslint-disable-line @typescript-eslint/no-unused-vars let allColumnList = COLUMNPro.concat(parameterStr);
allColumnList = COLUMNPro.concat(parameterStr);
// only succeed trials have final keys // only succeed trials have final keys
if (tableSource.filter(record => record.status === 'SUCCEEDED').length >= 1) { if (tableSource.filter(record => record.status === 'SUCCEEDED').length >= 1) {
const temp = tableSource.filter(record => record.status === 'SUCCEEDED')[0].accuracy; const temp = tableSource.filter(record => record.status === 'SUCCEEDED')[0].accDictionary;
if (temp !== undefined && typeof temp === 'object') { if (temp !== undefined && typeof temp === 'object') {
if (!isNaN(temp)) {
// concat default column and finalkeys // concat default column and finalkeys
const item = Object.keys(temp); const item = Object.keys(temp);
// item: ['default', 'other-keys', 'maybe loss'] // item: ['default', 'other-keys', 'maybe loss']
...@@ -406,11 +404,11 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -406,11 +404,11 @@ class TableList extends React.Component<TableListProps, TableListState> {
want.push(value); want.push(value);
} }
}); });
allColumnList = COLUMNPro.concat(want); allColumnList = allColumnList.concat(want);
}
} }
} }
} }
return allColumnList; return allColumnList;
} }
...@@ -522,8 +520,32 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -522,8 +520,32 @@ class TableList extends React.Component<TableListProps, TableListState> {
}); });
break; break;
default: default:
// FIXME showColumn.push({
alert('Unexpected column type'); name: item,
key: item,
fieldName: item,
minWidth: 100,
onRender: (record: TableRecord) => {
const accDictionary = record.accDictionary;
let decimals = 0;
let other = '';
if (accDictionary !== undefined) {
if (accDictionary[item].toString().indexOf('.') !== -1) {
decimals = accDictionary[item].toString().length - accDictionary[item].toString().indexOf('.') - 1;
if (decimals > 6) {
other = `${accDictionary[item].toFixed(6)}`;
} else {
other = accDictionary[item].toString();
}
}
} else {
other = '--';
}
return (
<div>{other}</div>
);
}
});
} }
} }
return showColumn; return showColumn;
...@@ -539,14 +561,13 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -539,14 +561,13 @@ class TableList extends React.Component<TableListProps, TableListState> {
} }
render(): React.ReactNode { render(): React.ReactNode {
const { intermediateKeys, modalIntermediateWidth, modalIntermediateHeight, const { intermediateKey, modalIntermediateWidth, modalIntermediateHeight,
tableColumns, allColumnList, isShowColumn, modalVisible, tableColumns, allColumnList, isShowColumn, modalVisible,
selectRows, isShowCompareModal, intermediateOtherKeys, selectRows, isShowCompareModal, intermediateOtherKeys,
isShowCustomizedModal, copyTrialId, intermediateOption isShowCustomizedModal, copyTrialId, intermediateOption
} = this.state; } = this.state;
const { columnList } = this.props; const { columnList } = this.props;
const tableSource: Array<TableRecord> = JSON.parse(JSON.stringify(this.state.tableSourceForSort)); const tableSource: Array<TableRecord> = JSON.parse(JSON.stringify(this.state.tableSourceForSort));
return ( return (
<Stack> <Stack>
<div id="tableList"> <div id="tableList">
...@@ -580,11 +601,10 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -580,11 +601,10 @@ class TableList extends React.Component<TableListProps, TableListState> {
{ {
intermediateOtherKeys.length > 1 intermediateOtherKeys.length > 1
? ?
<Stack className="selectKeys" styles={{ root: { width: 800 } }}> <Stack horizontalAlign="end" className="selectKeys">
<Dropdown <Dropdown
className="select" className="select"
selectedKeys={intermediateKeys} selectedKey={intermediateKey}
onChange={this.selectOtherKeys}
options={ options={
intermediateOtherKeys.map((key, item) => { intermediateOtherKeys.map((key, item) => {
return { return {
...@@ -592,7 +612,7 @@ class TableList extends React.Component<TableListProps, TableListState> { ...@@ -592,7 +612,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
}; };
}) })
} }
styles={{ dropdown: { width: 300 } }} onChange={this.selectOtherKeys}
/> />
</Stack> </Stack>
: :
......
...@@ -189,7 +189,12 @@ function formatTimestamp(timestamp?: number, placeholder?: string): string { ...@@ -189,7 +189,12 @@ function formatTimestamp(timestamp?: number, placeholder?: string): string {
function metricAccuracy(metric: MetricDataRecord): number { function metricAccuracy(metric: MetricDataRecord): number {
const data = parseMetrics(metric.data); const data = parseMetrics(metric.data);
return typeof data === 'number' ? data : NaN; // return typeof data === 'number' ? data : NaN;
if (typeof data === 'number') {
return data;
} else {
return data.default;
}
} }
function formatAccuracy(accuracy: number): string { function formatAccuracy(accuracy: number): string {
......
...@@ -23,7 +23,8 @@ interface TableRecord { ...@@ -23,7 +23,8 @@ interface TableRecord {
intermediateCount: number; intermediateCount: number;
accuracy?: number; accuracy?: number;
latestAccuracy: number | undefined; latestAccuracy: number | undefined;
formattedLatestAccuracy: string; // format (LATEST/FINAL) formattedLatestAccuracy: string; // format (LATEST/FINAL),
accDictionary: FinalType | undefined;
} }
interface SearchSpace { interface SearchSpace {
......
...@@ -53,10 +53,13 @@ class Trial implements TableObj { ...@@ -53,10 +53,13 @@ class Trial implements TableObj {
if (this.accuracy !== undefined) { if (this.accuracy !== undefined) {
return this.accuracy; return this.accuracy;
} else if (this.intermediates.length > 0) { } else if (this.intermediates.length > 0) {
// TODO: support intermeidate result is dict
const temp = this.intermediates[this.intermediates.length - 1]; const temp = this.intermediates[this.intermediates.length - 1];
if (temp !== undefined) { if (temp !== undefined) {
if (typeof parseMetrics(temp.data) === 'object') {
return parseMetrics(temp.data).default;
} else {
return parseMetrics(temp.data); return parseMetrics(temp.data);
}
} else { } else {
return undefined; return undefined;
} }
...@@ -82,9 +85,11 @@ class Trial implements TableObj { ...@@ -82,9 +85,11 @@ class Trial implements TableObj {
duration, duration,
status: this.info.status, status: this.info.status,
intermediateCount: this.intermediates.length, intermediateCount: this.intermediates.length,
accuracy: this.finalAcc, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
accuracy: this.acc !== undefined ? JSON.parse(this.acc!.default) : undefined,
latestAccuracy: this.latestAccuracy, latestAccuracy: this.latestAccuracy,
formattedLatestAccuracy: this.formatLatestAccuracy(), formattedLatestAccuracy: this.formatLatestAccuracy(),
accDictionary: this.acc
}; };
} }
......
...@@ -27,9 +27,10 @@ ...@@ -27,9 +27,10 @@
.selectKeys{ .selectKeys{
/* intermediate result is dict, select box for keys */ /* intermediate result is dict, select box for keys */
.select{ .select{
margin-right: 12%;
}
.ms-Dropdown{
width: 120px; width: 120px;
float: right;
margin-right: 10%;
} }
} }
...@@ -47,3 +47,7 @@ ...@@ -47,3 +47,7 @@
.detail-table{ .detail-table{
padding: 5px 0 0 0; padding: 5px 0 0 0;
} }
.columns-height{
max-height: 335px;
overflow-y: scroll;
}
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