Skip to content

Changes to IntelliCode and engine downloads #1715

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

Merged
merged 82 commits into from
May 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
a764bc9
Undo changes
Feb 13, 2018
9d1b2cc
Test fixes
Feb 13, 2018
a91291a
Increase timeout
Mar 2, 2018
bf266af
Remove double event listening
Mar 7, 2018
7bc6bd6
Remove test
Mar 7, 2018
8ce8b48
Revert "Remove test"
Mar 7, 2018
e3a549e
Revert "Remove double event listening"
Mar 7, 2018
92e8c1e
#1096 The if statement is automatically formatted incorrectly
Mar 27, 2018
b540a1d
Merge fix
Mar 27, 2018
7b0573e
Add more tests
Mar 27, 2018
facb106
More tests
Mar 27, 2018
f113881
Typo
Mar 27, 2018
3e76718
Test
Mar 28, 2018
6e85dc6
Also better handle multiline arguments
Mar 28, 2018
99e037c
Add a couple missing periods
brettcannon Mar 28, 2018
3caeab7
Undo changes
Feb 13, 2018
eeb1f11
Test fixes
Feb 13, 2018
f5f78c7
Increase timeout
Mar 2, 2018
88744da
Remove double event listening
Mar 7, 2018
65dde44
Remove test
Mar 7, 2018
c513f71
Revert "Remove test"
Mar 7, 2018
ccb3886
Revert "Remove double event listening"
Mar 7, 2018
106f4db
Merge fix
Mar 27, 2018
9e5cb43
Merge branch 'master' of https://github.com/MikhailArkhipov/vscode-py…
Apr 5, 2018
e1da6a6
#1257 On type formatting errors for args and kwargs
Apr 5, 2018
e78f0fb
Handle f-strings
Apr 5, 2018
725cf71
Stop importing from test code
Apr 5, 2018
5cd6d45
#1308 Single line statements leading to an indentation on the next line
Apr 5, 2018
27613db
#726 editing python after inline if statement invalid indent
Apr 5, 2018
8061a20
Undo change
Apr 5, 2018
17dc292
Move constant
Apr 5, 2018
65964b9
Harden LS startup error checks
Apr 10, 2018
4bf5a4c
#1364 Intellisense doesn't work after specific const string
Apr 10, 2018
6f7212c
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Apr 12, 2018
ddbd295
Telemetry for the analysis enging
Apr 12, 2018
ffd1d3f
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Apr 12, 2018
d4afb6c
PR feedback
Apr 13, 2018
12186b8
Fix typo
Apr 16, 2018
ca90529
Test baseline update
Apr 16, 2018
a7267b5
Jedi 0.12
Apr 16, 2018
cfee109
Priority to goto_defition
Apr 16, 2018
1285789
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
Apr 17, 2018
d1ff1d9
News
Apr 17, 2018
1bd1651
Replace unzip
Apr 17, 2018
a69b6fd
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
Apr 17, 2018
f916ace
Linux flavors + test
Apr 18, 2018
28ca25f
Grammar check
Apr 19, 2018
ad9a3c9
Grammar test
Apr 20, 2018
ff8dd35
Test baselines
Apr 20, 2018
26726f8
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
Apr 20, 2018
d7806ca
Add news
Apr 20, 2018
0b3f316
Pin dependency
brettcannon Apr 23, 2018
28a8950
Merge branch 'grammar' of https://github.com/MikhailArkhipov/vscode-p…
Apr 23, 2018
1804617
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
Apr 23, 2018
f000e5d
Specify markdown as preferable format
Apr 26, 2018
a06fd79
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Apr 26, 2018
ef7c5c7
Improve function argument detection
Apr 26, 2018
f4e88c0
Specify markdown
Apr 27, 2018
d420c34
Merge branch 'master' of https://github.com/Microsoft/vscode-python
May 3, 2018
b819d57
Merge branch 'master' into analysis
May 3, 2018
abff213
Pythia setting
May 3, 2018
d140b3a
Baseline updates
May 3, 2018
4b394d9
Baseline update
May 3, 2018
a397b11
Improve startup
May 4, 2018
e54eaf8
Handle missing interpreter better
May 4, 2018
3b8ddd5
Handle interpreter change
May 4, 2018
9a4500d
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
May 4, 2018
41f9624
Delete old file
May 4, 2018
3627b85
Fix LS startup time reporting
May 4, 2018
486d11d
Remove Async suffix from IFileSystem
May 8, 2018
cf5cf9c
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
May 8, 2018
4913e28
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
May 18, 2018
84214e1
Remove Pythia
May 17, 2018
9c1adb1
Remove pre-packaged MSIL
May 18, 2018
5a6e546
Exe name on Unix
May 18, 2018
1f2ae09
Plain linux
May 18, 2018
f972614
Fix casing
May 19, 2018
e0021a9
Merge branch 'analysis' of https://github.com/MikhailArkhipov/vscode-…
May 19, 2018
d2721cd
Fix message
May 19, 2018
b8bc0a2
Merge branch 'analysis' of https://github.com/MikhailArkhipov/vscode-…
May 19, 2018
56d34f7
Update PTVS engine activation steps
May 21, 2018
9aab160
Merge branch 'analysis' of https://github.com/MikhailArkhipov/vscode-…
May 21, 2018
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 CONTRIBUTING - PYTHON_ANALYSIS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Visual Studio 2017:
3. Binaries arrive in *Python/BuildOutput/VsCode/raw*
4. Delete contents of the *analysis* folder in the Python Extension folder
5. Copy *.dll, *.pdb, *.json fron *Python/BuildOutput/VsCode/raw* to *analysis*
6. In VS Code set setting *python.downloadCodeAnalysis* to *false*

