Skip to content

Commit

Permalink
Set default number of displayed commits to 1 for non-current branches…
Browse files Browse the repository at this point in the history
… in the experiments table (#4305)
  • Loading branch information
mattseddon authored Jul 19, 2023
1 parent 8823368 commit 5526a13
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion extension/src/cli/dvc/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const DVCLIVE_ONLY_RUNNING_SIGNAL_FILE = join(
)
export const EXP_RWLOCK_FILE = join(TEMP_EXP_DIR, 'rwlock.lock')

export const DEFAULT_NUM_OF_COMMITS_TO_SHOW = 3
export const DEFAULT_CURRENT_BRANCH_COMMITS_TO_SHOW = 3
export const DEFAULT_OTHER_BRANCH_COMMITS_TO_SHOW = 1
export const NUM_OF_COMMITS_TO_INCREASE = 2

export enum Command {
Expand Down
12 changes: 10 additions & 2 deletions extension/src/experiments/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ import { flattenMapValues } from '../../util/map'
import { ModelWithPersistence } from '../../persistence/model'
import { PersistenceKey } from '../../persistence/constants'
import { sum } from '../../util/math'
import { DEFAULT_NUM_OF_COMMITS_TO_SHOW } from '../../cli/dvc/constants'
import {
DEFAULT_CURRENT_BRANCH_COMMITS_TO_SHOW,
DEFAULT_OTHER_BRANCH_COMMITS_TO_SHOW
} from '../../cli/dvc/constants'

type StarredExperiments = Record<string, boolean | undefined>

Expand Down Expand Up @@ -456,7 +459,12 @@ export class ExperimentsModel extends ModelWithPersistence {
}

public getNbOfCommitsToShow(branch: string) {
return this.numberOfCommitsToShow[branch] || DEFAULT_NUM_OF_COMMITS_TO_SHOW
return (
this.numberOfCommitsToShow[branch] ||
(branch === this.currentBranch
? DEFAULT_CURRENT_BRANCH_COMMITS_TO_SHOW
: DEFAULT_OTHER_BRANCH_COMMITS_TO_SHOW)
)
}

public getAllNbOfCommitsToShow() {
Expand Down
6 changes: 3 additions & 3 deletions extension/src/test/suite/experiments/data/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '../../../../commands/internal'
import { buildExperimentsData } from '../util'
import {
DEFAULT_NUM_OF_COMMITS_TO_SHOW,
DEFAULT_CURRENT_BRANCH_COMMITS_TO_SHOW,
ExperimentFlag
} from '../../../../cli/dvc/constants'
import { EXPERIMENTS_GIT_LOGS_REFS } from '../../../../experiments/data/constants'
Expand Down Expand Up @@ -103,7 +103,7 @@ suite('Experiments Data Test Suite', () => {
{
getBranchesToShow: () => ['main'],
getNbOfCommitsToShow: () => ({
main: DEFAULT_NUM_OF_COMMITS_TO_SHOW
main: DEFAULT_CURRENT_BRANCH_COMMITS_TO_SHOW
}),
setBranches: stub()
} as unknown as ExperimentsModel,
Expand Down Expand Up @@ -165,7 +165,7 @@ suite('Experiments Data Test Suite', () => {
{
getBranchesToShow: () => ['main'],
getNbOfCommitsToShow: () => ({
main: DEFAULT_NUM_OF_COMMITS_TO_SHOW
main: DEFAULT_CURRENT_BRANCH_COMMITS_TO_SHOW
}),
setBranches: stub()
} as unknown as ExperimentsModel,
Expand Down
4 changes: 2 additions & 2 deletions extension/src/test/suite/experiments/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ExperimentsData } from '../../../experiments/data'
import * as Watcher from '../../../fileSystem/watcher'
import { ExperimentsModel } from '../../../experiments/model'
import { ColumnsModel } from '../../../experiments/columns/model'
import { DEFAULT_NUM_OF_COMMITS_TO_SHOW } from '../../../cli/dvc/constants'
import { DEFAULT_CURRENT_BRANCH_COMMITS_TO_SHOW } from '../../../cli/dvc/constants'
import { PersistenceKey } from '../../../persistence/constants'
import { ExpShowOutput } from '../../../cli/dvc/contract'
import { buildExperimentsPipeline } from '../pipeline/util'
Expand Down Expand Up @@ -235,7 +235,7 @@ export const buildExperimentsData = (
internalCommands,
{
getBranchesToShow: mockGetBranchesToShow,
getNbOfCommitsToShow: () => DEFAULT_NUM_OF_COMMITS_TO_SHOW,
getNbOfCommitsToShow: () => DEFAULT_CURRENT_BRANCH_COMMITS_TO_SHOW,
setBranches: mockSetBranches
} as unknown as ExperimentsModel,
[]
Expand Down

0 comments on commit 5526a13

Please sign in to comment.