mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
MLS R package management bug fixing (#8920)
* MLS R package management bug fixing
This commit is contained in:
@@ -38,7 +38,7 @@ export class PackageManager {
|
||||
private _config: Config,
|
||||
private _httpClient: HttpClient) {
|
||||
this._sqlPythonPackagePackageManager = new SqlPythonPackageManageProvider(this._outputChannel, this._apiWrapper, this._queryRunner, this._processService, this._config, this._httpClient);
|
||||
this._sqlRPackageManager = new SqlRPackageManageProvider(this._outputChannel, this._apiWrapper, this._queryRunner, this._processService, this._config);
|
||||
this._sqlRPackageManager = new SqlRPackageManageProvider(this._outputChannel, this._apiWrapper, this._queryRunner, this._processService, this._config, this._httpClient);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +205,7 @@ export class PackageManager {
|
||||
output = await this._processService.executeBufferedCommand(cmd, this._outputChannel);
|
||||
} else if (model.repository) {
|
||||
cmd = `"${this._rExecutable}" -e "install.packages('${model.name}', repos='${model.repository}')"`;
|
||||
output = output + await this._processService.executeBufferedCommand(cmd, this._outputChannel);
|
||||
output = await this._processService.executeBufferedCommand(cmd, this._outputChannel);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import { ApiWrapper } from '../common/apiWrapper';
|
||||
import { ProcessService } from '../common/processService';
|
||||
import { Config } from '../configurations/config';
|
||||
import { SqlPackageManageProviderBase, ScriptMode } from './SqlPackageManageProviderBase';
|
||||
import { HttpClient } from '../common/httpClient';
|
||||
import * as constants from '../common/constants';
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +32,8 @@ export class SqlRPackageManageProvider extends SqlPackageManageProviderBase impl
|
||||
apiWrapper: ApiWrapper,
|
||||
private _queryRunner: QueryRunner,
|
||||
private _processService: ProcessService,
|
||||
private _config: Config) {
|
||||
private _config: Config,
|
||||
private _httpClient: HttpClient) {
|
||||
super(apiWrapper);
|
||||
}
|
||||
|
||||
@@ -73,6 +76,9 @@ export class SqlRPackageManageProvider extends SqlPackageManageProviderBase impl
|
||||
'formals(quit)$save <- formals(q)$save <- "no"',
|
||||
'library(sqlmlutils)',
|
||||
`connection <- connectionInfo(${connectionParts})`,
|
||||
`r = getOption("repos")`,
|
||||
`r["CRAN"] = "${this._config.rPackagesRepository}"`,
|
||||
`options(repos = r)`,
|
||||
`pkgs <- c("${packageDetails.name}")`,
|
||||
`${rCommandScript}(connectionString = connection, pkgs, scope = "PUBLIC")`,
|
||||
'q()'
|
||||
@@ -93,6 +99,10 @@ export class SqlRPackageManageProvider extends SqlPackageManageProviderBase impl
|
||||
return false;
|
||||
}
|
||||
|
||||
private getPackageLink(packageName: string): string {
|
||||
return `${this._config.rPackagesRepository}/web/packages/${packageName}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns package overview for given name
|
||||
* @param packageName Package Name
|
||||
@@ -100,13 +110,11 @@ export class SqlRPackageManageProvider extends SqlPackageManageProviderBase impl
|
||||
protected async fetchPackage(packageName: string): Promise<nbExtensionApis.IPackageOverview> {
|
||||
let packagePreview: nbExtensionApis.IPackageOverview = {
|
||||
name: packageName,
|
||||
versions: [],
|
||||
versions: [constants.latestVersion],
|
||||
summary: ''
|
||||
};
|
||||
let connection = await this.getCurrentConnection();
|
||||
let availablePackages = await this._queryRunner.getRAvailablePackages(connection);
|
||||
let versions = availablePackages.filter(x => x.name === packageName).map(x => x.version);
|
||||
packagePreview.versions = versions;
|
||||
|
||||
await this._httpClient.fetch(this.getPackageLink(packageName));
|
||||
return packagePreview;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user