Skip to content

Commit

Permalink
Filter custom plot creation options (#3526)
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 authored Mar 22, 2023
1 parent 5c5cb42 commit 79b019e
Show file tree
Hide file tree
Showing 5 changed files with 425 additions and 205 deletions.
58 changes: 1 addition & 57 deletions extension/src/plots/model/custom.test.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,7 @@
import {
CHECKPOINTS_PARAM,
cleanupOldOrderValue,
doesCustomPlotAlreadyExist
} from './custom'
import { cleanupOldOrderValue } from './custom'
import { CustomPlotType } from '../webview/contract'
import { FILE_SEPARATOR } from '../../experiments/columns/paths'

describe('doesCustomPlotAlreadyExist', () => {
it('should return true if plot exists', () => {
const output = doesCustomPlotAlreadyExist(
[
{
metric: 'summary.json:loss',
param: 'params.yaml:dropout',
type: CustomPlotType.METRIC_VS_PARAM
},
{
metric: 'summary.json:accuracy',
param: 'params.yaml:epochs',
type: CustomPlotType.METRIC_VS_PARAM
},
{
metric: 'summary.json:loss',
param: CHECKPOINTS_PARAM,
type: CustomPlotType.CHECKPOINT
}
],
'summary.json:accuracy',
'params.yaml:epochs'
)
expect(output).toStrictEqual(true)
})

it('should return false if plot does not exists', () => {
const output = doesCustomPlotAlreadyExist(
[
{
metric: 'summary.json:loss',
param: 'params.yaml:dropout',
type: CustomPlotType.METRIC_VS_PARAM
},
{
metric: 'summary.json:accuracy',
param: 'params.yaml:epochs',
type: CustomPlotType.METRIC_VS_PARAM
},
{
metric: 'summary.json:loss',
param: CHECKPOINTS_PARAM,
type: CustomPlotType.CHECKPOINT
}
],
'summary.json:loss',
'params.yaml:epochs'
)
expect(output).toStrictEqual(false)
})
})

describe('cleanupOlderValue', () => {
it('should update value if contents are outdated', () => {
const output = cleanupOldOrderValue(
Expand Down
9 changes: 0 additions & 9 deletions extension/src/plots/model/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ export const isCheckpointValue = (
export const isCheckpointPlot = (plot: CustomPlot): plot is CheckpointPlot =>
plot.type === CustomPlotType.CHECKPOINT

export const doesCustomPlotAlreadyExist = (
order: CustomPlotsOrderValue[],
metric: string,
param = CHECKPOINTS_PARAM
) =>
order.some(value => {
return value.param === param && value.metric === metric
})

export const removeColumnTypeFromPath = (
columnPath: string,
type: string,
Expand Down
Loading

0 comments on commit 79b019e

Please sign in to comment.