From 3f775a26a25801c08b77ec780e97cccbf65ca170 Mon Sep 17 00:00:00 2001 From: julieg18 Date: Tue, 23 Aug 2022 13:42:09 -0500 Subject: [PATCH 01/10] Make timestamp column hideable --- .../experiments/columns/collect/index.test.ts | 3 + .../src/experiments/columns/collect/index.ts | 2 + .../experiments/columns/collect/timestamp.ts | 14 +++ extension/src/experiments/columns/extract.ts | 4 +- .../src/experiments/columns/model.test.ts | 3 + .../src/experiments/columns/quickPick.ts | 13 +-- .../src/experiments/columns/tree.test.ts | 24 +++++- extension/src/experiments/columns/tree.ts | 7 +- extension/src/experiments/model/collect.ts | 5 +- extension/src/experiments/webview/contract.ts | 3 +- extension/src/path/selection/model.ts | 11 ++- extension/src/path/selection/quickPick.ts | 5 +- .../src/test/fixtures/expShow/columns.ts | 2 + .../src/test/fixtures/expShow/dataTypes.ts | 5 +- .../src/test/fixtures/expShow/deeplyNested.ts | 3 +- extension/src/test/fixtures/expShow/rows.ts | 3 +- .../experiments/components/Experiments.tsx | 30 +++++-- .../components/table/Table.test.tsx | 2 +- .../components/table/TableHeader.tsx | 85 ++++++++++--------- webview/src/test/sort.ts | 6 +- 20 files changed, 155 insertions(+), 75 deletions(-) create mode 100644 extension/src/experiments/columns/collect/timestamp.ts diff --git a/extension/src/experiments/columns/collect/index.test.ts b/extension/src/experiments/columns/collect/index.test.ts index 387b2349f4..1382173edd 100644 --- a/extension/src/experiments/columns/collect/index.test.ts +++ b/extension/src/experiments/columns/collect/index.test.ts @@ -1,5 +1,6 @@ import { join } from 'path' import { collectChanges, collectColumns } from '.' +import { timestampColumn } from './timestamp' import { buildDepPath, buildMetricOrParamPath } from '../paths' import { Column, ColumnType } from '../../webview/contract' import outputFixture from '../../../test/fixtures/expShow/output' @@ -335,6 +336,7 @@ describe('collectColumns', () => { }) expect(columns.map(({ path }) => path)).toStrictEqual([ + timestampColumn.path, buildMetricOrParamPath(ColumnType.PARAMS, 'params.yaml'), buildMetricOrParamPath( ColumnType.PARAMS, @@ -419,6 +421,7 @@ describe('collectColumns', () => { it('should collect all params and metrics from the test fixture', () => { expect(collectColumns(outputFixture).map(({ path }) => path)).toStrictEqual( [ + timestampColumn.path, buildMetricOrParamPath(ColumnType.METRICS, 'summary.json'), buildMetricOrParamPath(ColumnType.METRICS, 'summary.json', 'loss'), buildMetricOrParamPath(ColumnType.METRICS, 'summary.json', 'accuracy'), diff --git a/extension/src/experiments/columns/collect/index.ts b/extension/src/experiments/columns/collect/index.ts index cd6811df8e..70c4946957 100644 --- a/extension/src/experiments/columns/collect/index.ts +++ b/extension/src/experiments/columns/collect/index.ts @@ -1,6 +1,7 @@ import { join } from 'path' import { ColumnAccumulator } from './util' import { collectDepChanges, collectDeps } from './deps' +import { collectTimestamp } from './timestamp' import { collectMetricAndParamChanges, collectMetricsAndParams @@ -19,6 +20,7 @@ const collectFromExperiment = ( ) => { const { data } = experiment if (data) { + collectTimestamp(acc) collectMetricsAndParams(acc, data) collectDeps(acc, data) } diff --git a/extension/src/experiments/columns/collect/timestamp.ts b/extension/src/experiments/columns/collect/timestamp.ts new file mode 100644 index 0000000000..c11d2b25e5 --- /dev/null +++ b/extension/src/experiments/columns/collect/timestamp.ts @@ -0,0 +1,14 @@ +import { ColumnAccumulator } from './util' +import { ColumnType } from '../../webview/contract' + +export const timestampColumn = { + hasChildren: false, + label: 'Timestamp', + parentPath: 'timestamp', + path: 'timestamp:timestamp', + type: ColumnType.TIMESTAMP +} + +export const collectTimestamp = (acc: ColumnAccumulator) => { + acc.timestamp = timestampColumn +} diff --git a/extension/src/experiments/columns/extract.ts b/extension/src/experiments/columns/extract.ts index f12536d8a3..f0f8ade89d 100644 --- a/extension/src/experiments/columns/extract.ts +++ b/extension/src/experiments/columns/extract.ts @@ -73,6 +73,7 @@ type Columns = { deps: DepColumns | undefined metrics: MetricOrParamColumns | undefined params: MetricOrParamColumns | undefined + timestamp: string | null | undefined } export const extractColumns = ( @@ -90,7 +91,8 @@ export const extractColumns = ( const columns: Columns = { deps: extractDeps(experiment.deps, branch), metrics: metricsData?.columns, - params: paramsData?.columns + params: paramsData?.columns, + timestamp: experiment?.timestamp } if (error) { diff --git a/extension/src/experiments/columns/model.test.ts b/extension/src/experiments/columns/model.test.ts index 22c6b888be..0348f29641 100644 --- a/extension/src/experiments/columns/model.test.ts +++ b/extension/src/experiments/columns/model.test.ts @@ -1,5 +1,6 @@ import { ColumnsModel } from './model' import { appendColumnToPath, buildMetricOrParamPath } from './paths' +import { timestampColumn } from './collect/timestamp' import { buildMockMemento } from '../../test/util' import { Status } from '../../path/selection/model' import { PersistenceKey } from '../../persistence/constants' @@ -61,6 +62,7 @@ describe('ColumnsModel', () => { const model = new ColumnsModel(exampleDvcRoot, buildMockMemento()) await model.transformAndSet(exampleData) expect(model.getSelected()).toStrictEqual([ + timestampColumn, { hasChildren: true, label: 'params.yaml', @@ -93,6 +95,7 @@ describe('ColumnsModel', () => { ) await model.transformAndSet(exampleData) expect(model.getSelected()).toStrictEqual([ + timestampColumn, { hasChildren: true, label: 'params.yaml', diff --git a/extension/src/experiments/columns/quickPick.ts b/extension/src/experiments/columns/quickPick.ts index f0e9c748ea..506888b6fd 100644 --- a/extension/src/experiments/columns/quickPick.ts +++ b/extension/src/experiments/columns/quickPick.ts @@ -1,4 +1,5 @@ import { ColumnLike } from './like' +import { timestampColumn } from './collect/timestamp' import { definedAndNonEmpty } from '../../util/array' import { QuickPickOptionsWithTitle, @@ -14,11 +15,13 @@ export const pickFromColumnLikes = ( return Toast.showError('There are no columns to select from.') } return quickPickValue( - columnLikes.map(columnLike => ({ - description: columnLike.path, - label: columnLike.label, - value: columnLike - })), + columnLikes + .filter(columnLike => columnLike.path !== timestampColumn.path) + .map(columnLike => ({ + description: columnLike.path, + label: columnLike.label, + value: columnLike + })), quickPickOptions ) } diff --git a/extension/src/experiments/columns/tree.test.ts b/extension/src/experiments/columns/tree.test.ts index db64a496c4..632602874b 100644 --- a/extension/src/experiments/columns/tree.test.ts +++ b/extension/src/experiments/columns/tree.test.ts @@ -8,6 +8,7 @@ import { buildMetricOrParamPath, splitColumnPath } from './paths' +import { timestampColumn } from './collect/timestamp' import columnsFixture from '../../test/fixtures/expShow/columns' import { Resource, ResourceLocator } from '../../resourceLocator' import { RegisteredCommands } from '../../commands/external' @@ -78,7 +79,10 @@ describe('ExperimentsColumnsTree', () => { .map(column => ({ ...column, descendantStatuses: [], - label: getLabel(column.path), + label: + column.type === ColumnType.TIMESTAMP + ? timestampColumn.label + : getLabel(column.path), status: Status.SELECTED })) @@ -101,7 +105,7 @@ describe('ExperimentsColumnsTree', () => { ) }) - it('should return the params and metrics if there is only a single repository and no path is provided', async () => { + it('should return the params, metrics, and timestamp if there is only a single repository and no path is provided', async () => { const experimentsColumnsTree = new ExperimentsColumnsTree( mockedExperiments, mockedInternalCommands, @@ -115,6 +119,14 @@ describe('ExperimentsColumnsTree', () => { const children = await experimentsColumnsTree.getChildren() expect(children).toStrictEqual([ + { + collapsibleState: 0, + description: undefined, + dvcRoot: mockedDvcRoot, + iconPath: mockedSelectedCheckbox, + label: timestampColumn.label, + path: timestampColumn.path + }, { collapsibleState: 1, description: undefined, @@ -194,6 +206,14 @@ describe('ExperimentsColumnsTree', () => { const processPath = appendColumnToPath(paramsPath, 'process') expect(children).toStrictEqual([ + { + collapsibleState: 0, + description: undefined, + dvcRoot: mockedDvcRoot, + iconPath: mockedSelectedCheckbox, + label: timestampColumn.label, + path: timestampColumn.path + }, { collapsibleState: 1, description: undefined, diff --git a/extension/src/experiments/columns/tree.ts b/extension/src/experiments/columns/tree.ts index 58d7d10dca..3dd6632f2e 100644 --- a/extension/src/experiments/columns/tree.ts +++ b/extension/src/experiments/columns/tree.ts @@ -1,3 +1,4 @@ +import { timestampColumn } from './collect/timestamp' import { BasePathSelectionTree, PathSelectionItem @@ -26,7 +27,11 @@ export class ExperimentsColumnsTree extends BasePathSelectionTree( RegisteredCommands.EXPERIMENT_METRICS_AND_PARAMS_TOGGLE, ({ dvcRoot, path }) => - this.workspace.getRepository(dvcRoot).toggleColumnStatus(path) + this.workspace + .getRepository(dvcRoot) + .toggleColumnStatus( + path === timestampColumn.path ? timestampColumn.parentPath : path + ) ) } diff --git a/extension/src/experiments/model/collect.ts b/extension/src/experiments/model/collect.ts index e5150b66f3..379b41ca7a 100644 --- a/extension/src/experiments/model/collect.ts +++ b/extension/src/experiments/model/collect.ts @@ -125,11 +125,14 @@ const transformColumns = ( experimentFields: ExperimentFields, branch?: Experiment ) => { - const { error, metrics, params, deps } = extractColumns( + const { error, metrics, params, deps, timestamp } = extractColumns( experimentFields, branch ) + if (timestamp) { + experiment.timestamp = timestamp + } if (metrics) { experiment.metrics = metrics } diff --git a/extension/src/experiments/webview/contract.ts b/extension/src/experiments/webview/contract.ts index 00461cfc24..396dddd76c 100644 --- a/extension/src/experiments/webview/contract.ts +++ b/extension/src/experiments/webview/contract.ts @@ -45,7 +45,8 @@ export interface ColumnAggregateData { export enum ColumnType { METRICS = 'metrics', PARAMS = 'params', - DEPS = 'deps' + DEPS = 'deps', + TIMESTAMP = 'timestamp' } export interface Column extends ColumnAggregateData { diff --git a/extension/src/path/selection/model.ts b/extension/src/path/selection/model.ts index ff486cbd04..e6ad3e813b 100644 --- a/extension/src/path/selection/model.ts +++ b/extension/src/path/selection/model.ts @@ -1,8 +1,9 @@ import { Memento } from 'vscode' import { PersistenceKey } from '../../persistence/constants' import { ModelWithPersistence } from '../../persistence/model' -import { Column } from '../../experiments/webview/contract' +import { Column, ColumnType } from '../../experiments/webview/contract' import { PlotPath } from '../../plots/paths/collect' +import { timestampColumn } from '../../experiments/columns/collect/timestamp' export enum Status { SELECTED = 2, @@ -76,15 +77,17 @@ export abstract class PathSelectionModel< public setSelected(elements: (T & { selected: boolean })[]) { const terminalNodes = this.getTerminalNodes() - for (const { path, selected } of terminalNodes) { + terminalNodes.map(({ path, selected, type }) => { const selectedElement = elements.find( ({ path: selectedPath }) => path === selectedPath ) if (!!selectedElement !== !!selected) { - this.toggleStatus(path) + const statusPath = + type === ColumnType.TIMESTAMP ? timestampColumn.parentPath : path + this.toggleStatus(statusPath) } - } + }) } protected setNewStatuses(data: { path: string }[]) { diff --git a/extension/src/path/selection/quickPick.ts b/extension/src/path/selection/quickPick.ts index 950612beac..080dfb2410 100644 --- a/extension/src/path/selection/quickPick.ts +++ b/extension/src/path/selection/quickPick.ts @@ -5,7 +5,7 @@ import { quickPickManyValues } from '../../vscode/quickPick' import { Title } from '../../vscode/title' -import { Column } from '../../experiments/webview/contract' +import { Column, ColumnType } from '../../experiments/webview/contract' import { PlotPath } from '../../plots/paths/collect' type PathType = PlotPath | Column @@ -15,7 +15,7 @@ type PathWithSelected = T & { } const getItem = (element: PathWithSelected) => ({ - label: element.path, + label: element.type === ColumnType.TIMESTAMP ? element.label : element.path, picked: element.selected, value: element }) @@ -41,7 +41,6 @@ export const pickPaths = ( if (!definedAndNonEmpty(paths)) { return Toast.showError(`There are no ${type} to select.`) } - const items = collectItems(paths) return quickPickManyValues>(items, { diff --git a/extension/src/test/fixtures/expShow/columns.ts b/extension/src/test/fixtures/expShow/columns.ts index 58c0f0524c..963be128fb 100644 --- a/extension/src/test/fixtures/expShow/columns.ts +++ b/extension/src/test/fixtures/expShow/columns.ts @@ -4,10 +4,12 @@ import { buildDepPath, buildMetricOrParamPath } from '../../../experiments/columns/paths' +import { timestampColumn } from '../../../experiments/columns/collect/timestamp' const nestedParamsFile = join('nested', 'params.yaml') const data: Column[] = [ + timestampColumn, { type: ColumnType.METRICS, hasChildren: true, diff --git a/extension/src/test/fixtures/expShow/dataTypes.ts b/extension/src/test/fixtures/expShow/dataTypes.ts index d294915f44..9f89578d44 100644 --- a/extension/src/test/fixtures/expShow/dataTypes.ts +++ b/extension/src/test/fixtures/expShow/dataTypes.ts @@ -1,4 +1,5 @@ import { ExperimentsOutput } from '../../../cli/dvc/reader' +import { timestampColumn } from '../../../experiments/columns/collect/timestamp' import { Column, ColumnType, @@ -45,6 +46,7 @@ export const dataTypesOutput: ExperimentsOutput = { } export const columns: Column[] = [ + timestampColumn, { hasChildren: true, label: 'params.yaml', @@ -160,8 +162,7 @@ export const rows: Row[] = [ queued: false, running: false, selected: true, - starred: false, - timestamp: null + starred: false }, { displayColor: '#13adc7', diff --git a/extension/src/test/fixtures/expShow/deeplyNested.ts b/extension/src/test/fixtures/expShow/deeplyNested.ts index d54c8fad1f..e9f13384f7 100644 --- a/extension/src/test/fixtures/expShow/deeplyNested.ts +++ b/extension/src/test/fixtures/expShow/deeplyNested.ts @@ -1,4 +1,5 @@ import { ExperimentsOutput } from '../../../cli/dvc/reader' +import { timestampColumn } from '../../../experiments/columns/collect/timestamp' import { Column, ColumnType, @@ -72,6 +73,7 @@ export const deeplyNestedOutput: ExperimentsOutput = { } export const columns: Column[] = [ + timestampColumn, { hasChildren: true, label: 'params.yaml', @@ -218,7 +220,6 @@ export const rows = [ { id: 'workspace', label: 'workspace', - timestamp: null, queued: false, running: false, executor: null, diff --git a/extension/src/test/fixtures/expShow/rows.ts b/extension/src/test/fixtures/expShow/rows.ts index 8e4c476a6c..5297cace54 100644 --- a/extension/src/test/fixtures/expShow/rows.ts +++ b/extension/src/test/fixtures/expShow/rows.ts @@ -95,8 +95,7 @@ const data: Row[] = [ queued: false, running: true, selected: true, - starred: false, - timestamp: null + starred: false }, { deps: { diff --git a/webview/src/experiments/components/Experiments.tsx b/webview/src/experiments/components/Experiments.tsx index 59b332b242..1ecafc5271 100644 --- a/webview/src/experiments/components/Experiments.tsx +++ b/webview/src/experiments/components/Experiments.tsx @@ -67,8 +67,12 @@ const DateCellContents: React.FC<{ value: string }> = ({ value }) => { ) } -const getColumns = (columns: Column[]): TableColumn[] => - [ +const getColumns = (columns: Column[]): TableColumn[] => { + const includeTimestamp = columns.some( + ({ type }) => type === ColumnType.TIMESTAMP + ) + + const builtColumns = [ { Cell: ({ row: { @@ -92,8 +96,14 @@ const getColumns = (columns: Column[]): TableColumn[] => minWidth: 250, width: 250 }, - { - Cell: ({ value }: { value: string }) => { + ...buildDynamicColumns(columns, ColumnType.METRICS), + ...buildDynamicColumns(columns, ColumnType.PARAMS), + ...buildDynamicColumns(columns, ColumnType.DEPS) + ] as TableColumn[] + + if (includeTimestamp) { + builtColumns.splice(1, 0, { + Cell: ({ value }) => { return (
{value && } @@ -102,12 +112,14 @@ const getColumns = (columns: Column[]): TableColumn[] => }, Header: TimestampHeader, accessor: 'timestamp', + group: ColumnType.TIMESTAMP, + id: 'timestamp', width: 100 - }, - ...buildDynamicColumns(columns, ColumnType.METRICS), - ...buildDynamicColumns(columns, ColumnType.PARAMS), - ...buildDynamicColumns(columns, ColumnType.DEPS) - ] as TableColumn[] + }) + } + + return builtColumns +} const reportResizedColumn = (state: TableState) => { const id = state.columnResizing.isResizingColumn diff --git a/webview/src/experiments/components/table/Table.test.tsx b/webview/src/experiments/components/table/Table.test.tsx index 1217ed6cef..d6f8293e4b 100644 --- a/webview/src/experiments/components/table/Table.test.tsx +++ b/webview/src/experiments/components/table/Table.test.tsx @@ -323,7 +323,7 @@ describe('Table', () => { dragAndDrop( screen.getByText('B'), - screen.getByText('Timestamp'), + screen.getByText('Experiment'), DragEnterDirection.AUTO ) diff --git a/webview/src/experiments/components/table/TableHeader.tsx b/webview/src/experiments/components/table/TableHeader.tsx index 764b6d858e..ed66364ae7 100644 --- a/webview/src/experiments/components/table/TableHeader.tsx +++ b/webview/src/experiments/components/table/TableHeader.tsx @@ -321,13 +321,14 @@ export const TableHeader: React.FC = ({ !column.placeholderOf && !['id', 'timestamp'].includes(column.id) && !column.columns + const isTimestamp = column.group === ColumnType.TIMESTAMP const sortOrder: SortOrder = possibleOrders[`${sort?.descending}`] const contextMenuOptions: MessagesMenuOptionProps[] = React.useMemo(() => { const menuOptions: MessagesMenuOptionProps[] = [ { - hidden: !!column.headers, + hidden: !isTimestamp && !!column.headers, id: 'hide-column', label: 'Hide Column', message: { @@ -347,7 +348,7 @@ export const TableHeader: React.FC = ({ ] return menuOptions - }, [column]) + }, [column, isTimestamp]) return ( = ({ onDragEnter={onDragEnter} onDragStart={onDragStart} onDrop={onDrop} - menuDisabled={!isSortable && column.group !== ColumnType.PARAMS} + menuDisabled={ + !isSortable && !isTimestamp && column.group !== ColumnType.PARAMS + } root={root} firstExpColumnCellId={firstExpColumnCellId} setExpColumnNeedsShadow={setExpColumnNeedsShadow} menuContent={
- - + + + { + hidden: sortOrder === SortOrder.NONE, + id: SortOrder.NONE, + label: SortOrder.NONE, + message: { + payload: column.id, + type: MessageFromWebviewType.REMOVE_COLUMN_SORT + } + } + ]} + /> + + )}
} /> diff --git a/webview/src/test/sort.ts b/webview/src/test/sort.ts index 96d8071330..ab76a5ed61 100644 --- a/webview/src/test/sort.ts +++ b/webview/src/test/sort.ts @@ -1,7 +1,7 @@ import { screen } from '@testing-library/react' import { ColumnType, TableData } from 'dvc/src/experiments/webview/contract' -export const defaultColumns = ['Experiment', 'Timestamp'] +export const defaultColumns = ['Experiment'] export const commonColumnFields = { hasChildren: false, @@ -54,8 +54,8 @@ export const tableData: TableData = { } export const getHeaders = async () => { - const renderedHeader = await screen.findAllByTestId('rendered-header') - return renderedHeader.map(header => header.textContent) + const renderedHeaders = await screen.findAllByTestId('rendered-header') + return renderedHeaders.map(header => header.textContent) } export const expectHeaders = async (expectedHeaderNames: string[]) => { From 64f0b6a053d4e1b3c2022c25c505fd102444dcee Mon Sep 17 00:00:00 2001 From: mattseddon <37993418+mattseddon@users.noreply.github.com> Date: Thu, 25 Aug 2022 00:33:42 +1000 Subject: [PATCH 02/10] make some suggestions (#2247) --- extension/.prettierignore | 1 + .../experiments/columns/collect/timestamp.ts | 4 +-- extension/src/experiments/columns/extract.ts | 6 ++-- extension/src/experiments/columns/model.ts | 4 +-- .../src/experiments/columns/tree.test.ts | 5 +--- extension/src/experiments/columns/tree.ts | 7 +---- extension/src/experiments/index.ts | 13 ++++---- extension/src/experiments/model/collect.ts | 6 ++-- .../experiments/model/status/index.test.ts | 18 +++++------ .../src/experiments/model/status/index.ts | 2 +- extension/src/experiments/webview/contract.ts | 1 + extension/src/experiments/webview/messages.ts | 2 +- extension/src/path/selection/model.ts | 9 ++---- extension/src/path/selection/quickPick.ts | 4 +-- .../src/test/fixtures/expShow/dataTypes.ts | 2 +- .../src/test/fixtures/expShow/deeplyNested.ts | 2 +- extension/src/test/fixtures/expShow/rows.ts | 30 +++++++++---------- .../experiments/components/Experiments.tsx | 3 +- .../components/table/TableHeader.tsx | 3 +- 19 files changed, 58 insertions(+), 64 deletions(-) diff --git a/extension/.prettierignore b/extension/.prettierignore index b575855f1a..69f7aa4bb3 100644 --- a/extension/.prettierignore +++ b/extension/.prettierignore @@ -3,3 +3,4 @@ dist .wdio-vscode-service coverage src/test/fixtures/plotsDiff/vega.ts +CHANGELOG.md diff --git a/extension/src/experiments/columns/collect/timestamp.ts b/extension/src/experiments/columns/collect/timestamp.ts index c11d2b25e5..c0cc0bbcc8 100644 --- a/extension/src/experiments/columns/collect/timestamp.ts +++ b/extension/src/experiments/columns/collect/timestamp.ts @@ -4,8 +4,8 @@ import { ColumnType } from '../../webview/contract' export const timestampColumn = { hasChildren: false, label: 'Timestamp', - parentPath: 'timestamp', - path: 'timestamp:timestamp', + parentPath: ColumnType.TIMESTAMP, + path: 'Timestamp', type: ColumnType.TIMESTAMP } diff --git a/extension/src/experiments/columns/extract.ts b/extension/src/experiments/columns/extract.ts index f0f8ade89d..ccaabfe032 100644 --- a/extension/src/experiments/columns/extract.ts +++ b/extension/src/experiments/columns/extract.ts @@ -73,7 +73,7 @@ type Columns = { deps: DepColumns | undefined metrics: MetricOrParamColumns | undefined params: MetricOrParamColumns | undefined - timestamp: string | null | undefined + Timestamp: string | null | undefined } export const extractColumns = ( @@ -89,10 +89,10 @@ export const extractColumns = ( ].join('\n') const columns: Columns = { + Timestamp: experiment?.timestamp, deps: extractDeps(experiment.deps, branch), metrics: metricsData?.columns, - params: paramsData?.columns, - timestamp: experiment?.timestamp + params: paramsData?.columns } if (error) { diff --git a/extension/src/experiments/columns/model.ts b/extension/src/experiments/columns/model.ts index 6bb8f70431..fe2dad83cd 100644 --- a/extension/src/experiments/columns/model.ts +++ b/extension/src/experiments/columns/model.ts @@ -71,8 +71,8 @@ export class ColumnsModel extends PathSelectionModel { ) } - public hasColumns() { - return this.data.length > 0 + public hasNonDefaultColumns() { + return this.data.length > 1 } private async transformAndSetColumns(data: ExperimentsOutput) { diff --git a/extension/src/experiments/columns/tree.test.ts b/extension/src/experiments/columns/tree.test.ts index 632602874b..ed9c16a0e1 100644 --- a/extension/src/experiments/columns/tree.test.ts +++ b/extension/src/experiments/columns/tree.test.ts @@ -79,10 +79,7 @@ describe('ExperimentsColumnsTree', () => { .map(column => ({ ...column, descendantStatuses: [], - label: - column.type === ColumnType.TIMESTAMP - ? timestampColumn.label - : getLabel(column.path), + label: getLabel(column.path), status: Status.SELECTED })) diff --git a/extension/src/experiments/columns/tree.ts b/extension/src/experiments/columns/tree.ts index 3dd6632f2e..58d7d10dca 100644 --- a/extension/src/experiments/columns/tree.ts +++ b/extension/src/experiments/columns/tree.ts @@ -1,4 +1,3 @@ -import { timestampColumn } from './collect/timestamp' import { BasePathSelectionTree, PathSelectionItem @@ -27,11 +26,7 @@ export class ExperimentsColumnsTree extends BasePathSelectionTree( RegisteredCommands.EXPERIMENT_METRICS_AND_PARAMS_TOGGLE, ({ dvcRoot, path }) => - this.workspace - .getRepository(dvcRoot) - .toggleColumnStatus( - path === timestampColumn.path ? timestampColumn.parentPath : path - ) + this.workspace.getRepository(dvcRoot).toggleColumnStatus(path) ) } diff --git a/extension/src/experiments/index.ts b/extension/src/experiments/index.ts index 896b0acfa5..8f3a945c6a 100644 --- a/extension/src/experiments/index.ts +++ b/extension/src/experiments/index.ts @@ -1,4 +1,5 @@ import { Event, EventEmitter, Memento } from 'vscode' +import omit from 'lodash.omit' import { addStarredToColumns } from './columns/like' import { setContextForEditorTitleIcons } from './context' import { ExperimentsModel } from './model' @@ -33,7 +34,7 @@ import { pickPaths } from '../path/selection/quickPick' import { Toast } from '../vscode/toast' export const ExperimentsScale = { - ...ColumnType, + ...omit(ColumnType, 'TIMESTAMP'), HAS_CHECKPOINTS: 'hasCheckpoints', NO_CHECKPOINTS: 'noCheckpoints' } as const @@ -182,7 +183,9 @@ export class Experiments extends BaseRepository { const acc = createTypedAccumulator(ExperimentsScale) for (const { type } of this.columns.getTerminalNodes()) { - acc[type] = acc[type] + 1 + if (type in acc) { + acc[type] = acc[type] + 1 + } } const checkpointType = this.hasCheckpoints() ? ExperimentsScale.HAS_CHECKPOINTS @@ -277,7 +280,7 @@ export class Experiments extends BaseRepository { } public getExperimentCount() { - if (!this.columns.hasColumns()) { + if (!this.columns.hasNonDefaultColumns()) { return 0 } @@ -349,7 +352,7 @@ export class Experiments extends BaseRepository { } public getExperiments() { - if (!this.columns.hasColumns()) { + if (!this.columns.hasNonDefaultColumns()) { return [] } @@ -365,7 +368,7 @@ export class Experiments extends BaseRepository { } public getSelectedRevisions() { - if (!this.columns.hasColumns()) { + if (!this.columns.hasNonDefaultColumns()) { return [] } diff --git a/extension/src/experiments/model/collect.ts b/extension/src/experiments/model/collect.ts index 379b41ca7a..b12fc204c2 100644 --- a/extension/src/experiments/model/collect.ts +++ b/extension/src/experiments/model/collect.ts @@ -125,13 +125,13 @@ const transformColumns = ( experimentFields: ExperimentFields, branch?: Experiment ) => { - const { error, metrics, params, deps, timestamp } = extractColumns( + const { error, metrics, params, deps, Timestamp } = extractColumns( experimentFields, branch ) - if (timestamp) { - experiment.timestamp = timestamp + if (Timestamp) { + experiment.Timestamp = Timestamp } if (metrics) { experiment.metrics = metrics diff --git a/extension/src/experiments/model/status/index.test.ts b/extension/src/experiments/model/status/index.test.ts index 6368c18590..37fcb42442 100644 --- a/extension/src/experiments/model/status/index.test.ts +++ b/extension/src/experiments/model/status/index.test.ts @@ -26,17 +26,17 @@ describe('canSelect', () => { describe('limitToMaxSelected', () => { const mockedExperiments = [ { id: '1', label: 'A' }, - { id: '2', label: 'B', timestamp: null }, - { id: '3', label: 'C', timestamp: '2022-02-20T09:10:52' }, - { id: '4', label: 'D', timestamp: '2022-02-20T09:10:53' }, - { id: '5', label: 'E', timestamp: '2022-02-20T09:10:54' }, - { id: '6', label: 'F', timestamp: '2022-02-20T09:10:55' }, - { id: '7', label: 'G', timestamp: '2022-02-20T09:10:56' }, - { id: '8', label: 'H', timestamp: '2022-02-20T09:10:57' }, - { id: '9', label: 'I', timestamp: '2022-02-20T09:10:58' } + { Timestamp: null, id: '2', label: 'B' }, + { Timestamp: '2022-02-20T09:10:52', id: '3', label: 'C' }, + { Timestamp: '2022-02-20T09:10:53', id: '4', label: 'D' }, + { Timestamp: '2022-02-20T09:10:54', id: '5', label: 'E' }, + { Timestamp: '2022-02-20T09:10:55', id: '6', label: 'F' }, + { Timestamp: '2022-02-20T09:10:56', id: '7', label: 'G' }, + { Timestamp: '2022-02-20T09:10:57', id: '8', label: 'H' }, + { Timestamp: '2022-02-20T09:10:58', id: '9', label: 'I' } ] as Experiment[] - it('should return the first 7 selected by timestamp', () => { + it('should return the first 7 selected by Timestamp', () => { expect( limitToMaxSelected(mockedExperiments) .map(({ label }) => label) diff --git a/extension/src/experiments/model/status/index.ts b/extension/src/experiments/model/status/index.ts index 4fac057f7c..a416418ecc 100644 --- a/extension/src/experiments/model/status/index.ts +++ b/extension/src/experiments/model/status/index.ts @@ -20,7 +20,7 @@ const getEpoch = (timestamp: string | null | undefined) => new Date(timestamp || 0).getTime() const compareTimestamps = (a: Experiment, b: Experiment) => - getEpoch(b.timestamp) - getEpoch(a.timestamp) + getEpoch(b.Timestamp) - getEpoch(a.Timestamp) export const limitToMaxSelected = (experiments: Experiment[]) => experiments diff --git a/extension/src/experiments/webview/contract.ts b/extension/src/experiments/webview/contract.ts index 396dddd76c..f47089e011 100644 --- a/extension/src/experiments/webview/contract.ts +++ b/extension/src/experiments/webview/contract.ts @@ -30,6 +30,7 @@ export interface Experiment extends BaseExperimentFields { selected?: boolean sha?: string starred?: boolean + Timestamp?: string } export interface Row extends Experiment { diff --git a/extension/src/experiments/webview/messages.ts b/extension/src/experiments/webview/messages.ts index ffab126dad..ad5ef7c7d0 100644 --- a/extension/src/experiments/webview/messages.ts +++ b/extension/src/experiments/webview/messages.ts @@ -138,7 +138,7 @@ export class WebviewMessages { ), filters: this.experiments.getFilterPaths(), hasCheckpoints: this.checkpoints.hasCheckpoints(), - hasColumns: this.columns.hasColumns(), + hasColumns: this.columns.hasNonDefaultColumns(), hasRunningExperiment: this.experiments.hasRunningExperiment(), rows: this.experiments.getRowData(), sorts: this.experiments.getSorts() diff --git a/extension/src/path/selection/model.ts b/extension/src/path/selection/model.ts index e6ad3e813b..38e8a17189 100644 --- a/extension/src/path/selection/model.ts +++ b/extension/src/path/selection/model.ts @@ -1,9 +1,8 @@ import { Memento } from 'vscode' import { PersistenceKey } from '../../persistence/constants' import { ModelWithPersistence } from '../../persistence/model' -import { Column, ColumnType } from '../../experiments/webview/contract' +import { Column } from '../../experiments/webview/contract' import { PlotPath } from '../../plots/paths/collect' -import { timestampColumn } from '../../experiments/columns/collect/timestamp' export enum Status { SELECTED = 2, @@ -77,15 +76,13 @@ export abstract class PathSelectionModel< public setSelected(elements: (T & { selected: boolean })[]) { const terminalNodes = this.getTerminalNodes() - terminalNodes.map(({ path, selected, type }) => { + terminalNodes.map(({ path, selected }) => { const selectedElement = elements.find( ({ path: selectedPath }) => path === selectedPath ) if (!!selectedElement !== !!selected) { - const statusPath = - type === ColumnType.TIMESTAMP ? timestampColumn.parentPath : path - this.toggleStatus(statusPath) + this.toggleStatus(path) } }) } diff --git a/extension/src/path/selection/quickPick.ts b/extension/src/path/selection/quickPick.ts index 080dfb2410..3aa0b1ab3c 100644 --- a/extension/src/path/selection/quickPick.ts +++ b/extension/src/path/selection/quickPick.ts @@ -5,7 +5,7 @@ import { quickPickManyValues } from '../../vscode/quickPick' import { Title } from '../../vscode/title' -import { Column, ColumnType } from '../../experiments/webview/contract' +import { Column } from '../../experiments/webview/contract' import { PlotPath } from '../../plots/paths/collect' type PathType = PlotPath | Column @@ -15,7 +15,7 @@ type PathWithSelected = T & { } const getItem = (element: PathWithSelected) => ({ - label: element.type === ColumnType.TIMESTAMP ? element.label : element.path, + label: element.path, picked: element.selected, value: element }) diff --git a/extension/src/test/fixtures/expShow/dataTypes.ts b/extension/src/test/fixtures/expShow/dataTypes.ts index 9f89578d44..f19b68d4d2 100644 --- a/extension/src/test/fixtures/expShow/dataTypes.ts +++ b/extension/src/test/fixtures/expShow/dataTypes.ts @@ -175,7 +175,7 @@ export const rows: Row[] = [ selected: true, sha: '53c3851f46955fa3e2b8f6e1c52999acc8c9ea77', starred: false, - timestamp: '2020-11-21T19:58:22' + Timestamp: '2020-11-21T19:58:22' } ] diff --git a/extension/src/test/fixtures/expShow/deeplyNested.ts b/extension/src/test/fixtures/expShow/deeplyNested.ts index e9f13384f7..83cfdecd2f 100644 --- a/extension/src/test/fixtures/expShow/deeplyNested.ts +++ b/extension/src/test/fixtures/expShow/deeplyNested.ts @@ -249,7 +249,7 @@ export const rows = [ { id: 'main', label: 'main', - timestamp: '2020-11-21T19:58:22', + Timestamp: '2020-11-21T19:58:22', queued: false, running: false, executor: null, diff --git a/extension/src/test/fixtures/expShow/rows.ts b/extension/src/test/fixtures/expShow/rows.ts index 5297cace54..73836755b0 100644 --- a/extension/src/test/fixtures/expShow/rows.ts +++ b/extension/src/test/fixtures/expShow/rows.ts @@ -368,7 +368,7 @@ const data: Row[] = [ selected: false, sha: 'd1343a87c6ee4a2e82d19525964d2fb2cb6756c9', starred: false, - timestamp: '2020-12-29T15:31:51' + Timestamp: '2020-12-29T15:31:51' }, { checkpoint_tip: '4fb124aebddb2adf1545030907687fa9a4c80e70', @@ -461,10 +461,10 @@ const data: Row[] = [ selected: false, sha: '1ee5f2ecb0fa4d83cbf614386536344cf894dd53', starred: false, - timestamp: '2020-12-29T15:31:44' + Timestamp: '2020-12-29T15:31:44' } ], - timestamp: '2020-12-29T15:31:52' + Timestamp: '2020-12-29T15:31:52' }, { checkpoint_parent: '217312476f8854dda1865450b737eb6bc7a3ba1b', @@ -649,7 +649,7 @@ const data: Row[] = [ selected: false, starred: false, sha: '217312476f8854dda1865450b737eb6bc7a3ba1b', - timestamp: '2020-12-29T15:28:57' + Timestamp: '2020-12-29T15:28:57' }, { checkpoint_tip: '42b8736b08170529903cd203a1f40382a4b4a8cd', @@ -742,10 +742,10 @@ const data: Row[] = [ selected: false, sha: '9523bde67538cf31230efaff2dbc47d38a944ab5', starred: false, - timestamp: '2020-12-29T15:28:50' + Timestamp: '2020-12-29T15:28:50' } ], - timestamp: '2020-12-29T15:28:59' + Timestamp: '2020-12-29T15:28:59' }, { checkpoint_parent: '22e40e1fa3c916ac567f69b85969e3066a91dda4', @@ -930,7 +930,7 @@ const data: Row[] = [ selected: false, sha: '22e40e1fa3c916ac567f69b85969e3066a91dda4', starred: false, - timestamp: '2020-12-29T15:27:01' + Timestamp: '2020-12-29T15:27:01' }, { checkpoint_tip: '1ba7bcd6ce6154e72e18b155475663ecbbd1f49d', @@ -1023,7 +1023,7 @@ const data: Row[] = [ selected: false, sha: '91116c1eae4b79cb1f5ab0312dfd9b3e43608e15', starred: false, - timestamp: '2020-12-29T15:26:55' + Timestamp: '2020-12-29T15:26:55' }, { checkpoint_parent: 'c658f8b14ac819ac2a5ea0449da6c15dbe8eb880', @@ -1116,7 +1116,7 @@ const data: Row[] = [ selected: false, sha: 'e821416bfafb4bc28b3e0a8ddb322505b0ad2361', starred: false, - timestamp: '2020-12-29T15:26:49' + Timestamp: '2020-12-29T15:26:49' }, { checkpoint_parent: '23250b33e3d6dd0e136262d1d26a2face031cb03', @@ -1209,7 +1209,7 @@ const data: Row[] = [ selected: false, sha: 'c658f8b14ac819ac2a5ea0449da6c15dbe8eb880', starred: false, - timestamp: '2020-12-29T15:26:43' + Timestamp: '2020-12-29T15:26:43' }, { checkpoint_parent: '53c3851f46955fa3e2b8f6e1c52999acc8c9ea77', @@ -1302,10 +1302,10 @@ const data: Row[] = [ selected: false, sha: '23250b33e3d6dd0e136262d1d26a2face031cb03', starred: false, - timestamp: '2020-12-29T15:26:36' + Timestamp: '2020-12-29T15:26:36' } ], - timestamp: '2020-12-29T15:27:02' + Timestamp: '2020-12-29T15:27:02' }, { displayColor: colorsList[5], @@ -1400,7 +1400,7 @@ const data: Row[] = [ selected: true, sha: 'f0f918662b4f8c47819ca154a23029bf9b47d4f3', starred: false, - timestamp: '2020-12-29T15:26:36' + Timestamp: '2020-12-29T15:26:36' }, { deps: { @@ -1476,10 +1476,10 @@ const data: Row[] = [ queued: true, sha: '90aea7f2482117a55dfcadcdb901aaa6610fbbc9', starred: false, - timestamp: '2020-12-29T15:25:27' + Timestamp: '2020-12-29T15:25:27' } ], - timestamp: '2020-11-21T19:58:22' + Timestamp: '2020-11-21T19:58:22' } ] diff --git a/webview/src/experiments/components/Experiments.tsx b/webview/src/experiments/components/Experiments.tsx index 1ecafc5271..061b5f17eb 100644 --- a/webview/src/experiments/components/Experiments.tsx +++ b/webview/src/experiments/components/Experiments.tsx @@ -111,9 +111,10 @@ const getColumns = (columns: Column[]): TableColumn[] => { ) }, Header: TimestampHeader, - accessor: 'timestamp', + accessor: 'Timestamp', group: ColumnType.TIMESTAMP, id: 'timestamp', + name: 'Timestamp', width: 100 }) } diff --git a/webview/src/experiments/components/table/TableHeader.tsx b/webview/src/experiments/components/table/TableHeader.tsx index ed66364ae7..fe7c949da9 100644 --- a/webview/src/experiments/components/table/TableHeader.tsx +++ b/webview/src/experiments/components/table/TableHeader.tsx @@ -228,8 +228,7 @@ const TableHeaderCell: React.FC<{ setExpColumnNeedsShadow }) => { const [menuSuppressed, setMenuSuppressed] = React.useState(false) - const isDraggable = - !column.placeholderOf && !['id', 'timestamp'].includes(column.id) + const isDraggable = !column.placeholderOf && !['id'].includes(column.id) const isPlaceholder = !!column.placeholderOf const canResize = column.canResize && !isPlaceholder From 2f6911453f39a6dc7e950f58f37080f3de35bcfa Mon Sep 17 00:00:00 2001 From: julieg18 Date: Wed, 24 Aug 2022 09:56:45 -0500 Subject: [PATCH 03/10] Add missing line in prettierignore --- extension/.prettierignore | 1 + 1 file changed, 1 insertion(+) diff --git a/extension/.prettierignore b/extension/.prettierignore index b575855f1a..69f7aa4bb3 100644 --- a/extension/.prettierignore +++ b/extension/.prettierignore @@ -3,3 +3,4 @@ dist .wdio-vscode-service coverage src/test/fixtures/plotsDiff/vega.ts +CHANGELOG.md From 03c2ceaf137f5d3a0c607f1069956afbaff336ab Mon Sep 17 00:00:00 2001 From: julieg18 Date: Wed, 24 Aug 2022 13:41:14 -0500 Subject: [PATCH 04/10] Fix timestamp column dropdown bug --- webview/src/experiments/components/table/TableHeader.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webview/src/experiments/components/table/TableHeader.tsx b/webview/src/experiments/components/table/TableHeader.tsx index d8b3154870..228e957d2d 100644 --- a/webview/src/experiments/components/table/TableHeader.tsx +++ b/webview/src/experiments/components/table/TableHeader.tsx @@ -71,7 +71,7 @@ export const TableHeader: React.FC = ({ id: 'hide-column', label: 'Hide Column', message: { - payload: column.id, + payload: isTimestamp && column.name ? column.name : column.id, type: MessageFromWebviewType.HIDE_EXPERIMENTS_TABLE_COLUMN } }, From caba7c76b1d9748fcdebb3d4df4c4b0ed9116c2b Mon Sep 17 00:00:00 2001 From: julieg18 Date: Wed, 24 Aug 2022 14:02:52 -0500 Subject: [PATCH 05/10] Clean up --- extension/.prettierignore | 2 +- extension/src/path/selection/model.ts | 4 ++-- extension/src/path/selection/quickPick.ts | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/extension/.prettierignore b/extension/.prettierignore index 69f7aa4bb3..374de1622a 100644 --- a/extension/.prettierignore +++ b/extension/.prettierignore @@ -3,4 +3,4 @@ dist .wdio-vscode-service coverage src/test/fixtures/plotsDiff/vega.ts -CHANGELOG.md +CHANGELOG.md \ No newline at end of file diff --git a/extension/src/path/selection/model.ts b/extension/src/path/selection/model.ts index 38e8a17189..ff486cbd04 100644 --- a/extension/src/path/selection/model.ts +++ b/extension/src/path/selection/model.ts @@ -76,7 +76,7 @@ export abstract class PathSelectionModel< public setSelected(elements: (T & { selected: boolean })[]) { const terminalNodes = this.getTerminalNodes() - terminalNodes.map(({ path, selected }) => { + for (const { path, selected } of terminalNodes) { const selectedElement = elements.find( ({ path: selectedPath }) => path === selectedPath ) @@ -84,7 +84,7 @@ export abstract class PathSelectionModel< if (!!selectedElement !== !!selected) { this.toggleStatus(path) } - }) + } } protected setNewStatuses(data: { path: string }[]) { diff --git a/extension/src/path/selection/quickPick.ts b/extension/src/path/selection/quickPick.ts index 3aa0b1ab3c..950612beac 100644 --- a/extension/src/path/selection/quickPick.ts +++ b/extension/src/path/selection/quickPick.ts @@ -41,6 +41,7 @@ export const pickPaths = ( if (!definedAndNonEmpty(paths)) { return Toast.showError(`There are no ${type} to select.`) } + const items = collectItems(paths) return quickPickManyValues>(items, { From 2294818d5b7277ac2f9faa5e621bf7f6b454bea0 Mon Sep 17 00:00:00 2001 From: julieg18 Date: Thu, 25 Aug 2022 08:09:19 -0500 Subject: [PATCH 06/10] Update timestamp column.id to "Timestamp" --- webview/src/experiments/components/Experiments.tsx | 2 +- webview/src/experiments/components/table/TableHeader.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/webview/src/experiments/components/Experiments.tsx b/webview/src/experiments/components/Experiments.tsx index 061b5f17eb..88cf765f83 100644 --- a/webview/src/experiments/components/Experiments.tsx +++ b/webview/src/experiments/components/Experiments.tsx @@ -113,7 +113,7 @@ const getColumns = (columns: Column[]): TableColumn[] => { Header: TimestampHeader, accessor: 'Timestamp', group: ColumnType.TIMESTAMP, - id: 'timestamp', + id: 'Timestamp', name: 'Timestamp', width: 100 }) diff --git a/webview/src/experiments/components/table/TableHeader.tsx b/webview/src/experiments/components/table/TableHeader.tsx index 228e957d2d..d8b3154870 100644 --- a/webview/src/experiments/components/table/TableHeader.tsx +++ b/webview/src/experiments/components/table/TableHeader.tsx @@ -71,7 +71,7 @@ export const TableHeader: React.FC = ({ id: 'hide-column', label: 'Hide Column', message: { - payload: isTimestamp && column.name ? column.name : column.id, + payload: column.id, type: MessageFromWebviewType.HIDE_EXPERIMENTS_TABLE_COLUMN } }, From b10574aa798ff8a7b4cb5f45184a535aa4fc3c92 Mon Sep 17 00:00:00 2001 From: julieg18 Date: Thu, 25 Aug 2022 16:40:11 -0500 Subject: [PATCH 07/10] Update defaultColumn variable --- webview/src/test/sort.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webview/src/test/sort.ts b/webview/src/test/sort.ts index ab76a5ed61..a68e56e5ac 100644 --- a/webview/src/test/sort.ts +++ b/webview/src/test/sort.ts @@ -1,7 +1,7 @@ import { screen } from '@testing-library/react' import { ColumnType, TableData } from 'dvc/src/experiments/webview/contract' -export const defaultColumns = ['Experiment'] +export const defaultColumn = 'Experiment' export const commonColumnFields = { hasChildren: false, @@ -60,7 +60,7 @@ export const getHeaders = async () => { export const expectHeaders = async (expectedHeaderNames: string[]) => { expect(await getHeaders()).toStrictEqual([ - ...defaultColumns, + defaultColumn, ...expectedHeaderNames ]) } From aa98a23312b5b8d396b3b7bfb4b6f5f4d2d1e951 Mon Sep 17 00:00:00 2001 From: julieg18 Date: Thu, 25 Aug 2022 16:43:12 -0500 Subject: [PATCH 08/10] Clean up isDraggable --- webview/src/experiments/components/table/TableHeaderCell.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webview/src/experiments/components/table/TableHeaderCell.tsx b/webview/src/experiments/components/table/TableHeaderCell.tsx index 537c95fc69..d793c98a06 100644 --- a/webview/src/experiments/components/table/TableHeaderCell.tsx +++ b/webview/src/experiments/components/table/TableHeaderCell.tsx @@ -104,7 +104,7 @@ export const TableHeaderCell: React.FC<{ setExpColumnNeedsShadow }) => { const [menuSuppressed, setMenuSuppressed] = React.useState(false) - const isDraggable = !column.placeholderOf && !['id'].includes(column.id) + const isDraggable = !column.placeholderOf && column.id !== 'id' const isPlaceholder = !!column.placeholderOf const canResize = column.canResize && !isPlaceholder From 0b1470e3227eccb3f0b36559811ae4fa4474b83a Mon Sep 17 00:00:00 2001 From: julieg18 Date: Thu, 25 Aug 2022 17:01:46 -0500 Subject: [PATCH 09/10] Update timestamp column logic * add column once when acc is created * move column to constants file --- .../src/experiments/columns/collect/index.test.ts | 4 ++-- extension/src/experiments/columns/collect/index.ts | 5 +++-- .../src/experiments/columns/collect/timestamp.ts | 14 -------------- extension/src/experiments/columns/constants.ts | 9 +++++++++ extension/src/experiments/columns/model.test.ts | 2 +- extension/src/experiments/columns/quickPick.ts | 2 +- extension/src/experiments/columns/tree.test.ts | 2 +- extension/src/test/fixtures/expShow/columns.ts | 2 +- extension/src/test/fixtures/expShow/dataTypes.ts | 2 +- .../src/test/fixtures/expShow/deeplyNested.ts | 2 +- 10 files changed, 20 insertions(+), 24 deletions(-) delete mode 100644 extension/src/experiments/columns/collect/timestamp.ts create mode 100644 extension/src/experiments/columns/constants.ts diff --git a/extension/src/experiments/columns/collect/index.test.ts b/extension/src/experiments/columns/collect/index.test.ts index 1382173edd..74831996c7 100644 --- a/extension/src/experiments/columns/collect/index.test.ts +++ b/extension/src/experiments/columns/collect/index.test.ts @@ -1,6 +1,6 @@ import { join } from 'path' import { collectChanges, collectColumns } from '.' -import { timestampColumn } from './timestamp' +import { timestampColumn } from '../constants' import { buildDepPath, buildMetricOrParamPath } from '../paths' import { Column, ColumnType } from '../../webview/contract' import outputFixture from '../../../test/fixtures/expShow/output' @@ -68,7 +68,7 @@ describe('collectColumns', () => { baseline: {} } }) - expect(columns).toStrictEqual([]) + expect(columns).toStrictEqual([timestampColumn]) }) const exampleBigNumber = 3000000000 diff --git a/extension/src/experiments/columns/collect/index.ts b/extension/src/experiments/columns/collect/index.ts index 70c4946957..fa743c2606 100644 --- a/extension/src/experiments/columns/collect/index.ts +++ b/extension/src/experiments/columns/collect/index.ts @@ -1,7 +1,6 @@ import { join } from 'path' import { ColumnAccumulator } from './util' import { collectDepChanges, collectDeps } from './deps' -import { collectTimestamp } from './timestamp' import { collectMetricAndParamChanges, collectMetricsAndParams @@ -13,6 +12,7 @@ import { ExperimentsOutput } from '../../../cli/dvc/reader' import { standardizePath } from '../../../fileSystem/path' +import { timestampColumn } from '../constants' const collectFromExperiment = ( acc: ColumnAccumulator, @@ -20,7 +20,6 @@ const collectFromExperiment = ( ) => { const { data } = experiment if (data) { - collectTimestamp(acc) collectMetricsAndParams(acc, data) collectDeps(acc, data) } @@ -40,6 +39,8 @@ const collectFromBranch = ( export const collectColumns = (data: ExperimentsOutput): Column[] => { const acc: ColumnAccumulator = {} + acc.timestamp = timestampColumn + const { workspace, ...rest } = data collectFromBranch(acc, workspace) for (const branch of Object.values(rest)) { diff --git a/extension/src/experiments/columns/collect/timestamp.ts b/extension/src/experiments/columns/collect/timestamp.ts deleted file mode 100644 index c0cc0bbcc8..0000000000 --- a/extension/src/experiments/columns/collect/timestamp.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { ColumnAccumulator } from './util' -import { ColumnType } from '../../webview/contract' - -export const timestampColumn = { - hasChildren: false, - label: 'Timestamp', - parentPath: ColumnType.TIMESTAMP, - path: 'Timestamp', - type: ColumnType.TIMESTAMP -} - -export const collectTimestamp = (acc: ColumnAccumulator) => { - acc.timestamp = timestampColumn -} diff --git a/extension/src/experiments/columns/constants.ts b/extension/src/experiments/columns/constants.ts new file mode 100644 index 0000000000..7a4eeaf2fb --- /dev/null +++ b/extension/src/experiments/columns/constants.ts @@ -0,0 +1,9 @@ +import { ColumnType } from '../webview/contract' + +export const timestampColumn = { + hasChildren: false, + label: 'Timestamp', + parentPath: ColumnType.TIMESTAMP, + path: 'Timestamp', + type: ColumnType.TIMESTAMP +} diff --git a/extension/src/experiments/columns/model.test.ts b/extension/src/experiments/columns/model.test.ts index 0348f29641..c66bc6ae7c 100644 --- a/extension/src/experiments/columns/model.test.ts +++ b/extension/src/experiments/columns/model.test.ts @@ -1,6 +1,6 @@ import { ColumnsModel } from './model' import { appendColumnToPath, buildMetricOrParamPath } from './paths' -import { timestampColumn } from './collect/timestamp' +import { timestampColumn } from './constants' import { buildMockMemento } from '../../test/util' import { Status } from '../../path/selection/model' import { PersistenceKey } from '../../persistence/constants' diff --git a/extension/src/experiments/columns/quickPick.ts b/extension/src/experiments/columns/quickPick.ts index 506888b6fd..06aea7af93 100644 --- a/extension/src/experiments/columns/quickPick.ts +++ b/extension/src/experiments/columns/quickPick.ts @@ -1,5 +1,5 @@ import { ColumnLike } from './like' -import { timestampColumn } from './collect/timestamp' +import { timestampColumn } from './constants' import { definedAndNonEmpty } from '../../util/array' import { QuickPickOptionsWithTitle, diff --git a/extension/src/experiments/columns/tree.test.ts b/extension/src/experiments/columns/tree.test.ts index ed9c16a0e1..2b1adb4cef 100644 --- a/extension/src/experiments/columns/tree.test.ts +++ b/extension/src/experiments/columns/tree.test.ts @@ -8,7 +8,7 @@ import { buildMetricOrParamPath, splitColumnPath } from './paths' -import { timestampColumn } from './collect/timestamp' +import { timestampColumn } from './constants' import columnsFixture from '../../test/fixtures/expShow/columns' import { Resource, ResourceLocator } from '../../resourceLocator' import { RegisteredCommands } from '../../commands/external' diff --git a/extension/src/test/fixtures/expShow/columns.ts b/extension/src/test/fixtures/expShow/columns.ts index 963be128fb..205edf9838 100644 --- a/extension/src/test/fixtures/expShow/columns.ts +++ b/extension/src/test/fixtures/expShow/columns.ts @@ -4,7 +4,7 @@ import { buildDepPath, buildMetricOrParamPath } from '../../../experiments/columns/paths' -import { timestampColumn } from '../../../experiments/columns/collect/timestamp' +import { timestampColumn } from '../../../experiments/columns/constants' const nestedParamsFile = join('nested', 'params.yaml') diff --git a/extension/src/test/fixtures/expShow/dataTypes.ts b/extension/src/test/fixtures/expShow/dataTypes.ts index f19b68d4d2..484c82a202 100644 --- a/extension/src/test/fixtures/expShow/dataTypes.ts +++ b/extension/src/test/fixtures/expShow/dataTypes.ts @@ -1,5 +1,5 @@ import { ExperimentsOutput } from '../../../cli/dvc/reader' -import { timestampColumn } from '../../../experiments/columns/collect/timestamp' +import { timestampColumn } from '../../../experiments/columns/constants' import { Column, ColumnType, diff --git a/extension/src/test/fixtures/expShow/deeplyNested.ts b/extension/src/test/fixtures/expShow/deeplyNested.ts index 83cfdecd2f..3b46ead5c4 100644 --- a/extension/src/test/fixtures/expShow/deeplyNested.ts +++ b/extension/src/test/fixtures/expShow/deeplyNested.ts @@ -1,5 +1,5 @@ import { ExperimentsOutput } from '../../../cli/dvc/reader' -import { timestampColumn } from '../../../experiments/columns/collect/timestamp' +import { timestampColumn } from '../../../experiments/columns/constants' import { Column, ColumnType, From 4c8c4338234553fac02f5d7ee3a5fcef996b39dc Mon Sep 17 00:00:00 2001 From: julieg18 Date: Thu, 25 Aug 2022 18:27:56 -0500 Subject: [PATCH 10/10] Update turbo.json with timestamp constants file --- turbo.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/turbo.json b/turbo.json index 16ffa69573..2540275a29 100644 --- a/turbo.json +++ b/turbo.json @@ -50,5 +50,8 @@ "cache": false } }, - "globalDependencies": ["extension/src/test/fixtures/**"] + "globalDependencies": [ + "extension/src/test/fixtures/**", + "extension/src/experiments/columns/constants.ts" + ] }