mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Machine Learning Services R Packages (#8870)
* R Package management in Machine learning services extension
This commit is contained in:
@@ -10,6 +10,8 @@ import * as nbExtensionApis from '../typings/notebookServices';
|
||||
import { ApiWrapper } from './apiWrapper';
|
||||
import * as constants from '../common/constants';
|
||||
|
||||
const maxNumberOfRetries = 3;
|
||||
|
||||
const listPythonPackagesQuery = `
|
||||
EXEC sp_execute_external_script
|
||||
@language=N'Python',
|
||||
@@ -18,6 +20,20 @@ import pandas
|
||||
OutputDataSet = pandas.DataFrame([(d.project_name, d.version) for d in pkg_resources.working_set])'
|
||||
`;
|
||||
|
||||
const listRPackagesQuery = `
|
||||
EXEC sp_execute_external_script
|
||||
@language=N'R',
|
||||
@script=N'
|
||||
OutputDataSet <- as.data.frame(installed.packages()[,c(1,3)])'
|
||||
`;
|
||||
|
||||
const listRAvailablePackagesQuery = `
|
||||
EXEC sp_execute_external_script
|
||||
@language=N'R',
|
||||
@script=N'
|
||||
OutputDataSet <- as.data.frame(installed.packages()[,c(1,3)])'
|
||||
`;
|
||||
|
||||
const checkMlInstalledQuery = `
|
||||
Declare @tablevar table(name NVARCHAR(MAX), min INT, max INT, config_value bit, run_value bit)
|
||||
insert into @tablevar(name, min, max, config_value, run_value) exec sp_configure
|
||||
@@ -57,8 +73,36 @@ export class QueryRunner {
|
||||
* @param connection SQL Connection
|
||||
*/
|
||||
public async getPythonPackages(connection: azdata.connection.ConnectionProfile): Promise<nbExtensionApis.IPackageDetails[]> {
|
||||
return this.getPackages(connection, listPythonPackagesQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns python packages installed in SQL server instance
|
||||
* @param connection SQL Connection
|
||||
*/
|
||||
public async getRPackages(connection: azdata.connection.ConnectionProfile): Promise<nbExtensionApis.IPackageDetails[]> {
|
||||
return this.getPackages(connection, listRPackagesQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns python packages installed in SQL server instance
|
||||
* @param connection SQL Connection
|
||||
*/
|
||||
public async getRAvailablePackages(connection: azdata.connection.ConnectionProfile): Promise<nbExtensionApis.IPackageDetails[]> {
|
||||
return this.getPackages(connection, listRAvailablePackagesQuery);
|
||||
}
|
||||
|
||||
private async getPackages(connection: azdata.connection.ConnectionProfile, script: string): Promise<nbExtensionApis.IPackageDetails[]> {
|
||||
let packages: nbExtensionApis.IPackageDetails[] = [];
|
||||
let result = await this.runQuery(connection, listPythonPackagesQuery);
|
||||
let result: azdata.SimpleExecuteResult | undefined = undefined;
|
||||
|
||||
for (let index = 0; index < maxNumberOfRetries; index++) {
|
||||
result = await this.runQuery(connection, script);
|
||||
if (result && result.rowCount > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result && result.rows.length > 0) {
|
||||
packages = result.rows.map(row => {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user