Machine Learning - Bug fixes (#10377)

* Fixing ML extension bugs
This commit is contained in:
Leila Lali
2020-05-14 12:46:47 -07:00
committed by GitHub
parent d3e1675fc5
commit 0258b1727a
22 changed files with 382 additions and 126 deletions

View File

@@ -45,12 +45,12 @@ export class PackageManager {
public init(): void {
}
private get pythonExecutable(): string {
return this._config.pythonExecutable;
private async getPythonExecutable(): Promise<string> {
return await this._config.getPythonExecutable(true);
}
private get _rExecutable(): string {
return this._config.rExecutable;
private async getRExecutable(): Promise<string> {
return await this._config.getRExecutable(true);
}
/**
* Returns packageManageProviders
@@ -123,7 +123,8 @@ export class PackageManager {
if (!this._config.rEnabled) {
return;
}
if (!this._rExecutable) {
let rExecutable = await this.getRExecutable();
if (!rExecutable) {
throw new Error(constants.rConfigError);
}
@@ -139,7 +140,8 @@ export class PackageManager {
if (!this._config.pythonEnabled) {
return;
}
if (!this.pythonExecutable) {
let pythonExecutable = await this.getPythonExecutable();
if (!pythonExecutable) {
throw new Error(constants.pythonConfigError);
}
if (!requiredPackages || requiredPackages.length === 0) {
@@ -177,7 +179,8 @@ export class PackageManager {
private async getInstalledPipPackages(): Promise<nbExtensionApis.IPackageDetails[]> {
try {
let cmd = `"${this.pythonExecutable}" -m pip list --format=json`;
let pythonExecutable = await this.getPythonExecutable();
let cmd = `"${pythonExecutable}" -m pip list --format=json`;
let packagesInfo = await this._processService.executeBufferedCommand(cmd, undefined);
let packagesResult: nbExtensionApis.IPackageDetails[] = [];
if (packagesInfo && packagesInfo.indexOf(']') > 0) {
@@ -196,23 +199,25 @@ export class PackageManager {
}
private async installPipPackage(requirementFilePath: string): Promise<string> {
let cmd = `"${this.pythonExecutable}" -m pip install -r "${requirementFilePath}"`;
let pythonExecutable = await this.getPythonExecutable();
let cmd = `"${pythonExecutable}" -m pip install -r "${requirementFilePath}"`;
return await this._processService.executeBufferedCommand(cmd, this._outputChannel);
}
private async installRPackage(model: PackageConfigModel): Promise<string> {
let output = '';
let cmd = '';
let rExecutable = await this.getRExecutable();
if (model.downloadUrl) {
const packageFile = utils.getPackageFilePath(this._rootFolder, model.fileName || model.name);
const packageExist = await utils.exists(packageFile);
if (!packageExist) {
await this._httpClient.download(model.downloadUrl, packageFile, this._outputChannel);
}
cmd = `"${this._rExecutable}" CMD INSTALL ${packageFile}`;
cmd = `"${rExecutable}" CMD INSTALL ${packageFile}`;
output = await this._processService.executeBufferedCommand(cmd, this._outputChannel);
} else if (model.repository) {
cmd = `"${this._rExecutable}" -e "install.packages('${model.name}', repos='${model.repository}')"`;
cmd = `"${rExecutable}" -e "install.packages('${model.name}', repos='${model.repository}')"`;
output = await this._processService.executeBufferedCommand(cmd, this._outputChannel);
}
return output;

View File

@@ -84,7 +84,7 @@ export class SqlPythonPackageManageProvider extends SqlPackageManageProviderBase
'pkgmanager = sqlmlutils.SQLPackageManager(connection)',
pythonCommandScript
];
let pythonExecutable = this._config.pythonExecutable;
let pythonExecutable = await this._config.getPythonExecutable(true);
await this._processService.execScripts(pythonExecutable, scripts, [], this._outputChannel);
}
}

View File

@@ -83,7 +83,7 @@ export class SqlRPackageManageProvider extends SqlPackageManageProviderBase impl
`${rCommandScript}(connectionString = connection, pkgs, scope = "PUBLIC")`,
'q()'
];
let rExecutable = this._config.rExecutable;
let rExecutable = await this._config.getRExecutable(true);
await this._processService.execScripts(`${rExecutable}`, scripts, ['--vanilla'], this._outputChannel);
}
}