Skip to content

Commit

Permalink
Merge branch 'main' into inform-invalid-yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
sroy3 authored Mar 1, 2023
2 parents f9ed3ab + 4fbbe9e commit 7072e19
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 42 deletions.
11 changes: 10 additions & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,11 @@
"category": "DVC",
"icon": "$(repo-push)"
},
{
"title": "%command.views.experiments.showLogs%",
"command": "dvc.views.experiments.showLogs",
"category": "DVC"
},
{
"title": "%command.views.experimentsTree.selectExperiments%",
"command": "dvc.views.experimentsTree.selectExperiments",
Expand Down Expand Up @@ -885,6 +890,10 @@
"command": "dvc.views.experiments.shareExperimentToStudio",
"when": "false"
},
{
"command": "dvc.views.experiments.showLogs",
"when": "false"
},
{
"command": "dvc.views.experimentsFilterByTree.removeAllFilters",
"when": "false"
Expand Down Expand Up @@ -1611,7 +1620,7 @@
"@types/node": "16.x",
"@types/react-vega": "7.0.0",
"@types/sinon-chai": "3.2.9",
"@types/uuid": "9.0.0",
"@types/uuid": "9.0.1",
"@types/vscode": "1.64.0",
"@vscode/test-electron": "2.2.3",
"@vscode/vsce": "2.17.0",
Expand Down
1 change: 1 addition & 0 deletions extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"command.views.experiments.shareExperimentAsBranch": "Share as Branch",
"command.views.experiments.shareExperimentAsCommit": "Commit and Share",
"command.views.experiments.shareExperimentToStudio": "Share to Studio",
"command.views.experiments.showLogs": "Show Logs",
"command.views.experimentsTree.selectExperiments": "Select Experiments to Display in Plots",
"command.views.plotsPathsTree.selectPlots": "Select Plots to Display",
"command.views.plotsPathsTree.refreshPlots": "Refresh Plots for Selected Experiments",
Expand Down
2 changes: 1 addition & 1 deletion extension/src/cli/dvc/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class DvcViewer extends Disposable implements ICli {

public queueLogs(cwd: string, expName: string) {
return this.run(
expName,
`${expName} logs`,
cwd,
Command.QUEUE,
QueueSubCommand.LOGS,
Expand Down
1 change: 1 addition & 0 deletions extension/src/cli/viewable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class ViewableCliProcess extends DeferredDisposable {
},
processCompleted
)
this.pseudoTerminal.setBlocked(false)
processOutput.fire('\r\nPress any key to close\r\n\n')
})
}
Expand Down
1 change: 1 addition & 0 deletions extension/src/commands/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export enum RegisteredCliCommands {
EXPERIMENT_VIEW_REMOVE = 'dvc.views.experiments.removeExperiment',
EXPERIMENT_VIEW_SHARE_AS_BRANCH = 'dvc.views.experiments.shareExperimentAsBranch',
EXPERIMENT_VIEW_SHARE_AS_COMMIT = 'dvc.views.experiments.shareExperimentAsCommit',
EXPERIMENT_VIEW_SHOW_LOGS = 'dvc.views.experiments.showLogs',
EXPERIMENT_VIEW_STOP = 'dvc.views.experiments.stopQueueExperiment',

EXPERIMENT_VIEW_QUEUE = 'dvc.views.experiments.queueExperiment',
Expand Down
6 changes: 6 additions & 0 deletions extension/src/experiments/commands/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,10 @@ export const registerExperimentCommands = (
RegisteredCommands.EXPERIMENT_VIEW_SHARE_TO_STUDIO,
getShareExperimentToStudioCommand(internalCommands, connect)
)

internalCommands.registerExternalCliCommand(
RegisteredCliCommands.EXPERIMENT_VIEW_SHOW_LOGS,
({ dvcRoot, id }: ExperimentDetails) =>
internalCommands.executeCommand(AvailableCommands.QUEUE_LOGS, dvcRoot, id)
)
}
9 changes: 9 additions & 0 deletions extension/src/experiments/webview/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ export class WebviewMessages {
{ dvcRoot: this.dvcRoot, id: message.payload }
)

