Commit 9aed500d authored by Lijiao's avatar Lijiao Committed by chicm-ms
Browse files

Fix table sort issue (#1773)

parent 587dd3af
...@@ -586,17 +586,16 @@ const AccuracyColumnConfig: ColumnProps<TableRecord> = { ...@@ -586,17 +586,16 @@ const AccuracyColumnConfig: ColumnProps<TableRecord> = {
dataIndex: 'accuracy', dataIndex: 'accuracy',
width: 120, width: 120,
sorter: (a, b, sortOrder) => { sorter: (a, b, sortOrder) => {
if (a.accuracy === undefined) { if (a.latestAccuracy === undefined) {
return sortOrder === 'ascend' ? -1 : 1;
} else if (b.accuracy === undefined) {
return sortOrder === 'ascend' ? 1 : -1; return sortOrder === 'ascend' ? 1 : -1;
} else if (b.latestAccuracy === undefined) {
return sortOrder === 'ascend' ? -1 : 1;
} else { } else {
return a.accuracy - b.accuracy; return a.latestAccuracy - b.latestAccuracy;
} }
}, },
render: (text, record) => ( render: (text, record) => (
// TODO: is this needed? <div>{record.formattedLatestAccuracy}</div>
<div>{record.latestAccuracy}</div>
) )
}; };
......
...@@ -186,5 +186,5 @@ function formatAccuracy(accuracy: number): string { ...@@ -186,5 +186,5 @@ function formatAccuracy(accuracy: number): string {
export { export {
convertTime, convertDuration, getFinalResult, getFinal, downFile, convertTime, convertDuration, getFinalResult, getFinal, downFile,
intermediateGraphOption, killJob, filterByStatus, filterDuration, intermediateGraphOption, killJob, filterByStatus, filterDuration,
formatAccuracy, formatTimestamp, metricAccuracy, formatAccuracy, formatTimestamp, metricAccuracy
}; };
...@@ -24,7 +24,8 @@ interface TableRecord { ...@@ -24,7 +24,8 @@ interface TableRecord {
status: string; status: string;
intermediateCount: number; intermediateCount: number;
accuracy?: number; accuracy?: number;
latestAccuracy: string; // formatted string latestAccuracy: number | undefined;
formattedLatestAccuracy: string; // format (LATEST/FINAL)
} }
interface SearchSpace { interface SearchSpace {
......
...@@ -46,6 +46,22 @@ class Trial implements TableObj { ...@@ -46,6 +46,22 @@ class Trial implements TableObj {
return this.metricsInitialized && this.finalAcc !== undefined && !isNaN(this.finalAcc); return this.metricsInitialized && this.finalAcc !== undefined && !isNaN(this.finalAcc);
} }
get latestAccuracy(): number | undefined {
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 JSON.parse(temp.data);
} else {
return undefined;
}
} else {
return undefined;
}
}
/* table obj start */ /* table obj start */
get tableRecord(): TableRecord { get tableRecord(): TableRecord {
...@@ -62,7 +78,8 @@ class Trial implements TableObj { ...@@ -62,7 +78,8 @@ class Trial implements TableObj {
status: this.info.status, status: this.info.status,
intermediateCount: this.intermediates.length, intermediateCount: this.intermediates.length,
accuracy: this.finalAcc, accuracy: this.finalAcc,
latestAccuracy: this.formatLatestAccuracy(), latestAccuracy: this.latestAccuracy,
formattedLatestAccuracy: this.formatLatestAccuracy(),
}; };
} }
......
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