### Debugging code in Python Extension to VS Code
Folow regular TypeScript debugging steps
Expand Down
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1232,12 +1232,6 @@
"description": "Whether to install Python modules globally when not using an environment.",
"scope": "resource"
},
"python.pythiaEnabled": {
"type": "boolean",
"default": true,
"description": "Enables AI-driven additions to the completion list. Does not apply to Jedi.",
"scope": "resource"
},
"python.jediEnabled": {
"type": "boolean",
"default": true,
Expand Down
41 changes: 7 additions & 34 deletions src/client/activation/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { IApplicationShell } from '../common/application/types';
import { isTestExecution, STANDARD_OUTPUT_CHANNEL } from '../common/constants';
import { createDeferred, Deferred } from '../common/helpers';
import { IFileSystem, IPlatformService } from '../common/platform/types';
import { IProcessServiceFactory } from '../common/process/types';
import { StopWatch } from '../common/stopWatch';
import { IConfigurationService, IOutputChannel, IPythonSettings } from '../common/types';
import { IEnvironmentVariablesProvider } from '../common/variables/types';
Expand Down Expand Up @@ -103,32 +102,19 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
// Determine if we are running MSIL/Universal via dotnet or self-contained app.
const mscorlib = path.join(context.extensionPath, analysisEngineFolder, 'mscorlib.dll');
const downloader = new AnalysisEngineDownloader(this.services, analysisEngineFolder);
let downloadPackage = false;

const reporter = getTelemetryReporter();
reporter.sendTelemetryEvent(PYTHON_ANALYSIS_ENGINE_ENABLED);

await this.checkPythiaModel(context, downloader);

if (!await this.fs.fileExists(mscorlib)) {
// Depends on .NET Runtime or SDK
const settings = this.configuration.getSettings();
if (!settings.downloadCodeAnalysis) {
// Depends on .NET Runtime or SDK. Typically development-only case.
this.languageClient = this.createSimpleLanguageClient(context, clientOptions);
try {
await this.tryStartLanguageClient(context, this.languageClient);
return true;
} catch (ex) {
if (await this.isDotNetInstalled()) {
this.appShell.showErrorMessage(`.NET Runtime appears to be installed but the language server did not start. Error ${ex}`);
reporter.sendTelemetryEvent(PYTHON_ANALYSIS_ENGINE_ERROR, { error: 'Failed to start (MSIL)' });
return false;
}
// No .NET Runtime, no mscorlib - need to download self-contained package.
downloadPackage = true;
}
await this.tryStartLanguageClient(context, this.languageClient);
return true;
}

if (downloadPackage) {
this.appShell.showWarningMessage('.NET Runtime is not found, platform-specific Python Analysis Engine will be downloaded.');
if (!await this.fs.fileExists(mscorlib)) {
await downloader.downloadAnalysisEngine(context);
reporter.sendTelemetryEvent(PYTHON_ANALYSIS_ENGINE_DOWNLOADED);
}
Expand Down Expand Up @@ -254,22 +240,9 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
maxDocumentationTextLength: 0
},
asyncStartup: true,
pythiaEnabled: settings.pythiaEnabled,
intelliCodeEnabled: settings.intelliCodeEnabled,
testEnvironment: isTestExecution()
}
};
}

private async isDotNetInstalled(): Promise<boolean> {
const ps = await this.services.get<IProcessServiceFactory>(IProcessServiceFactory).create();
const result = await ps.exec('dotnet', ['--version']).catch(() => { return { stdout: '' }; });
return result.stdout.trim().startsWith('2.');
}

