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

[WebUI] Support dictionary metrics includes table defatule metirc | addcolumn | intermeidate result modal #2073

Merged
merged 3 commits into from
Feb 18, 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
3 changes: 1 addition & 2 deletions src/webui/src/components/Modals/ChangeColumnComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ class ChangeColumnComponent extends React.Component<ChangeColumnProps, ChangeCol
});
return (
<div>
<div>Hello</div>
<Dialog
hidden={isHideDialog} // required field!
dialogContentProps={{
Expand All @@ -130,7 +129,7 @@ class ChangeColumnComponent extends React.Component<ChangeColumnProps, ChangeCol
styles: { main: { maxWidth: 450 } }
}}
>
<div>
<div className="columns-height">
{renderOptions.map(item => {
return <Checkbox key={item.label} {...item} styles={{ root: { marginBottom: 8 } }} />
})}
Expand Down
74 changes: 47 additions & 27 deletions src/webui/src/components/trial-detail/TableList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface TableListState {
isShowCustomizedModal: boolean;
copyTrialId: string; // user copy trial to submit a new customized trial
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;
modalIntermediateWidth: number;
modalIntermediateHeight: number;
Expand Down Expand Up @@ -86,7 +86,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
isShowCustomizedModal: false,
isCalloutVisible: false,
copyTrialId: '',
intermediateKeys: ['default'],
intermediateKey: 'default',
isExpand: false,
modalIntermediateWidth: window.innerWidth,
modalIntermediateHeight: window.innerHeight,
Expand Down Expand Up @@ -294,7 +294,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
const intermediate = intermediateGraphOption(intermediateArr, intermediateId);
// re-render
this.setState({
intermediateKeys: [value],
intermediateKey: value,
intermediateOption: intermediate
});
}
Expand Down Expand Up @@ -388,29 +388,27 @@ class TableList extends React.Component<TableListProps, TableListState> {
parameterStr.push(`${value} (search space)`);
});
}
let allColumnList = COLUMNPro; // eslint-disable-line @typescript-eslint/no-unused-vars
allColumnList = COLUMNPro.concat(parameterStr);
let allColumnList = COLUMNPro.concat(parameterStr);

// only succeed trials have final keys
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 (!isNaN(temp)) {
// concat default column and finalkeys
const item = Object.keys(temp);
// item: ['default', 'other-keys', 'maybe loss']
if (item.length > 1) {
const want: string[] = [];
item.forEach(value => {
if (value !== 'default') {
want.push(value);
}
});
allColumnList = COLUMNPro.concat(want);
}
// concat default column and finalkeys
const item = Object.keys(temp);
// item: ['default', 'other-keys', 'maybe loss']
if (item.length > 1) {
const want: string[] = [];
item.forEach(value => {
if (value !== 'default') {
want.push(value);
}
});
allColumnList = allColumnList.concat(want);
}
}
}

return allColumnList;
}

Expand Down Expand Up @@ -522,8 +520,32 @@ class TableList extends React.Component<TableListProps, TableListState> {
});
break;
default:
// FIXME
alert('Unexpected column type');
showColumn.push({
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;
Expand All @@ -539,14 +561,13 @@ class TableList extends React.Component<TableListProps, TableListState> {

}
render(): React.ReactNode {
const { intermediateKeys, modalIntermediateWidth, modalIntermediateHeight,
const { intermediateKey, modalIntermediateWidth, modalIntermediateHeight,
tableColumns, allColumnList, isShowColumn, modalVisible,
selectRows, isShowCompareModal, intermediateOtherKeys,
isShowCustomizedModal, copyTrialId, intermediateOption
} = this.state;
const { columnList } = this.props;
const tableSource: Array<TableRecord> = JSON.parse(JSON.stringify(this.state.tableSourceForSort));

return (
<Stack>
<div id="tableList">
Expand Down Expand Up @@ -580,19 +601,18 @@ class TableList extends React.Component<TableListProps, TableListState> {
{
intermediateOtherKeys.length > 1
?
<Stack className="selectKeys" styles={{ root: { width: 800 } }}>
<Stack horizontalAlign="end" className="selectKeys">
<Dropdown
className="select"
selectedKeys={intermediateKeys}
onChange={this.selectOtherKeys}
selectedKey={intermediateKey}
options={
intermediateOtherKeys.map((key, item) => {
return {
key: key, text: intermediateOtherKeys[item]
};
})
}
styles={{ dropdown: { width: 300 } }}
onChange={this.selectOtherKeys}
/>
</Stack>
:
Expand Down
7 changes: 6 additions & 1 deletion src/webui/src/static/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ function formatTimestamp(timestamp?: number, placeholder?: string): string {

function metricAccuracy(metric: MetricDataRecord): number {
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 {
Expand Down
3 changes: 2 additions & 1 deletion src/webui/src/static/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ interface TableRecord {
intermediateCount: number;
accuracy?: number;
latestAccuracy: number | undefined;
formattedLatestAccuracy: string; // format (LATEST/FINAL)
formattedLatestAccuracy: string; // format (LATEST/FINAL),
accDictionary: FinalType | undefined;
}

interface SearchSpace {
Expand Down
11 changes: 8 additions & 3 deletions src/webui/src/static/model/trial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ class Trial implements TableObj {
if (this.accuracy !== undefined) {
return this.accuracy;
} else if (this.intermediates.length > 0) {
// TODO: support intermeidate result is dict
const temp = this.intermediates[this.intermediates.length - 1];
if (temp !== undefined) {
return parseMetrics(temp.data);
if (typeof parseMetrics(temp.data) === 'object') {
return parseMetrics(temp.data).default;
} else {
return parseMetrics(temp.data);
}
} else {
return undefined;
}
Expand All @@ -82,9 +85,11 @@ class Trial implements TableObj {
duration,
status: this.info.status,
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,
formattedLatestAccuracy: this.formatLatestAccuracy(),
accDictionary: this.acc
};
}

Expand Down
5 changes: 3 additions & 2 deletions src/webui/src/static/style/search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
.selectKeys{
/* intermediate result is dict, select box for keys */
.select{
margin-right: 12%;
}
.ms-Dropdown{
width: 120px;
float: right;
margin-right: 10%;
}
}

6 changes: 5 additions & 1 deletion src/webui/src/static/style/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,8 @@
}
.detail-table{
padding: 5px 0 0 0;
}
}
.columns-height{
max-height: 335px;
overflow-y: scroll;
}