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

Fix table sort issue #1773

Merged
merged 4 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 4 additions & 5 deletions src/webui/src/components/trial-detail/TableList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -586,17 +586,16 @@ const AccuracyColumnConfig: ColumnProps<TableRecord> = {
dataIndex: 'accuracy',
width: 120,
sorter: (a, b, sortOrder) => {
if (a.accuracy === undefined) {
if (a.latestAccuracy === undefined) {
return sortOrder === 'ascend' ? -1 : 1;
} else if (b.accuracy === undefined) {
} else if (b.latestAccuracy === undefined) {
return sortOrder === 'ascend' ? 1 : -1;
} else {
return a.accuracy - b.accuracy;
return a.latestAccuracy - b.latestAccuracy;
}
},
render: (text, record) => (
// TODO: is this needed?
<div>{record.latestAccuracy}</div>
<div>{record.formattedLatestAccuracy}</div>
)
};

Expand Down
2 changes: 1 addition & 1 deletion src/webui/src/static/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,5 @@ function formatAccuracy(accuracy: number): string {
export {
convertTime, convertDuration, getFinalResult, getFinal, downFile,
intermediateGraphOption, killJob, filterByStatus, filterDuration,
formatAccuracy, formatTimestamp, metricAccuracy,
formatAccuracy, formatTimestamp, metricAccuracy
};
3 changes: 2 additions & 1 deletion src/webui/src/static/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ interface TableRecord {
status: string;
intermediateCount: number;
accuracy?: number;
latestAccuracy: string; // formatted string
latestAccuracy: number | undefined;
formattedLatestAccuracy: string; // format (LATEST/FINAL)
}

interface SearchSpace {
Expand Down
19 changes: 18 additions & 1 deletion src/webui/src/static/model/trial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ class Trial implements TableObj {
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 */

get tableRecord(): TableRecord {
Expand All @@ -62,7 +78,8 @@ class Trial implements TableObj {
status: this.info.status,
intermediateCount: this.intermediates.length,
accuracy: this.finalAcc,
latestAccuracy: this.formatLatestAccuracy(),
latestAccuracy: this.latestAccuracy,
formattedLatestAccuracy: this.formatLatestAccuracy(),
};
}

Expand Down