Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/1 Enhancements/13177.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The status bar will show 'Gathering code' while gather is executing.
15 changes: 8 additions & 7 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@
"DataScience.findJupyterCommandProgressCheckInterpreter": "Checking {0}.",
"DataScience.findJupyterCommandProgressSearchCurrentPath": "Searching current path.",
"DataScience.gatherError": "Gather internal error",
"DataScience.gatheredScriptDescription": "# This file was generated by the Gather Extension.\n# It requires version 2020.7.94776 (or newer) of the Python Extension.\n#\n# The intent is that it contains only the code required to produce\n# the same results as the cell originally selected for gathering.\n# Please note that the Python analysis is quite conservative, so if\n# it is unsure whether a line of code is necessary for execution, it\n# will err on the side of including it.\n#\n# Please let us know if you are satisfied with what was gathered here:\n# https://aka.ms/gathersurvey\n\n",
"DataScience.gatherStatusBar": "$(sync~spin) Gathering Code",
"DataScience.gatheredScriptDescription": "# This file was generated by the Gather Extension.\n# It requires version 2020.7.94776 (or newer) of the Python Extension.\n#\n# The intent is that it contains only the code required to produce\n# the same results as the cell originally selected for gathering.\n# Please note that the Python analysis is quite conservative, so if\n# it is unsure whether a line of code is necessary for execution, it\n# will err on the side of including it.\n#\n# Please let us know if you are satisfied with what was gathered here:\n# https://aka.ms/gatherfeedback\n\n",
"DataScience.gatheredNotebookDescriptionInMarkdown": "## Gathered Notebook\nGathered from ```{0}```\n\n| | |\n|---|---|\n|  &nbsp|This notebook was generated by the Gather Extension. It requires version 2020.7.94776 (or newer) of the Python Extension, please update [here](https://command:python.datascience.latestExtension). The intent is that it contains only the code and cells required to produce the same results as the cell originally selected for gathering. Please note that the Python analysis is quite conservative, so if it is unsure whether a line of code is necessary for execution, it will err on the side of including it.|\n\n**Are you satisfied with the code that was gathered?**\n\n[Yes](https://command:python.datascience.gatherquality?yes) [No](https://command:python.datascience.gatherquality?no)",
"DataScience.savePngTitle": "Save Image",
"DataScience.jupyterSelectURIQuickPickTitle": "Pick how to connect to Jupyter",
Expand Down Expand Up @@ -570,10 +571,10 @@
"DataScienceRendererExtension.downloadCompletedOutputMessage": "Notebook Renderers extension download complete.",
"DataScience.uriProviderDescriptionFormat": "{0} (From {1} extension)",
"DataScience.unknownPackage": "unknown",
"DataScience.interactiveWindowTitle" : "Python Interactive",
"DataScience.interactiveWindowTitleFormat" : "Python Interactive - {0}",
"DataScience.interactiveWindowModeBannerTitle" : "Do you want to open a new Python Interactive window for this file? [More Information](command:workbench.action.openSettings?%5B%22python.dataScience.interactiveWindowMode%22%5D).",
"DataScience.interactiveWindowModeBannerSwitchYes" : "Yes",
"DataScience.interactiveWindowModeBannerSwitchAlways" : "Always",
"DataScience.interactiveWindowModeBannerSwitchNo" : "No"
"DataScience.interactiveWindowTitle": "Python Interactive",
"DataScience.interactiveWindowTitleFormat": "Python Interactive - {0}",
"DataScience.interactiveWindowModeBannerTitle": "Do you want to open a new Python Interactive window for this file? [More Information](command:workbench.action.openSettings?%5B%22python.dataScience.interactiveWindowMode%22%5D).",
"DataScience.interactiveWindowModeBannerSwitchYes": "Yes",
"DataScience.interactiveWindowModeBannerSwitchAlways": "Always",
"DataScience.interactiveWindowModeBannerSwitchNo": "No"
}
3 changes: 2 additions & 1 deletion src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,9 +923,10 @@ export namespace DataScience {
'Searching current path.'
);
export const gatherError = localize('DataScience.gatherError', 'Gather internal error');
export const gatherStatusBar = localize('DataScience.gatherStatusBar', '$(sync~spin) Gathering Code');
export const gatheredScriptDescription = localize(
'DataScience.gatheredScriptDescription',
'# This file was generated by the Gather Extension.\n# It requires version 2020.7.94776 (or newer) of the Python Extension.\n#\n# The intent is that it contains only the code required to produce\n# the same results as the cell originally selected for gathering.\n# Please note that the Python analysis is quite conservative, so if\n# it is unsure whether a line of code is necessary for execution, it\n# will err on the side of including it.\n#\n# Please let us know if you are satisfied with what was gathered here:\n# https://aka.ms/gathersurvey\n\n'
'# This file was generated by the Gather Extension.\n# It requires version 2020.7.94776 (or newer) of the Python Extension.\n#\n# The intent is that it contains only the code required to produce\n# the same results as the cell originally selected for gathering.\n# Please note that the Python analysis is quite conservative, so if\n# it is unsure whether a line of code is necessary for execution, it\n# will err on the side of including it.\n#\n# Please let us know if you are satisfied with what was gathered here:\n# https://aka.ms/gatherfeedback\n\n'
);
export const gatheredNotebookDescriptionInMarkdown = localize(
'DataScience.gatheredNotebookDescriptionInMarkdown',
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/commands/commandRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export class CommandRegistry implements IDisposable {

private reportGatherQuality(val: string) {
sendTelemetryEvent(Telemetry.GatherQualityReport, undefined, { result: val[0] === 'no' ? 'no' : 'yes' });
env.openExternal(Uri.parse(`https://aka.ms/gathersurvey?succeed=${val[0]}`));
env.openExternal(Uri.parse(`https://aka.ms/gatherfeedback?succeed=${val[0]}`));
}

private openPythonExtensionPage() {
Expand Down
61 changes: 47 additions & 14 deletions src/client/datascience/gather/gatherListener.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { inject, injectable } from 'inversify';
import { IDisposable } from 'monaco-editor';
import * as uuid from 'uuid/v4';
import { Event, EventEmitter, Position, Uri, ViewColumn } from 'vscode';
import { Event, EventEmitter, Position, StatusBarItem, Uri, ViewColumn } from 'vscode';
import { createMarkdownCell } from '../../../datascience-ui/common/cellFactory';
import { IApplicationShell, IDocumentManager } from '../../common/application/types';
import { PYTHON_LANGUAGE } from '../../common/constants';
Expand All @@ -10,7 +10,6 @@ import { traceError } from '../../common/logger';
import type { nbformat } from '@jupyterlab/coreutils';
import { IConfigurationService, Resource } from '../../common/types';
import * as localize from '../../common/utils/localize';
import { noop } from '../../common/utils/misc';
import { StopWatch } from '../../common/utils/stopWatch';
import { sendTelemetryEvent } from '../../telemetry';
import { generateCellsFromString } from '../cellFactory';
Expand Down Expand Up @@ -46,6 +45,7 @@ export class GatherListener implements IInteractiveWindowListener {
private gatherTimer: StopWatch | undefined;
private linesSubmitted: number = 0;
private cellsSubmitted: number = 0;
private statusBar: StatusBarItem;

constructor(
@inject(IApplicationShell) private applicationShell: IApplicationShell,
Expand All @@ -55,10 +55,13 @@ export class GatherListener implements IInteractiveWindowListener {
@inject(IConfigurationService) private configService: IConfigurationService,
@inject(IDocumentManager) private documentManager: IDocumentManager,
@inject(IDataScienceFileSystem) private fs: IDataScienceFileSystem
) {}
) {
this.statusBar = this.applicationShell.createStatusBarItem();
this.statusBar.text = localize.DataScience.gatherStatusBar();
}

public dispose() {
noop();
this.statusBar.dispose();
}

// tslint:disable-next-line: no-any
Expand All @@ -74,10 +77,24 @@ export class GatherListener implements IInteractiveWindowListener {
break;

case InteractiveWindowMessages.GatherCode:
this.postEmitter.fire({
message: InteractiveWindowMessages.Gathering,
payload: { cellId: payload.id, gathering: true }
});
setTimeout(() => {
this.statusBar.show();
}, 2000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make this 2000 a constant? Seems to be repeated at least once and might make it easier to understand why the 2 sec wait.

this.handleMessage(message, payload, this.doGather);
break;

case InteractiveWindowMessages.GatherCodeToScript:
this.postEmitter.fire({
message: InteractiveWindowMessages.Gathering,
payload: { cellId: payload.id, gathering: true }
});
setTimeout(() => {
this.statusBar.show();
}, 2000);
this.handleMessage(message, payload, this.doGatherToScript);
break;

Expand Down Expand Up @@ -142,18 +159,34 @@ export class GatherListener implements IInteractiveWindowListener {
}
}

private doGather(payload: ICell): void {
this.gatherCodeInternal(payload).catch((err) => {
traceError(`Gather to Notebook error: ${err}`);
this.applicationShell.showErrorMessage(err);
});
private doGather(payload: ICell): Promise<void> {
return this.gatherCodeInternal(payload)
.catch((err) => {
traceError(`Gather to Notebook error: ${err}`);
this.applicationShell.showErrorMessage(err);
})
.finally(() => {
this.postEmitter.fire({
message: InteractiveWindowMessages.Gathering,
payload: { cellId: payload.id, gathering: false }
});
this.statusBar.hide();
});
}

private doGatherToScript(payload: ICell): void {
this.gatherCodeInternal(payload, true).catch((err) => {
traceError(`Gather to Script error: ${err}`);
this.applicationShell.showErrorMessage(err);
});
private doGatherToScript(payload: ICell): Promise<void> {
return this.gatherCodeInternal(payload, true)
.catch((err) => {
traceError(`Gather to Script error: ${err}`);
this.applicationShell.showErrorMessage(err);
})
.finally(() => {
this.postEmitter.fire({
message: InteractiveWindowMessages.Gathering,
payload: { cellId: payload.id, gathering: false }
});
this.statusBar.hide();
});
}

private gatherCodeInternal = async (cell: ICell, toScript: boolean = false) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { DebugProtocol } from 'vscode-debugprotocol';
import {
CommonActionType,
IAddCellAction,
IChangeGatherStatus,
ILoadIPyWidgetClassFailureAction,
IVariableExplorerHeight,
LoadIPyWidgetClassLoadAction,
Expand Down Expand Up @@ -98,6 +99,7 @@ export enum InteractiveWindowMessages {
StopDebugging = 'stop_debugging',
GatherCode = 'gather_code',
GatherCodeToScript = 'gather_code_to_script',
Gathering = 'gathering',
LaunchNotebookTrustPrompt = 'launch_notebook_trust_prompt',
TrustNotebookComplete = 'trust_notebook_complete',
LoadAllCells = 'load_all_cells',
Expand Down Expand Up @@ -630,6 +632,7 @@ export class IInteractiveWindowMapping {
public [InteractiveWindowMessages.StopDebugging]: never | undefined;
public [InteractiveWindowMessages.GatherCode]: ICell;
public [InteractiveWindowMessages.GatherCodeToScript]: ICell;
public [InteractiveWindowMessages.Gathering]: IChangeGatherStatus;
public [InteractiveWindowMessages.LaunchNotebookTrustPrompt]: never | undefined;
public [InteractiveWindowMessages.TrustNotebookComplete]: never | undefined;
public [InteractiveWindowMessages.LoadAllCells]: ILoadAllCells;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const messageWithMessageTypes: MessageMapping<IInteractiveWindowMapping> & Messa
[InteractiveWindowMessages.FocusedCellEditor]: MessageType.syncWithLiveShare,
[InteractiveWindowMessages.GatherCode]: MessageType.other,
[InteractiveWindowMessages.GatherCodeToScript]: MessageType.other,
[InteractiveWindowMessages.Gathering]: MessageType.other,
[InteractiveWindowMessages.GetAllCells]: MessageType.other,
[InteractiveWindowMessages.ForceVariableRefresh]: MessageType.other,
[InteractiveWindowMessages.GetVariablesRequest]: MessageType.other,
Expand Down
7 changes: 6 additions & 1 deletion src/datascience-ui/history-react/interactiveCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,13 @@ export class InteractiveCell extends React.Component<IInteractiveCellProps> {
!this.props.settings.gatherIsInstalled
}
tooltip={getLocString('DataScience.gatherCodeTooltip', 'Gather code')}
disabled={this.props.cellVM.gathering}
>
<Image baseTheme={this.props.baseTheme} class="image-button-image" image={ImageName.GatherCode} />
<Image
baseTheme={this.props.baseTheme}
class={this.props.cellVM.gathering ? 'image-button-image rotate' : 'image-button-image'}
image={this.props.cellVM.gathering ? ImageName.Sync : ImageName.GatherCode}
/>
</ImageButton>
<ImageButton
baseTheme={this.props.baseTheme}
Expand Down
24 changes: 18 additions & 6 deletions src/datascience-ui/history-react/interactivePanel.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Import common styles and then override them below */
@import "../interactive-common/common.css";
@import '../interactive-common/common.css';

.toolbar-menu-bar-child {
background: var(--override-background, var(--vscode-editor-background));
Expand Down Expand Up @@ -37,27 +37,26 @@
}

.cell-outer {
display:grid;
display: grid;
grid-template-columns: auto minmax(0, 1fr) 8px;
grid-column-gap: 3px;
width: 100%;
}


.cell-output {
margin: 0px;
width: 100%;
overflow-x: scroll;
background: transparent;
}

.cell-output>div {
.cell-output > div {
background: var(--override-widget-background, var(--vscode-notifications-background));
}

xmp {
margin: 0px;
}
}

.cell-input {
margin: 0;
Expand All @@ -72,4 +71,17 @@ xmp {
white-space: pre-wrap;
word-break: break-all;
overflow-x: hidden;
}
}

.rotate {
animation: rotation 2s infinite linear;
}

@keyframes rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(359deg);
}
}
24 changes: 22 additions & 2 deletions src/datascience-ui/history-react/redux/reducers/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { InteractiveWindowMessages } from '../../../../client/datascience/intera
import { CellState } from '../../../../client/datascience/types';
import { generateMarkdownFromCodeLines } from '../../../common';
import { createCellFrom } from '../../../common/cellFactory';
import { createCellVM, IMainState } from '../../../interactive-common/mainState';
import { createCellVM, ICellViewModel, IMainState } from '../../../interactive-common/mainState';
import { postActionToExtension } from '../../../interactive-common/redux/helpers';
import { Helpers } from '../../../interactive-common/redux/reducers/helpers';
import { ICodeAction } from '../../../interactive-common/redux/reducers/types';
import { IChangeGatherStatus, ICodeAction } from '../../../interactive-common/redux/reducers/types';
import { InteractiveReducerArg } from '../mapping';
import { Creation } from './creation';

Expand Down Expand Up @@ -127,4 +127,24 @@ export namespace Execution {
}
return arg.prevState;
}

export function gathering(arg: InteractiveReducerArg<IChangeGatherStatus>): IMainState {
const index = arg.prevState.cellVMs.findIndex((c) => c.cell.id === arg.payload.data.cellId);
if (index >= 0) {
const cellVMs = [...arg.prevState.cellVMs];
const current = arg.prevState.cellVMs[index];
const newCell: ICellViewModel = {
...current,
gathering: arg.payload.data.gathering
};
cellVMs[index] = newCell;

return {
...arg.prevState,
cellVMs
};
}

return arg.prevState;
}
}
3 changes: 2 additions & 1 deletion src/datascience-ui/history-react/redux/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ export const reducerMap: Partial<IInteractiveActionMapping> = {
[InteractiveWindowMessages.UpdateKernel]: Kernel.updateStatus,
[SharedMessages.LocInit]: CommonEffects.handleLocInit,
[InteractiveWindowMessages.UpdateDisplayData]: CommonEffects.handleUpdateDisplayData,
[InteractiveWindowMessages.HasCell]: Transfer.hasCell
[InteractiveWindowMessages.HasCell]: Transfer.hasCell,
[InteractiveWindowMessages.Gathering]: Execution.gathering
};
7 changes: 5 additions & 2 deletions src/datascience-ui/interactive-common/mainState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface ICellViewModel {
uiSideError?: string;
runningByLine: DebugState;
currentStack?: DebugProtocol.StackFrame[];
gathering: boolean;
}

export type IMainState = {
Expand Down Expand Up @@ -227,7 +228,8 @@ export function createEditableCellVM(executionCount: number): ICellViewModel {
cursorPos: CursorPos.Current,
hasBeenRun: false,
scrollCount: 0,
runningByLine: DebugState.Design
runningByLine: DebugState.Design,
gathering: false
};
}

Expand Down Expand Up @@ -281,7 +283,8 @@ export function createCellVM(
hasBeenRun: false,
scrollCount: 0,
runDuringDebug,
runningByLine: DebugState.Design
runningByLine: DebugState.Design,
gathering: false
};

// Update the input text
Expand Down
5 changes: 5 additions & 0 deletions src/datascience-ui/interactive-common/redux/reducers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,9 @@ export type NotifyIPyWidgeWidgetVersionNotSupportedAction = {
moduleVersion: string;
};

export interface IChangeGatherStatus {
cellId: string;
gathering: boolean;
}

export type CommonAction<T = never | undefined> = ActionWithPayload<T, CommonActionType | InteractiveWindowMessages>;
4 changes: 2 additions & 2 deletions src/datascience-ui/native-editor/nativeCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -708,12 +708,12 @@ export class NativeCell extends React.Component<INativeCellProps> {
'Gather the code required to generate this cell into a new notebook'
)}
hidden={gatherDisabled}
disabled={!this.props.isNotebookTrusted}
disabled={!this.props.isNotebookTrusted || this.props.cellVM.gathering}
>
<Image
baseTheme={this.props.baseTheme}
class="image-button-image"
image={ImageName.GatherCode}
image={this.props.cellVM.gathering ? ImageName.Sync : ImageName.GatherCode}
/>
</ImageButton>
<ImageButton
Expand Down
Loading