Skip to content

Commit 4ae0be9

Browse files
authored
Add config for updating max amount of table head depth (#2436)
1 parent afb400a commit 4ae0be9

File tree

9 files changed

+39
-7
lines changed

9 files changed

+39
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ These are the VS Code [settings] available for the Extension:
150150
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
151151
| `dvc.dvcPath` | Path or shell command to the DVC binary. Required unless Microsoft's [Python extension] is installed and the `dvc` package found in its environment. |
152152
| `dvc.pythonPath` | Path to the desired Python interpreter to use with DVC. Required when using a virtual environment. |
153+
| `dvc.expTableHeadMaxLayers` | Maximum depth of experiment table head rows (minimum is 3). |
153154
| `dvc.doNotShowWalkthroughAfterInstall` | Do not prompt to show the Get Started page after installing. Useful for pre-configured development environments |
154155
| `dvc.doNotRecommendRedHatExtension` | Do not prompt to install the Red Hat YAML extension, which helps with DVC YAML schema validation (`dvc.yaml` and `.dvc` files). |
155156
| `dvc.doNotShowCliUnavailable` | Do not warn when the workspace contains a DVC project but the DVC binary is unavailable. |

extension/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,12 @@
554554
"type": "string",
555555
"default": null
556556
},
557+
"dvc.expTableHeadMaxLayers": {
558+
"title": "%config.expTableHeadMaxLayers.title%",
559+
"description": "%config.expTableHeadMaxLayers.description%",
560+
"type": "number",
561+
"default": 5
562+
},
557563
"dvc.pythonPath": {
558564
"title": "%config.pythonPath.title%",
559565
"description": "%config.pythonPath.description%",

extension/package.nls.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@
8484
"config.doNotShowUnableToFilter.title": "Do not warn before disabling auto-apply filters to experiment selection.",
8585
"config.dvcPath.description": "Path or shell command to the DVC binary. Required unless Microsoft's Python extension is installed and the `dvc` package found in its environment.",
8686
"config.dvcPath.title": "DVC Path (or shell command)",
87+
"config.expTableHeadMaxLayers.title": "Maximum depth of Experiment table head rows",
88+
"config.expTableHeadMaxLayers.description": "Minimum is three.",
8789
"config.pythonPath.description": "Path to the desired Python interpreter to use with DVC. Required when using a virtual environment. Overrides any other extension's settings for this extension's purposes.",
8890
"config.pythonPath.title": "Python Interpreter"
8991
}

extension/src/experiments/columns/collect/index.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import workspaceChangesFixture from '../../../test/fixtures/expShow/workspaceCha
99
import uncommittedDepsFixture from '../../../test/fixtures/expShow/uncommittedDeps'
1010
import { ExperimentsOutput } from '../../../cli/dvc/reader'
1111

12+
jest.mock('../../../vscode/config')
13+
1214
describe('collectColumns', () => {
1315
it('should return a value equal to the columns fixture when given the output fixture', () => {
1416
const columns = collectColumns(outputFixture)

extension/src/experiments/columns/collect/util.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import { Column, ColumnType } from '../../webview/contract'
22
import { Value } from '../../../cli/dvc/reader'
3+
import { ConfigKey, getConfigValue } from '../../../vscode/config'
4+
import { INITIAL_TABLE_HEAD_MAX_LAYERS } from '../consts'
35

46
export type ColumnAccumulator = Record<string, Column>
57

6-
export const limitAncestorDepth = (
7-
ancestors: string[],
8-
sep: string,
9-
limit = 5
10-
) => {
8+
export const limitAncestorDepth = (ancestors: string[], sep: string) => {
119
const [path, ...rest] = ancestors
1210
/*
1311
The depth is only limited for the middle of the path array.
1412
The first and final layer are excluded, and the
1513
concatenated layer itself counts as one; because of this, we must subtract 3
1614
from what we want the final layer count to be.
1715
*/
18-
const convertedLimit = limit - 3
16+
const collectedLimit =
17+
Number(getConfigValue(ConfigKey.EXP_TABLE_HEAD_MAX_LAYERS)) ||
18+
INITIAL_TABLE_HEAD_MAX_LAYERS
19+
20+
const convertedLimit = (collectedLimit >= 3 ? collectedLimit : 3) - 3
1921
if (rest.length <= convertedLimit) {
2022
return ancestors
2123
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const INITIAL_TABLE_HEAD_MAX_LAYERS = 5

extension/src/experiments/columns/model.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import {
1616
columns as dataTypesColumns
1717
} from '../../test/fixtures/expShow/dataTypes'
1818

19+
jest.mock('../../vscode/config')
20+
1921
describe('ColumnsModel', () => {
2022
const exampleDvcRoot = 'test'
2123

extension/src/experiments/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { Event, EventEmitter, Memento } from 'vscode'
1+
import {
2+
ConfigurationChangeEvent,
3+
Event,
4+
EventEmitter,
5+
Memento,
6+
workspace
7+
} from 'vscode'
28
import omit from 'lodash.omit'
39
import { addStarredToColumns } from './columns/like'
410
import { setContextForEditorTitleIcons } from './context'
@@ -32,6 +38,7 @@ import { Title } from '../vscode/title'
3238
import { createTypedAccumulator } from '../util/object'
3339
import { pickPaths } from '../path/selection/quickPick'
3440
import { Toast } from '../vscode/toast'
41+
import { ConfigKey } from '../vscode/config'
3542

3643
export const ExperimentsScale = {
3744
...omit(ColumnType, 'TIMESTAMP'),
@@ -123,6 +130,14 @@ export class Experiments extends BaseRepository<TableData> {
123130
})
124131
)
125132

133+
this.dispose.track(
134+
workspace.onDidChangeConfiguration((event: ConfigurationChangeEvent) => {
135+
if (event.affectsConfiguration(ConfigKey.EXP_TABLE_HEAD_MAX_LAYERS)) {
136+
this.cliData.update()
137+
}
138+
})
139+
)
140+
126141
this.webviewMessages = this.createWebviewMessageHandler()
127142
this.setupInitialData()
128143
this.watchActiveEditor()

extension/src/vscode/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export enum ConfigKey {
55
DO_NOT_SHOW_CLI_UNAVAILABLE = 'dvc.doNotShowCliUnavailable',
66
DO_NOT_SHOW_WALKTHROUGH_AFTER_INSTALL = 'dvc.doNotShowWalkthroughAfterInstall',
77
DO_NOT_SHOW_UNABLE_TO_FILTER = 'dvc.doNotShowUnableToFilter',
8+
EXP_TABLE_HEAD_MAX_LAYERS = 'dvc.expTableHeadMaxLayers',
89
DVC_PATH = 'dvc.dvcPath',
910
PYTHON_PATH = 'dvc.pythonPath'
1011
}

0 commit comments

Comments
 (0)