mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 01:25:39 -05:00
ML - Bug fixing (#11920)
* Fixed a bug with validating inputs when generating predict script * Fixed the bug with verifying R packages * Fixed the tests * Added warning for when output column data type doesn't match with model output data type * Fix the issue with selecting db
This commit is contained in:
@@ -71,12 +71,10 @@ export class PackageManager {
|
||||
// Only execute the command if there's a valid connection with ml configuration enabled
|
||||
//
|
||||
let connection = await this.getCurrentConnection();
|
||||
let isPythonInstalled = await this._service.isPythonInstalled(connection);
|
||||
let isRInstalled = await this._service.isRInstalled(connection);
|
||||
let defaultProvider: SqlRPackageManageProvider | SqlPythonPackageManageProvider | undefined;
|
||||
if (connection && isPythonInstalled && this._sqlPythonPackagePackageManager.canUseProvider) {
|
||||
if (connection && await this._sqlPythonPackagePackageManager.canUseProvider()) {
|
||||
defaultProvider = this._sqlPythonPackagePackageManager;
|
||||
} else if (connection && isRInstalled && this._sqlRPackageManager.canUseProvider) {
|
||||
} else if (connection && await this._sqlRPackageManager.canUseProvider()) {
|
||||
defaultProvider = this._sqlRPackageManager;
|
||||
}
|
||||
if (connection && defaultProvider) {
|
||||
@@ -119,7 +117,7 @@ export class PackageManager {
|
||||
public async installDependencies(): Promise<void> {
|
||||
await utils.executeTasks(this._apiWrapper, constants.installPackageMngDependenciesMsgTaskName, [
|
||||
this.installRequiredPythonPackages(this._config.requiredSqlPythonPackages),
|
||||
this.installRequiredRPackages()], true);
|
||||
this.installRequiredRPackages()], false);
|
||||
|
||||
await this.verifyOdbcInstalled();
|
||||
}
|
||||
@@ -135,12 +133,30 @@ export class PackageManager {
|
||||
|
||||
await utils.createFolder(utils.getRPackagesFolderPath(this._rootFolder));
|
||||
const packages = this._config.requiredSqlRPackages.filter(p => !p.platform || p.platform === process.platform);
|
||||
let packagesToInstall: PackageConfigModel[] = [];
|
||||
|
||||
// Installs packages in order of listed in the config. The order specifies the dependency of the packages and
|
||||
// packages cannot install as parallel because of the dependency for each other
|
||||
for (let index = 0; index < packages.length; index++) {
|
||||
const packageName = packages[index];
|
||||
await this.installRPackage(packageName);
|
||||
const packageDetail = packages[index];
|
||||
const isInstalled = await this.verifyRPackageInstalled(packageDetail.name);
|
||||
if (!isInstalled) {
|
||||
packagesToInstall.push(packageDetail);
|
||||
}
|
||||
}
|
||||
|
||||
if (packagesToInstall.length > 0) {
|
||||
this._apiWrapper.showInfoMessage(constants.confirmInstallRPackagesDetails(packagesToInstall.map(x => x.name).join(', ')));
|
||||
let confirmed = await utils.promptConfirm(constants.confirmInstallPythonPackages, this._apiWrapper);
|
||||
if (confirmed) {
|
||||
this._outputChannel.appendLine(constants.installDependenciesPackages);
|
||||
// Installs packages in order of listed in the config. The order specifies the dependency of the packages and
|
||||
// packages cannot install as parallel because of the dependency for each other
|
||||
for (let index = 0; index < packagesToInstall.length; index++) {
|
||||
const packageName = packagesToInstall[index];
|
||||
await this.installRPackage(packageName);
|
||||
}
|
||||
} else {
|
||||
throw Error(constants.requiredPackagesNotInstalled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,6 +270,23 @@ export class PackageManager {
|
||||
return await this._processService.executeBufferedCommand(cmd, this._outputChannel);
|
||||
}
|
||||
|
||||
private async verifyRPackageInstalled(packageName: string): Promise<boolean> {
|
||||
let rExecutable = await this.getRExecutable();
|
||||
|
||||
let scripts: string[] = [
|
||||
'formals(quit)$save <- formals(q)$save <- "no"',
|
||||
`library(${packageName})`,
|
||||
'q()'
|
||||
];
|
||||
|
||||
try {
|
||||
await this._processService.execScripts(rExecutable, scripts, ['--vanilla'], undefined);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private async installRPackage(model: PackageConfigModel): Promise<string> {
|
||||
let output = '';
|
||||
let cmd = '';
|
||||
|
||||
Reference in New Issue
Block a user