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

Update WebUI for metrics data changing to json string #2067

Merged
merged 4 commits into from
Feb 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions src/webui/src/components/trial-detail/TableList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Stack, Dropdown, DetailsList, IDetailsListProps, DetailsListLayoutMode,
PrimaryButton, Modal, IDropdownOption, IColumn, Selection, SelectionMode, IconButton
} from 'office-ui-fabric-react';
import * as JSON5 from 'json5';
import { LineChart, blocked, copy } from '../Buttons/Icon';
import { MANAGER_IP, COLUMNPro } from '../../static/const';
import { convertDuration, formatTimestamp, intermediateGraphOption, parseMetrics } from '../../static/function';
Expand Down Expand Up @@ -377,7 +378,7 @@ class TableList extends React.Component<TableListProps, TableListState> {

// trial parameters & dict final keys & Trial No. Id ...
private getAllColumnKeys = (): string[] => {
const tableSource: Array<TableRecord> = JSON.parse(JSON.stringify(this.props.tableSource));
const tableSource: Array<TableRecord> = JSON5.parse(JSON5.stringify(this.props.tableSource));
// parameter as table column
const parameterStr: string[] = [];
if (tableSource.length > 0) {
Expand Down Expand Up @@ -545,7 +546,7 @@ class TableList extends React.Component<TableListProps, TableListState> {
isShowCustomizedModal, copyTrialId, intermediateOption
} = this.state;
const { columnList } = this.props;
const tableSource: Array<TableRecord> = JSON.parse(JSON.stringify(this.state.tableSourceForSort));
const tableSource: Array<TableRecord> = JSON5.parse(JSON5.stringify(this.state.tableSourceForSort));

return (
<Stack>
Expand Down
6 changes: 2 additions & 4 deletions src/webui/src/static/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const getFinalResult = (final?: MetricDataRecord[]): number => {
let acc;
let showDefault = 0;
if (final) {
acc = JSON.parse(final[final.length - 1].data);
acc = JSON5.parse(final[final.length - 1].data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to call parseMetrics here? there maybe more updates in parseMetrics later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK.

if (typeof (acc) === 'object') {
if (acc.default) {
showDefault = acc.default;
Expand All @@ -61,7 +61,7 @@ const getFinalResult = (final?: MetricDataRecord[]): number => {
const getFinal = (final?: MetricDataRecord[]): FinalType | undefined => {
let showDefault: FinalType;
if (final) {
showDefault = JSON.parse(final[final.length - 1].data);
showDefault = JSON5.parse(final[final.length - 1].data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be replaced by parseMetrics?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

if (typeof showDefault === 'number') {
showDefault = { default: showDefault };
}
Expand Down Expand Up @@ -182,8 +182,6 @@ function formatTimestamp(timestamp?: number, placeholder?: string): string {
function parseMetrics(metricData: string): any {
if (metricData.includes('NaN')) {
return JSON5.parse(metricData)
} else {
return JSON.parse(metricData)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought UI only use JSON5 from the teams message.
It's misleading, I'll change this back.

}
}

Expand Down