case MessageFromWebviewType.SHOW_EXPERIMENT_LOGS:
return commands.executeCommand(
RegisteredCliCommands.EXPERIMENT_VIEW_SHOW_LOGS,
{
dvcRoot: this.dvcRoot,
id: message.payload
}
)

default:
Logger.error(`Unexpected message: ${JSON.stringify(message)}`)
}
Expand Down
1 change: 1 addition & 0 deletions extension/src/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export interface IEventNamePropertyMapping {
[EventName.EXPERIMENT_VIEW_SHARE_AS_BRANCH]: undefined
[EventName.EXPERIMENT_VIEW_SHARE_AS_COMMIT]: undefined
[EventName.EXPERIMENT_VIEW_SHARE_TO_STUDIO]: undefined
[EventName.EXPERIMENT_VIEW_SHOW_LOGS]: undefined
[EventName.EXPERIMENT_VIEW_STOP]: undefined
[EventName.QUEUE_EXPERIMENT]: undefined
[EventName.QUEUE_KILL]: undefined
Expand Down
39 changes: 38 additions & 1 deletion extension/src/test/suite/experiments/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ import { shortenForLabel } from '../../../util/string'
import { GitExecutor } from '../../../cli/git/executor'
import { WorkspacePlots } from '../../../plots/workspace'
import { PlotSizeNumber } from '../../../plots/webview/contract'
import { RegisteredCommands } from '../../../commands/external'
import {
RegisteredCliCommands,
RegisteredCommands
} from '../../../commands/external'
import { ConfigKey } from '../../../vscode/config'
import { EXPERIMENT_WORKSPACE_ID } from '../../../cli/dvc/contract'
import * as Time from '../../../util/time'
Expand All @@ -78,6 +81,7 @@ import * as FileSystem from '../../../fileSystem'
import * as ProcessExecution from '../../../process/execution'
import { DvcReader } from '../../../cli/dvc/reader'
import { Connect } from '../../../connect'
import { DvcViewer } from '../../../cli/dvc/viewer'

const { openFileInEditor } = FileSystem

Expand Down Expand Up @@ -549,6 +553,39 @@ suite('Experiments Test Suite', () => {
)
}).timeout(WEBVIEW_TEST_TIMEOUT)

it('should handle a message to show the logs of an experiment', async () => {
const { experiments } = buildExperiments(disposable)
await experiments.isReady()

const mockExpId = 'exp-e7a67'

const webview = await experiments.showWebview()
const mockMessageReceived = getMessageReceivedEmitter(webview)

const executeCommandSpy = spy(commands, 'executeCommand')

const mockShowLogs = stub(DvcViewer.prototype, 'queueLogs')

const logsShown = new Promise(resolve =>
mockShowLogs.callsFake(() => {
resolve(undefined)
return Promise.resolve(undefined)
})
)

mockMessageReceived.fire({
payload: mockExpId,
type: MessageFromWebviewType.SHOW_EXPERIMENT_LOGS
})

await logsShown

expect(executeCommandSpy).to.be.calledWithExactly(
RegisteredCliCommands.EXPERIMENT_VIEW_SHOW_LOGS,
{ dvcRoot: dvcDemoPath, id: mockExpId }
)
}).timeout(WEBVIEW_TEST_TIMEOUT)

