mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Machine Learning Services R Packages (#8870)
* R Package management in Machine learning services extension
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"requiredPythonPackages": [
|
||||
{ "name": "pymssql", "version": "2.1.4" },
|
||||
{ "name": "sqlmlutils", "version": ""}
|
||||
],
|
||||
|
||||
"requiredRPackages": [
|
||||
{ "name": "RODBCext", "repository": "https://cran.microsoft.com" },
|
||||
{ "name": "sqlmlutils", "fileName": "sqlmlutils_0.7.1.zip", "downloadUrl": "https://github.com/microsoft/sqlmlutils/blob/master/R/dist/sqlmlutils_0.7.1.zip?raw=true"}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { ApiWrapper } from '../common/apiWrapper';
|
||||
import * as constants from '../common/constants';
|
||||
import { promises as fs } from 'fs';
|
||||
import * as path from 'path';
|
||||
import { PackageConfigModel } from './packageConfigModel';
|
||||
|
||||
const configFileName = 'config.json';
|
||||
const defaultPythonExecutable = 'python';
|
||||
const defaultRExecutable = 'r';
|
||||
|
||||
|
||||
/**
|
||||
* Extension Configuration from app settings
|
||||
*/
|
||||
export class Config {
|
||||
|
||||
private _configValues: any;
|
||||
private _mlsConfig: vscode.WorkspaceConfiguration | undefined;
|
||||
|
||||
constructor(private _root: string, private _apiWrapper: ApiWrapper) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the config values
|
||||
*/
|
||||
public async load(): Promise<void> {
|
||||
const rawConfig = await fs.readFile(path.join(this._root, 'src', 'configurations', configFileName));
|
||||
this._configValues = JSON.parse(rawConfig.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the config value of required python packages
|
||||
*/
|
||||
public get requiredPythonPackages(): PackageConfigModel[] {
|
||||
return this._configValues.requiredPythonPackages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the config value of required r packages
|
||||
*/
|
||||
public get requiredRPackages(): PackageConfigModel[] {
|
||||
return this._configValues.requiredRPackages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns python path from user settings
|
||||
*/
|
||||
public get pythonExecutable(): string {
|
||||
return this.config.get(constants.pythonPathConfigKey) || defaultPythonExecutable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns r path from user settings
|
||||
*/
|
||||
public get rExecutable(): string {
|
||||
return this.config.get(constants.rPathConfigKey) || defaultRExecutable;
|
||||
}
|
||||
|
||||
private get config(): vscode.WorkspaceConfiguration {
|
||||
if (!this._mlsConfig) {
|
||||
this._mlsConfig = this._apiWrapper.getConfiguration(constants.mlsConfigKey);
|
||||
}
|
||||
return this._mlsConfig;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The model for package config value
|
||||
*/
|
||||
export interface PackageConfigModel {
|
||||
|
||||
/**
|
||||
* Package name
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Package version
|
||||
*/
|
||||
version?: string;
|
||||
|
||||
/**
|
||||
* Package repository
|
||||
*/
|
||||
repository?: string;
|
||||
|
||||
/**
|
||||
* Package download url
|
||||
*/
|
||||
downloadUrl?: string;
|
||||
|
||||
/**
|
||||
* Package file name if package has download url
|
||||
*/
|
||||
fileName?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user