-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add plots show command (with stub) #995
Changes from all commits
64656b3
6395c07
fc87aa2
743569e
9c7b922
f3392c0
1e0e801
0fa2ba5
a41d526
20a17eb
625ff96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { createProcess } from '../processExecution' | |
import { getFailingMockedProcess, getMockedProcess } from '../test/util/jest' | ||
import { getProcessEnv } from '../env' | ||
import expShowFixture from '../test/fixtures/expShow/output' | ||
import plotsShowFixture from '../test/fixtures/plotsShow/output' | ||
import { Config } from '../config' | ||
|
||
jest.mock('vscode') | ||
|
@@ -303,6 +304,26 @@ describe('CliReader', () => { | |
}) | ||
}) | ||
|
||
describe('plotsShow', () => { | ||
it('should match the expected output', async () => { | ||
const cwd = __dirname | ||
|
||
mockedCreateProcess.mockReturnValueOnce( | ||
getMockedProcess(JSON.stringify(plotsShowFixture)) | ||
) | ||
|
||
const plots = await cliReader.plotsShow(cwd) | ||
expect(plots).toEqual(plotsShowFixture) | ||
expect(mockedCreateProcess).not.toBeCalled() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [F] This second expect will fail when we remove the stub, we can then replace it with whats below |
||
// expect(mockedCreateProcess).toBeCalledWith({ | ||
// args: ['plots', 'show', SHOW_JSON], | ||
// cwd, | ||
// env: mockedEnv, | ||
// executable: 'dvc' | ||
// }) | ||
}) | ||
}) | ||
|
||
describe('root', () => { | ||
it('should return the root relative to the cwd', async () => { | ||
const stdout = join('..', '..') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import isEqual from 'lodash.isequal' | ||
import { VisualizationSpec } from 'react-vega' | ||
import { Cli, typeCheckCommands } from '.' | ||
import { | ||
Args, | ||
Command, | ||
ExperimentFlag, | ||
ExperimentSubCommand, | ||
Flag, | ||
ListFlag | ||
ListFlag, | ||
SubCommand | ||
} from './args' | ||
import { retry } from './retry' | ||
import { trimAndSplit } from '../util/stdout' | ||
import plotsShowFixture from '../test/fixtures/plotsShow/output' | ||
|
||
export type PathOutput = { path: string } | ||
|
||
|
@@ -96,12 +100,15 @@ export interface ExperimentsRepoJSONOutput { | |
} | ||
} | ||
|
||
export type PlotsOutput = Record<string, VisualizationSpec> | ||
|
||
export const autoRegisteredCommands = { | ||
DIFF: 'diff', | ||
EXPERIMENT_LIST_CURRENT: 'experimentListCurrent', | ||
EXPERIMENT_SHOW: 'experimentShow', | ||
LIST_DVC_ONLY: 'listDvcOnly', | ||
LIST_DVC_ONLY_RECURSIVE: 'listDvcOnlyRecursive', | ||
PLOTS_SHOW: 'plotsShow', | ||
STATUS: 'status' | ||
} as const | ||
|
||
|
@@ -122,10 +129,9 @@ export class CliReader extends Cli { | |
} | ||
|
||
public experimentShow(cwd: string): Promise<ExperimentsRepoJSONOutput> { | ||
return this.readProcessJson<ExperimentsRepoJSONOutput>( | ||
return this.readShowProcessJson<ExperimentsRepoJSONOutput>( | ||
cwd, | ||
Command.EXPERIMENT, | ||
ExperimentSubCommand.SHOW | ||
Command.EXPERIMENT | ||
) | ||
} | ||
|
||
|
@@ -157,6 +163,10 @@ export class CliReader extends Cli { | |
) | ||
} | ||
|
||
public plotsShow(cwd: string): Promise<PlotsOutput> { | ||
mattseddon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return this.readShowProcessJson<PlotsOutput>(cwd, Command.PLOTS) | ||
} | ||
|
||
public async root(cwd: string): Promise<string | undefined> { | ||
try { | ||
return await this.executeProcess(cwd, Command.ROOT) | ||
|
@@ -172,6 +182,11 @@ export class CliReader extends Cli { | |
formatter: typeof trimAndSplit | typeof JSON.parse, | ||
...args: Args | ||
): Promise<T> { | ||
// Stubbed until DVC ready | ||
if (isEqual(args, ['plots', 'show', '--show-json'])) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [F] This is a guess at what the command will actually be |
||
return Promise.resolve(formatter(JSON.stringify(plotsShowFixture))) | ||
} | ||
|
||
const output = await retry( | ||
() => this.executeProcess(cwd, ...args), | ||
args.join(' ') | ||
|
@@ -191,4 +206,8 @@ export class CliReader extends Cli { | |
Flag.SHOW_JSON | ||
) | ||
} | ||
|
||
private readShowProcessJson<T>(cwd: string, command: Command): Promise<T> { | ||
return this.readProcessJson<T>(cwd, command, SubCommand.SHOW) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { VisualizationSpec } from 'react-vega' | ||
|
||
const data = { | ||
'logs/loss.tsv': { | ||
$schema: 'https://vega.github.io/schema/vega-lite/v5.json', | ||
|
@@ -173,7 +175,7 @@ const data = { | |
] | ||
} | ||
] | ||
}, | ||
} as VisualizationSpec, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [F] Have to cast otherwise we get type errors |
||
'logs/acc.tsv': { | ||
$schema: 'https://vega.github.io/schema/vega-lite/v5.json', | ||
data: { | ||
|
@@ -348,7 +350,7 @@ const data = { | |
] | ||
} | ||
] | ||
}, | ||
} as VisualizationSpec, | ||
'predictions.json': { | ||
$schema: 'https://vega.github.io/schema/vega-lite/v5.json', | ||
data: { | ||
|
@@ -50447,7 +50449,7 @@ const data = { | |
} | ||
] | ||
} | ||
} | ||
} as VisualizationSpec | ||
} | ||
|
||
export default data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[F] We need this for the contract