Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show - for empty data in searches table [ET-749] #9963

Merged
merged 4 commits into from
Sep 23, 2024
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
2 changes: 1 addition & 1 deletion webui/react/src/components/ExperimentActionDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const ExperimentActionDropdown: React.FC<Props> = ({

const cellCopyData = useMemo(() => {
if (cell && 'displayData' in cell && isString(cell.displayData)) return cell.displayData;
if (cell?.copyData) return cell.copyData;
if (cell?.copyData && cell.copyData !== '-') return cell.copyData;
return undefined;
}, [cell]);

Expand Down
154 changes: 72 additions & 82 deletions webui/react/src/components/Searches/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { getDurationInEnglish, getTimeInEnglish } from 'utils/datetime';
import { humanReadableNumber } from 'utils/number';
import { AnyMouseEvent } from 'utils/routes';
import { floatToPercent, humanReadableBytes } from 'utils/string';
import { handleEmptyCell } from 'utils/table';
import { getDisplayName } from 'utils/user';

// order used in ColumnPickerMenu
Expand Down Expand Up @@ -143,97 +144,98 @@ export const getColumnDefs = ({
checkpointSize: {
id: 'checkpointSize',
isNumerical: true,
renderer: (record: ExperimentWithTrial) => ({
allowOverlay: false,
copyData: record.experiment.checkpointSize
? humanReadableBytes(record.experiment.checkpointSize)
: '',
data: { kind: TEXT_CELL },
kind: GridCellKind.Custom,
}),
renderer: (record: ExperimentWithTrial) =>
handleEmptyCell(record.experiment.checkpointSize, (data) => ({
allowOverlay: false,
copyData: humanReadableBytes(data),
data: { kind: TEXT_CELL },
kind: GridCellKind.Custom,
})),
title: 'Checkpoint Size',
tooltip: () => undefined,
width: columnWidths.checkpointSize,
},
description: {
id: 'description',
renderer: (record: ExperimentWithTrial) => ({
allowOverlay: false,
copyData: String(record.experiment.description),
data: { kind: TEXT_CELL },
kind: GridCellKind.Custom,
}),
renderer: (record: ExperimentWithTrial) =>
handleEmptyCell(
record.experiment.description,
(data) => ({
allowOverlay: false,
copyData: String(data),
data: { kind: TEXT_CELL },
kind: GridCellKind.Custom,
}),
false,
),
title: 'Description',
tooltip: () => undefined,
width: columnWidths.description,
},
duration: {
id: 'duration',
isNumerical: true,
renderer: (record: ExperimentWithTrial) => ({
allowOverlay: false,
copyData: getDurationInEnglish(record.experiment),
data: { kind: TEXT_CELL },
kind: GridCellKind.Custom,
}),
renderer: (record: ExperimentWithTrial) =>
handleEmptyCell(record.experiment.duration, () => ({
allowOverlay: false,
copyData: getDurationInEnglish(record.experiment),
data: { kind: TEXT_CELL },
kind: GridCellKind.Custom,
})),
title: 'Duration',
tooltip: () => undefined,
width: columnWidths.duration,
},
externalExperimentId: {
id: 'externalExperimentId',
renderer: (record: ExperimentWithTrial) => ({
allowOverlay: false,
copyData: record.experiment.externalExperimentId ?? '',
data: { kind: TEXT_CELL },
kind: GridCellKind.Custom,
}),
renderer: (record: ExperimentWithTrial) =>
handleEmptyCell(record.experiment.externalExperimentId, (data) => ({
allowOverlay: false,
copyData: data,
data: { kind: TEXT_CELL },
kind: GridCellKind.Custom,
})),
title: 'External Search ID',
tooltip: () => undefined,
width: columnWidths.externalExperimentId,
},
externalTrialId: {
id: 'externalTrialId',
renderer: (record: ExperimentWithTrial) => ({
allowOverlay: false,
copyData: record.experiment.externalTrialId ?? '',
data: { kind: TEXT_CELL },
kind: GridCellKind.Custom,
}),
renderer: (record: ExperimentWithTrial) =>
handleEmptyCell(record.experiment.externalTrialId, (data) => ({
allowOverlay: false,
copyData: data,
data: { kind: TEXT_CELL },
kind: GridCellKind.Custom,
})),
title: 'External Trial ID',
tooltip: () => undefined,
width: columnWidths.externalTrialId,
},
forkedFrom: {
id: 'forkedFrom',
renderer: (record: ExperimentWithTrial) => ({
allowOverlay: false,
copyData: String(record.experiment.forkedFrom ?? ''),
cursor: record.experiment.forkedFrom ? 'pointer' : undefined,
data: {
kind: LINK_CELL,
link:
record.experiment.forkedFrom !== undefined
? {
href: record.experiment.forkedFrom
? paths.experimentDetails(record.experiment.forkedFrom)
: undefined,
title: String(record.experiment.forkedFrom ?? ''),
}
: undefined,
navigateOn: 'click',
underlineOffset: 6,
},
kind: GridCellKind.Custom,
onClick: (e: CellClickedEventArgs) => {
if (record.experiment.forkedFrom) {
renderer: (record: ExperimentWithTrial) =>
handleEmptyCell(record.experiment.forkedFrom, (data) => ({
allowOverlay: false,
copyData: String(record.experiment.forkedFrom),
cursor: 'pointer',
data: {
kind: LINK_CELL,
link: {
href: paths.experimentDetails(data),
title: String(record.experiment.forkedFrom),
},
navigateOn: 'click',
underlineOffset: 6,
},
kind: GridCellKind.Custom,
onClick: (e: CellClickedEventArgs) => {
handlePath(e as unknown as AnyMouseEvent, {
path: String(record.experiment.forkedFrom),
});
}
},
readonly: true,
}),
},
readonly: true,
})),
title: 'Forked From',
tooltip: () => undefined,
width: columnWidths.forkedFrom,
Expand Down Expand Up @@ -308,16 +310,13 @@ export const getColumnDefs = ({
},
progress: {
id: 'progress',
renderer: (record: ExperimentWithTrial) => {
const percentage = floatToPercent(record.experiment.progress ?? 0, 0);

return {
renderer: (record: ExperimentWithTrial) =>
handleEmptyCell(record.experiment.progress, (data) => ({
allowOverlay: false,
data: percentage,
displayData: percentage,
data: floatToPercent(data, 0),
displayData: floatToPercent(data, 0),
kind: GridCellKind.Text,
};
},
})),
title: 'Progress',
tooltip: () => undefined,
width: columnWidths.progress,
Expand All @@ -337,15 +336,13 @@ export const getColumnDefs = ({
searcherMetric: {
id: 'searcherMetric',
isNumerical: false,
renderer: (record: ExperimentWithTrial) => {
const sMetric = record.experiment.searcherMetric ?? '';
return {
renderer: (record: ExperimentWithTrial) =>
handleEmptyCell(record.experiment.searcherMetric, (data) => ({
allowOverlay: false,
copyData: sMetric,
copyData: data,
data: { kind: TEXT_CELL },
kind: GridCellKind.Custom,
};
},
})),
title: 'Searcher Metric',
tooltip: () => undefined,
width: columnWidths.searcherMetric,
Expand Down Expand Up @@ -444,20 +441,13 @@ export const searcherMetricsValColumn = (columnWidth?: number): ColumnDef<Experi
return {
id: 'searcherMetricsVal',
isNumerical: true,
renderer: (record: ExperimentWithTrial) => {
const sMetricValue = record.bestTrial?.searcherMetricsVal;

return {
renderer: (record: ExperimentWithTrial) =>
handleEmptyCell(record.bestTrial?.searcherMetricsVal, (data) => ({
allowOverlay: false,
copyData: sMetricValue
? typeof sMetricValue === 'number'
? humanReadableNumber(sMetricValue)
: sMetricValue
: '',
copyData: humanReadableNumber(data),
data: { kind: TEXT_CELL },
kind: GridCellKind.Custom,
};
},
})),
title: 'Searcher Metric Value',
tooltip: () => undefined,
width: columnWidth ?? DEFAULT_COLUMN_WIDTH,
Expand Down
Loading
Loading