Skip to content

Commit

Permalink
Merge branch 'main' into attempt-on-django
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorjboyd authored Oct 18, 2023
2 parents 395e366 + 7cb3593 commit 10fad9b
Show file tree
Hide file tree
Showing 35 changed files with 670 additions and 283 deletions.
1 change: 1 addition & 0 deletions build/webpack/webpack.extension.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const config = {
resolve: {
extensions: ['.ts', '.js'],
plugins: [new tsconfig_paths_webpack_plugin.TsconfigPathsPlugin({ configFile: configFileName })],
conditionNames: ['import', 'require', 'node'],
},
output: {
filename: '[name].js',
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,15 +537,17 @@
"pythonPromptNewToolsExt",
"pythonTerminalEnvVarActivation",
"pythonTestAdapter",
"pythonREPLSmartSend"
"pythonREPLSmartSend",
"pythonRecommendTensorboardExt"
],
"enumDescriptions": [
"%python.experiments.All.description%",
"%python.experiments.pythonSurveyNotification.description%",
"%python.experiments.pythonPromptNewToolsExt.description%",
"%python.experiments.pythonTerminalEnvVarActivation.description%",
"%python.experiments.pythonTestAdapter.description%",
"%python.experiments.pythonREPLSmartSend.description%"
"%python.experiments.pythonREPLSmartSend.description%",
"%python.experiments.pythonRecommendTensorboardExt.description%"
]
},
"scope": "machine",
Expand Down Expand Up @@ -1098,7 +1100,9 @@
"default": "",
"description": "%python.tensorBoard.logDirectory.description%",
"scope": "resource",
"type": "string"
"type": "string",
"markdownDeprecationMessage": "%python.tensorBoard.logDirectory.markdownDeprecationMessage%",
"deprecationMessage": "%python.tensorBoard.logDirectory.deprecationMessage%"
},
"python.terminal.activateEnvInCurrentTerminal": {
"default": false,
Expand Down
3 changes: 3 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"python.experiments.pythonTerminalEnvVarActivation.description": "Enables use of environment variables to activate terminals instead of sending activation commands.",
"python.experiments.pythonTestAdapter.description": "Denotes the Python Test Adapter experiment.",
"python.experiments.pythonREPLSmartSend.description": "Denotes the Python REPL Smart Send experiment.",
"python.experiments.pythonRecommendTensorboardExt.description": "Denotes the Tensorboard Extension recommendation experiment.",
"python.globalModuleInstallation.description": "Whether to install Python modules globally when not using an environment.",
"python.languageServer.description": "Defines type of the language server.",
"python.languageServer.defaultDescription": "Automatically select a language server: Pylance if installed and available, otherwise fallback to Jedi.",
Expand Down Expand Up @@ -181,6 +182,8 @@
"python.pipenvPath.description": "Path to the pipenv executable to use for activation.",
"python.poetryPath.description": "Path to the poetry executable.",
"python.tensorBoard.logDirectory.description": "Set this setting to your preferred TensorBoard log directory to skip log directory prompt when starting TensorBoard.",
"python.tensorBoard.logDirectory.markdownDeprecationMessage": "Tensorboard support has been moved to the extension [Tensorboard extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.tensorboard). Instead use the setting `tensorBoard.logDirectory`.",
"python.tensorBoard.logDirectory.deprecationMessage": "Tensorboard support has been moved to the extension Tensorboard extension. Instead use the setting `tensorBoard.logDirectory`.",
"python.terminal.activateEnvInCurrentTerminal.description": "Activate Python Environment in the current Terminal on load of the Extension.",
"python.terminal.activateEnvironment.description": "Activate Python Environment in all Terminals created.",
"python.terminal.executeInFileDir.description": "When executing a file in the terminal, whether to use execute in the file's directory, instead of the current open folder.",
Expand Down
2 changes: 1 addition & 1 deletion pythonFiles/normalizeSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def normalize_lines(selection):

# Insert a newline between each top-level statement, and append a newline to the selection.
source = "\n".join(statements) + "\n"
if selection[-2] == "}":
if selection[-2] == "}" or selection[-2] == "]":
source = source[:-1]
except Exception:
# If there's a problem when parsing statements,
Expand Down
16 changes: 10 additions & 6 deletions pythonFiles/vscode_pytest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class testRunResultDict(Dict[str, Dict[str, TestOutcome]]):
tests: Dict[str, TestOutcome]


@pytest.hookimpl(hookwrapper=True, trylast=True)
def pytest_report_teststatus(report, config):
"""
A pytest hook that is called when a test is called. It is called 3 times per test,
Expand Down Expand Up @@ -223,6 +224,7 @@ def pytest_report_teststatus(report, config):
"success",
collected_test if collected_test else None,
)
yield


ERROR_MESSAGE_CONST = {
Expand All @@ -233,6 +235,7 @@ def pytest_report_teststatus(report, config):
}


@pytest.hookimpl(hookwrapper=True, trylast=True)
def pytest_runtest_protocol(item, nextitem):
map_id_to_path[item.nodeid] = get_node_path(item)
skipped = check_skipped_wrapper(item)
Expand All @@ -255,6 +258,7 @@ def pytest_runtest_protocol(item, nextitem):
"success",
collected_test if collected_test else None,
)
yield


def check_skipped_wrapper(item):
Expand Down Expand Up @@ -302,12 +306,12 @@ def pytest_sessionfinish(session, exitstatus):
session -- the pytest session object.
exitstatus -- the status code of the session.
0: All tests passed successfully.
1: One or more tests failed.
2: Pytest was unable to start or run any tests due to issues with test discovery or test collection.
3: Pytest was interrupted by the user, for example by pressing Ctrl+C during test execution.
4: Pytest encountered an internal error or exception during test execution.
5: Pytest was unable to find any tests to run.
Exit code 0: All tests were collected and passed successfully
Exit code 1: Tests were collected and run but some of the tests failed
Exit code 2: Test execution was interrupted by the user
Exit code 3: Internal error happened while executing tests
Exit code 4: pytest command line usage error
Exit code 5: No tests were collected
"""
cwd = pathlib.Path.cwd()
if IS_DISCOVERY:
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ importlib-metadata==6.7.0 \
--hash=sha256:1aaf550d4f73e5d6783e7acb77aec43d49da8017410afae93822cc9cca98c4d4 \
--hash=sha256:cb52082e659e97afc5dac71e79de97d8681de3aa07ff18578330904a9d18e5b5
# via -r requirements.in
microvenv==2023.2.0 \
--hash=sha256:5b46296d6a65992946da504bd9e724a5becf5c256091f2f9383e5b4e9f567f23 \
--hash=sha256:a07e88a8fb5ee90219b86dd90095cb5646462d45d30285ea3b1a3c7cf33616d3
microvenv==2023.3.post1 \
--hash=sha256:67f0a48511cf16d6a2a45137175d0ddc36a657b91459b598cfbe976ef2afd596 \
--hash=sha256:6e8c80ccfe813b00b77ab9cc2e5af3fd44e2fe540df176509fda97123f8b8290
# via -r requirements.in
packaging==23.2 \
--hash=sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5 \
Expand Down
5 changes: 5 additions & 0 deletions src/client/common/experiments/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ export enum EnableTestAdapterRewrite {
export enum EnableREPLSmartSend {
experiment = 'pythonREPLSmartSend',
}

// Experiment to recommend installing the tensorboard extension.
export enum RecommendTensobardExtension {
experiment = 'pythonRecommendTensorboardExt',
}
6 changes: 4 additions & 2 deletions src/client/common/experiments/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,10 @@ function sendOptInOptOutTelemetry(optedIn: string[], optedOut: string[], package
const sanitizedOptedIn = optedIn.filter((exp) => optedInEnumValues.includes(exp));
const sanitizedOptedOut = optedOut.filter((exp) => optedOutEnumValues.includes(exp));

JSON.stringify(sanitizedOptedIn.sort());

sendTelemetryEvent(EventName.PYTHON_EXPERIMENTS_OPT_IN_OPT_OUT_SETTINGS, undefined, {
optedInto: sanitizedOptedIn,
optedOutFrom: sanitizedOptedOut,
optedInto: JSON.stringify(sanitizedOptedIn.sort()),
optedOutFrom: JSON.stringify(sanitizedOptedOut.sort()),
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,12 @@ function shouldPS1BeSet(type: PythonEnvType | undefined, env: EnvironmentVariabl
}

function shouldSkip(env: string) {
return ['_', 'SHLVL'].includes(env);
return [
'_',
'SHLVL',
// Even though this maybe returned, setting it can result in output encoding errors in terminal.
'PYTHONUTF8',
].includes(env);
}

function getPromptForEnv(interpreter: PythonEnvironment | undefined) {
Expand Down
8 changes: 4 additions & 4 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1405,14 +1405,14 @@ export interface IEventNamePropertyMapping {
[EventName.PYTHON_EXPERIMENTS_OPT_IN_OPT_OUT_SETTINGS]: {
/**
* List of valid experiments in the python.experiments.optInto setting
* @type {string[]}
* @type {string}
*/
optedInto: string[];
optedInto: string;
/**
* List of valid experiments in the python.experiments.optOutFrom setting
* @type {string[]}
* @type {string}
*/
optedOutFrom: string[];
optedOutFrom: string;
};
/**
* Telemetry event sent when LS is started for workspace (workspace folder in case of multi-root)
Expand Down
22 changes: 17 additions & 5 deletions src/client/tensorBoard/nbextensionCodeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,46 @@

import { inject, injectable } from 'inversify';
import { once } from 'lodash';
import { CancellationToken, CodeLens, Command, languages, Position, Range, TextDocument } from 'vscode';
import { CancellationToken, CodeLens, Command, Disposable, languages, Position, Range, TextDocument } from 'vscode';
import { IExtensionSingleActivationService } from '../activation/types';
import { Commands, NotebookCellScheme, PYTHON_LANGUAGE } from '../common/constants';
import { IDisposableRegistry } from '../common/types';
import { IDisposable, IDisposableRegistry } from '../common/types';
import { TensorBoard } from '../common/utils/localize';
import { sendTelemetryEvent } from '../telemetry';
import { EventName } from '../telemetry/constants';
import { TensorBoardEntrypoint, TensorBoardEntrypointTrigger } from './constants';
import { containsNotebookExtension } from './helpers';
import { useNewTensorboardExtension } from './tensorboarExperiment';
import { TensorboardExperiment } from './tensorboarExperiment';

@injectable()
export class TensorBoardNbextensionCodeLensProvider implements IExtensionSingleActivationService {
public readonly supportedWorkspaceTypes = { untrustedWorkspace: false, virtualWorkspace: false };

private readonly disposables: IDisposable[] = [];

private sendTelemetryOnce = once(
sendTelemetryEvent.bind(this, EventName.TENSORBOARD_ENTRYPOINT_SHOWN, undefined, {
trigger: TensorBoardEntrypointTrigger.nbextension,
entrypoint: TensorBoardEntrypoint.codelens,
}),
);

constructor(@inject(IDisposableRegistry) private disposables: IDisposableRegistry) {}
constructor(
@inject(IDisposableRegistry) disposables: IDisposableRegistry,
@inject(TensorboardExperiment) private readonly experiment: TensorboardExperiment,
) {
disposables.push(this);
}

public dispose(): void {
Disposable.from(...this.disposables).dispose();
}

public async activate(): Promise<void> {
if (useNewTensorboardExtension()) {
if (TensorboardExperiment.isTensorboardExtensionInstalled) {
return;
}
this.experiment.disposeOnInstallingTensorboard(this);
this.activateInternal().ignoreErrors();
}

Expand Down
2 changes: 2 additions & 0 deletions src/client/tensorBoard/serviceRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TensorBoardSessionProvider } from './tensorBoardSessionProvider';
import { TensorBoardNbextensionCodeLensProvider } from './nbextensionCodeLensProvider';
import { TerminalWatcher } from './terminalWatcher';
import { TensorboardDependencyChecker } from './tensorboardDependencyChecker';
import { TensorboardExperiment } from './tensorboarExperiment';

export function registerTypes(serviceManager: IServiceManager): void {
serviceManager.addSingleton<TensorBoardSessionProvider>(TensorBoardSessionProvider, TensorBoardSessionProvider);
Expand All @@ -34,4 +35,5 @@ export function registerTypes(serviceManager: IServiceManager): void {
serviceManager.addBinding(TensorBoardNbextensionCodeLensProvider, IExtensionSingleActivationService);
serviceManager.addSingleton(IExtensionSingleActivationService, TerminalWatcher);
serviceManager.addSingleton(TensorboardDependencyChecker, TensorboardDependencyChecker);
serviceManager.addSingleton(TensorboardExperiment, TensorboardExperiment);
}
22 changes: 16 additions & 6 deletions src/client/tensorBoard/tensorBoardFileWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Licensed under the MIT License.

import { inject, injectable } from 'inversify';
import { FileSystemWatcher, RelativePattern, WorkspaceFolder, WorkspaceFoldersChangeEvent } from 'vscode';
import { Disposable, FileSystemWatcher, RelativePattern, WorkspaceFolder, WorkspaceFoldersChangeEvent } from 'vscode';
import { IExtensionSingleActivationService } from '../activation/types';
import { IWorkspaceService } from '../common/application/types';
import { IDisposableRegistry } from '../common/types';
import { IDisposable, IDisposableRegistry } from '../common/types';
import { TensorBoardEntrypointTrigger } from './constants';
import { TensorBoardPrompt } from './tensorBoardPrompt';
import { useNewTensorboardExtension } from './tensorboarExperiment';
import { TensorboardExperiment } from './tensorboarExperiment';

@injectable()
export class TensorBoardFileWatcher implements IExtensionSingleActivationService {
Expand All @@ -18,16 +18,26 @@ export class TensorBoardFileWatcher implements IExtensionSingleActivationService

private globPatterns = ['*tfevents*', '*/*tfevents*', '*/*/*tfevents*'];

private readonly disposables: IDisposable[] = [];

constructor(
@inject(IWorkspaceService) private workspaceService: IWorkspaceService,
@inject(TensorBoardPrompt) private tensorBoardPrompt: TensorBoardPrompt,
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry,
) {}
@inject(IDisposableRegistry) disposables: IDisposableRegistry,
@inject(TensorboardExperiment) private readonly experiment: TensorboardExperiment,
) {
disposables.push(this);
}

public dispose(): void {
Disposable.from(...this.disposables).dispose();
}

public async activate(): Promise<void> {
if (useNewTensorboardExtension()) {
if (TensorboardExperiment.isTensorboardExtensionInstalled) {
return;
}
this.experiment.disposeOnInstallingTensorboard(this);
this.activateInternal().ignoreErrors();
}

Expand Down
22 changes: 17 additions & 5 deletions src/client/tensorBoard/tensorBoardImportCodeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

import { inject, injectable } from 'inversify';
import { once } from 'lodash';
import { CancellationToken, CodeLens, Command, languages, Position, Range, TextDocument } from 'vscode';
import { CancellationToken, CodeLens, Command, Disposable, languages, Position, Range, TextDocument } from 'vscode';
import { IExtensionSingleActivationService } from '../activation/types';
import { Commands, PYTHON } from '../common/constants';
import { IDisposableRegistry } from '../common/types';
import { IDisposable, IDisposableRegistry } from '../common/types';
import { TensorBoard } from '../common/utils/localize';
import { sendTelemetryEvent } from '../telemetry';
import { EventName } from '../telemetry/constants';
import { TensorBoardEntrypoint, TensorBoardEntrypointTrigger } from './constants';
import { containsTensorBoardImport } from './helpers';
import { useNewTensorboardExtension } from './tensorboarExperiment';
import { TensorboardExperiment } from './tensorboarExperiment';

@injectable()
export class TensorBoardImportCodeLensProvider implements IExtensionSingleActivationService {
Expand All @@ -25,12 +25,24 @@ export class TensorBoardImportCodeLensProvider implements IExtensionSingleActiva
}),
);

constructor(@inject(IDisposableRegistry) private disposables: IDisposableRegistry) {}
private readonly disposables: IDisposable[] = [];

constructor(
@inject(IDisposableRegistry) disposables: IDisposableRegistry,
@inject(TensorboardExperiment) private readonly experiment: TensorboardExperiment,
) {
disposables.push(this);
}

public dispose(): void {
Disposable.from(...this.disposables).dispose();
}

public async activate(): Promise<void> {
if (useNewTensorboardExtension()) {
if (TensorboardExperiment.isTensorboardExtensionInstalled) {
return;
}
this.experiment.disposeOnInstallingTensorboard(this);
this.activateInternal().ignoreErrors();
}

Expand Down
Loading

0 comments on commit 10fad9b

Please sign in to comment.