private async checkPythiaModel(context: ExtensionContext, downloader: AnalysisEngineDownloader): Promise<void> {
const settings = this.configuration.getSettings();
if (settings.pythiaEnabled) {
await downloader.downloadPythiaModel(context);
}
}
}
8 changes: 1 addition & 7 deletions src/client/activation/analysisEngineHashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,4 @@
export const analysis_engine_win_x86_sha512 = 'win-x86';
export const analysis_engine_win_x64_sha512 = 'win-x64';
export const analysis_engine_osx_x64_sha512 = 'osx-x64';
export const analysis_engine_centos_x64_sha512 = 'centos-x64';
export const analysis_engine_debian_x64_sha512 = 'debian-x64';
export const analysis_engine_fedora_x64_sha512 = 'fedora-x64';
export const analysis_engine_ol_x64_sha512 = 'ol-x64';
export const analysis_engine_opensuse_x64_sha512 = 'opensuse-x64';
export const analysis_engine_rhel_x64_sha512 = 'rhel-x64';
export const analysis_engine_ubuntu_x64_sha512 = 'ubuntu-x64';
export const analysis_engine_linux_x64_sha512 = 'linux-x64';
15 changes: 7 additions & 8 deletions src/client/activation/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { PlatformData } from './platformData';
const StreamZip = require('node-stream-zip');

const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-analysis';
const downloadBaseFileName = 'python-analysis-vscode';
const downloadBaseFileName = 'Python-Analysis-VSCode';
const downloadVersion = '0.1.0';
const downloadFileExtension = '.nupkg';
const pythiaModelName = 'model-sequence.json.gz';
const modelName = 'model-sequence.json.gz';

export class AnalysisEngineDownloader {
private readonly output: OutputChannel;
Expand Down Expand Up @@ -56,16 +56,16 @@ export class AnalysisEngineDownloader {
}
}

public async downloadPythiaModel(context: ExtensionContext): Promise<void> {
public async downloadIntelliCodeModel(context: ExtensionContext): Promise<void> {
const modelFolder = path.join(context.extensionPath, 'analysis', 'Pythia', 'model');
const localPath = path.join(modelFolder, pythiaModelName);
const localPath = path.join(modelFolder, modelName);
if (await this.fs.fileExists(localPath)) {
return;
}

let localTempFilePath = '';
try {
localTempFilePath = await this.downloadFile(downloadUriPrefix, pythiaModelName, 'Downloading IntelliSense Model File... ');
localTempFilePath = await this.downloadFile(downloadUriPrefix, modelName, 'Downloading IntelliCode Model File... ');
await this.fs.createDirectory(modelFolder);
await this.fs.copyFile(localTempFilePath, localPath);
} catch (err) {
Expand Down Expand Up @@ -129,11 +129,10 @@ export class AnalysisEngineDownloader {
if (!await verifier.verifyHash(filePath, platformString, await this.platformData.getExpectedHash())) {
throw new Error('Hash of the downloaded file does not match.');
}
this.output.append('valid.');
this.output.appendLine('valid.');
}

private async unpackArchive(extensionPath: string, tempFilePath: string): Promise<void> {
this.output.appendLine('');
this.output.append('Unpacking archive... ');

const installFolder = path.join(extensionPath, this.engineFolder);
Expand Down Expand Up @@ -170,12 +169,12 @@ export class AnalysisEngineDownloader {
});
return deferred.promise;
});
this.output.append('done.');

// Set file to executable
if (!this.platform.isWindows) {
const executablePath = path.join(installFolder, this.platformData.getEngineExecutableName());
fileSystem.chmodSync(executablePath, '0764'); // -rwxrw-r--
}
this.output.appendLine('done.');
}
}
56 changes: 5 additions & 51 deletions src/client/activation/platformData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,14 @@

import { IFileSystem, IPlatformService } from '../common/platform/types';
import {
analysis_engine_centos_x64_sha512,
analysis_engine_debian_x64_sha512,
analysis_engine_fedora_x64_sha512,
analysis_engine_ol_x64_sha512,
analysis_engine_opensuse_x64_sha512,
analysis_engine_linux_x64_sha512,
analysis_engine_osx_x64_sha512,
analysis_engine_rhel_x64_sha512,
analysis_engine_ubuntu_x64_sha512,
analysis_engine_win_x64_sha512,
analysis_engine_win_x86_sha512
} from './analysisEngineHashes';

// '/etc/os-release', ID=flavor
const supportedLinuxFlavors = [
'centos',
'debian',
'fedora',
'ol',
'opensuse',
'rhel',
'ubuntu'
];