it('should handle a message to share an experiment to Studio', async () => {
const { experiments } = buildExperiments(disposable)
await experiments.isReady()
Expand Down
2 changes: 2 additions & 0 deletions extension/src/test/suite/experiments/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const buildExperiments = (
dvcExecutor,
dvcReader,
dvcRunner,
dvcViewer,
gitReader,
internalCommands,
messageSpy,
Expand Down Expand Up @@ -90,6 +91,7 @@ export const buildExperiments = (
dvcExecutor,
dvcReader,
dvcRunner,
dvcViewer,
experiments,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
experimentsModel: (experiments as any).experiments as ExperimentsModel,
Expand Down
6 changes: 6 additions & 0 deletions extension/src/test/suite/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { TableData } from '../../experiments/webview/contract'
import { DvcExecutor } from '../../cli/dvc/executor'
import { GitReader } from '../../cli/git/reader'
import { SetupData } from '../../setup/webview/contract'
import { DvcViewer } from '../../cli/dvc/viewer'

export const mockDisposable = {
dispose: stub()
Expand Down Expand Up @@ -141,6 +142,7 @@ export const buildInternalCommands = (disposer: Disposer) => {
const dvcReader = disposer.track(new DvcReader(config))
const dvcRunner = disposer.track(new DvcRunner(config))
const dvcExecutor = disposer.track(new DvcExecutor(config))
const dvcViewer = disposer.track(new DvcViewer(config))
const gitReader = disposer.track(new GitReader())

const outputChannel = disposer.track(
Expand All @@ -153,6 +155,7 @@ export const buildInternalCommands = (disposer: Disposer) => {
dvcExecutor,
dvcReader,
dvcRunner,
dvcViewer,
gitReader
)
)
Expand All @@ -162,6 +165,7 @@ export const buildInternalCommands = (disposer: Disposer) => {
dvcExecutor,
dvcReader,
dvcRunner,
dvcViewer,
gitReader,
internalCommands
}
Expand Down Expand Up @@ -189,6 +193,7 @@ export const buildDependencies = (
dvcExecutor,
dvcReader,
dvcRunner,
dvcViewer,
gitReader,
internalCommands
} = buildInternalCommands(disposer)
Expand Down Expand Up @@ -223,6 +228,7 @@ export const buildDependencies = (
dvcExecutor,
dvcReader,
dvcRunner,
dvcViewer,
gitReader,
internalCommands,
messageSpy,
Expand Down
2 changes: 2 additions & 0 deletions extension/src/webview/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export enum MessageFromWebviewType {
RESIZE_PLOTS = 'resize-plots',
SAVE_STUDIO_TOKEN = 'save-studio-token',
SHARE_EXPERIMENT_TO_STUDIO = 'share-experiment-to-studio',
SHOW_EXPERIMENT_LOGS = 'show-experiment-logs',
STOP_EXPERIMENT = 'stop-experiment',
SORT_COLUMN = 'sort-column',
TOGGLE_EXPERIMENT = 'toggle-experiment',
Expand Down Expand Up @@ -136,6 +137,7 @@ export type MessageFromWebview =
type: MessageFromWebviewType.STOP_EXPERIMENT
payload: { id: string; executor?: string | null }[]
}
| { type: MessageFromWebviewType.SHOW_EXPERIMENT_LOGS; payload: string }
| {
type: MessageFromWebviewType.SHARE_EXPERIMENT_TO_STUDIO
payload: string
Expand Down
9 changes: 5 additions & 4 deletions webview/src/experiments/components/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,7 @@ describe('App', () => {
const menuitems = screen.getAllByRole('menuitem')
const itemLabels = menuitems.map(item => item.textContent)
expect(itemLabels).toStrictEqual([
'Show Logs',
'Apply to Workspace',
'Create new Branch',
'Share to Studio',
Expand All @@ -888,7 +889,7 @@ describe('App', () => {
fireEvent.contextMenu(row, { bubbles: true })

advanceTimersByTime(100)
expect(screen.getAllByRole('menuitem')).toHaveLength(11)
expect(screen.getAllByRole('menuitem')).toHaveLength(12)

fireEvent.click(window, { bubbles: true })
advanceTimersByTime(100)
Expand All @@ -902,7 +903,7 @@ describe('App', () => {
fireEvent.contextMenu(row, { bubbles: true })

advanceTimersByTime(100)
expect(screen.getAllByRole('menuitem')).toHaveLength(11)
expect(screen.getAllByRole('menuitem')).toHaveLength(12)

const commit = getRow('main')
fireEvent.click(commit, { bubbles: true })
Expand All @@ -917,13 +918,13 @@ describe('App', () => {
fireEvent.contextMenu(row, { bubbles: true })

advanceTimersByTime(100)
expect(screen.queryAllByRole('menuitem')).toHaveLength(11)
expect(screen.queryAllByRole('menuitem')).toHaveLength(12)

fireEvent.contextMenu(within(row).getByText('[exp-e7a67]'), {
bubbles: true
})
advanceTimersByTime(200)
expect(screen.queryAllByRole('menuitem')).toHaveLength(11)
expect(screen.queryAllByRole('menuitem')).toHaveLength(12)
})

it('should present the Remove experiment option for the checkpoint tips', () => {
Expand Down
9 changes: 8 additions & 1 deletion webview/src/experiments/components/table/RowContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { MessageFromWebviewType } from 'dvc/src/webview/contract'
import {
ExperimentStatus,
isQueued,
isRunning
isRunning,
isRunningInQueue
} from 'dvc/src/experiments/webview/contract'
import { EXPERIMENT_WORKSPACE_ID } from 'dvc/src/cli/dvc/contract'
import { RowProp } from './interfaces'
Expand Down Expand Up @@ -190,6 +191,12 @@ const getSingleSelectMenuOptions = (
)

return [
experimentMenuOption(
id,
'Show Logs',
MessageFromWebviewType.SHOW_EXPERIMENT_LOGS,
!isRunningInQueue({ executor, status })
),
notRunningWithId(
'Apply to Workspace',
MessageFromWebviewType.APPLY_EXPERIMENT_TO_WORKSPACE,
Expand Down
6 changes: 1 addition & 5 deletions webview/src/plots/components/PlotsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ import {
import { isSelecting } from '../../util/strings'
import { isTooltip } from '../../util/helpers'

export interface CommonPlotsContainerProps {
onResize: (size: number) => void
}

export interface PlotsContainerProps extends CommonPlotsContainerProps {
export interface PlotsContainerProps {
sectionCollapsed: boolean
sectionKey: Section
title: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { Section } from 'dvc/src/plots/webview/contract'
import { MessageFromWebviewType } from 'dvc/src/webview/contract'
import React, { useEffect, useState } from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { useSelector } from 'react-redux'
import { CheckpointPlots } from './CheckpointPlots'
import { changeSize } from './checkpointPlotsSlice'
import { PlotsContainer } from '../PlotsContainer'
import { sendMessage } from '../../../shared/vscode'
import { PlotsState } from '../../store'

export const CheckpointPlotsWrapper: React.FC = () => {
const dispatch = useDispatch()
const { plotsIds, size, selectedMetrics, isCollapsed, colors } = useSelector(
(state: PlotsState) => state.checkpoint
)
Expand All @@ -29,10 +27,6 @@ export const CheckpointPlotsWrapper: React.FC = () => {
})
}

const handleResize = (size: number) => {
dispatch(changeSize(size))
}

const menu =
plotsIds.length > 0
? {
Expand All @@ -49,7 +43,6 @@ export const CheckpointPlotsWrapper: React.FC = () => {
menu={menu}
currentSize={size}
sectionCollapsed={isCollapsed}
onResize={handleResize}
>
<CheckpointPlots plotsIds={selectedPlots} colors={colors} />
</PlotsContainer>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
import { Section } from 'dvc/src/plots/webview/contract'
import React from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { useSelector } from 'react-redux'
import { ComparisonTable } from './ComparisonTable'
import { changeSize } from './comparisonTableSlice'
import { PlotsContainer } from '../PlotsContainer'
import { PlotsState } from '../../store'

export const ComparisonTableWrapper: React.FC = () => {
const dispatch = useDispatch()
const { size, isCollapsed } = useSelector(
(state: PlotsState) => state.comparison
)
const handleResize = (size: number) => {
dispatch(changeSize(size))
}

return (
<PlotsContainer
title="Images"
sectionKey={Section.COMPARISON_TABLE}
currentSize={size}
sectionCollapsed={isCollapsed}
onResize={handleResize}
>
<ComparisonTable />
</PlotsContainer>
Expand Down
Loading

0 comments on commit 7072e19

Please sign in to comment.