export class PlatformData {
constructor(private platform: IPlatformService, private fs: IFileSystem) { }
constructor(private platform: IPlatformService, fs: IFileSystem) { }
public async getPlatformName(): Promise<string> {
if (this.platform.isWindows) {
return this.platform.is64bit ? 'win-x64' : 'win-x86';
Expand All @@ -39,14 +22,7 @@ export class PlatformData {
if (!this.platform.is64bit) {
throw new Error('Python Analysis Engine does not support 32-bit Linux.');
}
const linuxFlavor = await this.getLinuxFlavor();
if (linuxFlavor.length === 0) {
throw new Error('Unable to determine Linux flavor from /etc/os-release.');
}
if (supportedLinuxFlavors.indexOf(linuxFlavor) < 0) {
throw new Error(`${linuxFlavor} is not supported.`);
}
return `${linuxFlavor}-x64`;
return 'linux-x64';
}
throw new Error('Unknown OS platform.');
}
Expand All @@ -58,7 +34,7 @@ export class PlatformData {
public getEngineExecutableName(): string {
return this.platform.isWindows
? 'Microsoft.PythonTools.VsCode.exe'
: 'Microsoft.PythonTools.VsCode';
: 'Microsoft.PythonTools.VsCode.VsCode';
}

public async getExpectedHash(): Promise<string> {
Expand All @@ -69,30 +45,8 @@ export class PlatformData {
return analysis_engine_osx_x64_sha512;
}
if (this.platform.isLinux && this.platform.is64bit) {
const linuxFlavor = await this.getLinuxFlavor();
// tslint:disable-next-line:switch-default
switch (linuxFlavor) {
case 'centos': return analysis_engine_centos_x64_sha512;
case 'debian': return analysis_engine_debian_x64_sha512;
case 'fedora': return analysis_engine_fedora_x64_sha512;
case 'ol': return analysis_engine_ol_x64_sha512;
case 'opensuse': return analysis_engine_opensuse_x64_sha512;
case 'rhel': return analysis_engine_rhel_x64_sha512;
case 'ubuntu': return analysis_engine_ubuntu_x64_sha512;
}
return analysis_engine_linux_x64_sha512;
}
throw new Error('Unknown platform.');
}

private async getLinuxFlavor(): Promise<string> {
const verFile = '/etc/os-release';
const data = await this.fs.readFile(verFile);
if (data) {
const res = /ID=(.*)/.exec(data);
if (res && res.length > 1) {
return res[1];
}
}
return '';
}
}
6 changes: 4 additions & 2 deletions src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export const IS_WINDOWS = /^win/.test(process.platform);
// tslint:disable-next-line:completed-docs
export class PythonSettings extends EventEmitter implements IPythonSettings {
private static pythonSettings: Map<string, PythonSettings> = new Map<string, PythonSettings>();
public pythiaEnabled = true;
public intelliCodeEnabled = true;
public downloadCodeAnalysis = true;
public jediEnabled = true;
public jediPath = '';
public jediMemoryLimit = 1024;
Expand Down Expand Up @@ -115,6 +116,7 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
this.venvPath = systemVariables.resolveAny(pythonSettings.get<string>('venvPath'))!;
this.venvFolders = systemVariables.resolveAny(pythonSettings.get<string[]>('venvFolders'))!;

this.downloadCodeAnalysis = systemVariables.resolveAny(pythonSettings.get<boolean>('downloadCodeAnalysis', true))!;
this.jediEnabled = systemVariables.resolveAny(pythonSettings.get<boolean>('jediEnabled', true))!;
if (this.jediEnabled) {
// tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion
Expand All @@ -126,7 +128,7 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
}
this.jediMemoryLimit = pythonSettings.get<number>('jediMemoryLimit')!;
} else {
this.pythiaEnabled = systemVariables.resolveAny(pythonSettings.get<boolean>('pythiaEnabled', true))!;
this.intelliCodeEnabled = systemVariables.resolveAny(pythonSettings.get<boolean>('intelliCodeEnabled', true))!;
}

// tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion
Expand Down
3 changes: 2 additions & 1 deletion src/client/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export interface IPythonSettings {
readonly pythonPath: string;
readonly venvPath: string;
readonly venvFolders: string[];
readonly pythiaEnabled: boolean;
readonly intelliCodeEnabled: boolean;

Choose a reason for hiding this comment

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

Don't we need to define these two settings (intelliCodeEnabled and downloadCodeAnalysis ) in package.json?

Copy link
Author

Choose a reason for hiding this comment

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

Not yet. IntelliCode functionality is not public yet and disabling download is for contributors only (or us).

readonly downloadCodeAnalysis: boolean;
readonly jediEnabled: boolean;
readonly jediPath: string;
readonly jediMemoryLimit: number;
Expand Down