mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 18:46:34 -05:00
ML - dashboard icons and links (#10153)
* ML - dashboard icons and links
This commit is contained in:
@@ -0,0 +1,202 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as should from 'should';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import 'mocha';
|
||||
import { createContext } from './utils';
|
||||
import { ImportedModel, ModelParameters } from '../../../modelManagement/interfaces';
|
||||
import { azureResource } from '../../../typings/azure-resource';
|
||||
import { Workspace } from '@azure/arm-machinelearningservices/esm/models';
|
||||
import { WorkspaceModel } from '../../../modelManagement/interfaces';
|
||||
import { ModelManagementController } from '../../../views/models/modelManagementController';
|
||||
import { DatabaseTable, TableColumn } from '../../../prediction/interfaces';
|
||||
import { DeleteModelEventName, UpdateModelEventName } from '../../../views/models/modelViewBase';
|
||||
import { EditModelDialog } from '../../../views/models/manageModels/editModelDialog';
|
||||
|
||||
const accounts: azdata.Account[] = [
|
||||
{
|
||||
key: {
|
||||
accountId: '1',
|
||||
providerId: ''
|
||||
},
|
||||
displayInfo: {
|
||||
displayName: 'account',
|
||||
userId: '',
|
||||
accountType: '',
|
||||
contextualDisplayName: ''
|
||||
},
|
||||
isStale: false,
|
||||
properties: []
|
||||
}
|
||||
];
|
||||
const subscriptions: azureResource.AzureResourceSubscription[] = [
|
||||
{
|
||||
name: 'subscription',
|
||||
id: '2'
|
||||
}
|
||||
];
|
||||
const groups: azureResource.AzureResourceResourceGroup[] = [
|
||||
{
|
||||
name: 'group',
|
||||
id: '3'
|
||||
}
|
||||
];
|
||||
const workspaces: Workspace[] = [
|
||||
{
|
||||
name: 'workspace',
|
||||
id: '4'
|
||||
}
|
||||
];
|
||||
const models: WorkspaceModel[] = [
|
||||
{
|
||||
id: '5',
|
||||
name: 'model'
|
||||
}
|
||||
];
|
||||
const localModels: ImportedModel[] = [
|
||||
{
|
||||
id: 1,
|
||||
modelName: 'model',
|
||||
table: {
|
||||
databaseName: 'db',
|
||||
tableName: 'tb',
|
||||
schema: 'dbo'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
const dbNames: string[] = [
|
||||
'db1',
|
||||
'db2'
|
||||
];
|
||||
const tableNames: DatabaseTable[] = [
|
||||
{
|
||||
databaseName: 'db1',
|
||||
schema: 'dbo',
|
||||
tableName: 'tb1'
|
||||
},
|
||||
{
|
||||
databaseName: 'db1',
|
||||
tableName: 'tb2',
|
||||
schema: 'dbo'
|
||||
}
|
||||
];
|
||||
const columnNames: TableColumn[] = [
|
||||
{
|
||||
columnName: 'c1',
|
||||
dataType: 'int'
|
||||
},
|
||||
{
|
||||
columnName: 'c2',
|
||||
dataType: 'varchar'
|
||||
}
|
||||
];
|
||||
const modelParameters: ModelParameters = {
|
||||
inputs: [
|
||||
{
|
||||
'name': 'p1',
|
||||
'type': 'int'
|
||||
},
|
||||
{
|
||||
'name': 'p2',
|
||||
'type': 'varchar'
|
||||
}
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
'name': 'o1',
|
||||
'type': 'int'
|
||||
}
|
||||
]
|
||||
};
|
||||
describe('Model Controller', () => {
|
||||
|
||||
it('Should open deploy model wizard successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
|
||||
|
||||
let controller = new ModelManagementController(testContext.apiWrapper.object, '', testContext.azureModelService.object, testContext.deployModelService.object, testContext.predictService.object);
|
||||
testContext.deployModelService.setup(x => x.getRecentImportTable()).returns(() => Promise.resolve({
|
||||
databaseName: 'db',
|
||||
tableName: 'table',
|
||||
schema: 'dbo'
|
||||
}));
|
||||
testContext.deployModelService.setup(x => x.getDeployedModels(TypeMoq.It.isAny())).returns(() => Promise.resolve(localModels));
|
||||
testContext.predictService.setup(x => x.getDatabaseList()).returns(() => Promise.resolve(dbNames));
|
||||
testContext.predictService.setup(x => x.getTableList(TypeMoq.It.isAny())).returns(() => Promise.resolve(tableNames));
|
||||
testContext.azureModelService.setup(x => x.getAccounts()).returns(() => Promise.resolve(accounts));
|
||||
testContext.azureModelService.setup(x => x.getSubscriptions(TypeMoq.It.isAny())).returns(() => Promise.resolve(subscriptions));
|
||||
testContext.azureModelService.setup(x => x.getGroups(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(groups));
|
||||
testContext.azureModelService.setup(x => x.getWorkspaces(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(workspaces));
|
||||
testContext.azureModelService.setup(x => x.getModels(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(models));
|
||||
|
||||
const view = await controller.registerModel(undefined);
|
||||
should.notEqual(view, undefined);
|
||||
});
|
||||
|
||||
it('Should open predict wizard successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
|
||||
|
||||
let controller = new ModelManagementController(testContext.apiWrapper.object, '', testContext.azureModelService.object, testContext.deployModelService.object, testContext.predictService.object);
|
||||
testContext.deployModelService.setup(x => x.getRecentImportTable()).returns(() => Promise.resolve({
|
||||
databaseName: 'db',
|
||||
tableName: 'table',
|
||||
schema: 'dbo'
|
||||
}));
|
||||
testContext.deployModelService.setup(x => x.getDeployedModels(TypeMoq.It.isAny())).returns(() => Promise.resolve(localModels));
|
||||
testContext.predictService.setup(x => x.getDatabaseList()).returns(() => Promise.resolve([
|
||||
'db', 'db1'
|
||||
]));
|
||||
testContext.predictService.setup(x => x.getTableList(TypeMoq.It.isAny())).returns(() => Promise.resolve([
|
||||
{ tableName: 'tb', databaseName: 'db', schema: 'dbo' }
|
||||
]));
|
||||
testContext.azureModelService.setup(x => x.getAccounts()).returns(() => Promise.resolve(accounts));
|
||||
testContext.azureModelService.setup(x => x.getSubscriptions(TypeMoq.It.isAny())).returns(() => Promise.resolve(subscriptions));
|
||||
testContext.azureModelService.setup(x => x.getGroups(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(groups));
|
||||
testContext.azureModelService.setup(x => x.getWorkspaces(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(workspaces));
|
||||
testContext.azureModelService.setup(x => x.getModels(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(models));
|
||||
testContext.predictService.setup(x => x.getTableColumnsList(TypeMoq.It.isAny())).returns(() => Promise.resolve(columnNames));
|
||||
testContext.deployModelService.setup(x => x.loadModelParameters(TypeMoq.It.isAny())).returns(() => Promise.resolve(modelParameters));
|
||||
testContext.azureModelService.setup(x => x.downloadModel(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('file'));
|
||||
testContext.deployModelService.setup(x => x.downloadModel(TypeMoq.It.isAny())).returns(() => Promise.resolve('file'));
|
||||
|
||||
const view = await controller.predictModel();
|
||||
should.notEqual(view, undefined);
|
||||
});
|
||||
|
||||
it('Should open edit model dialog successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
testContext.deployModelService.setup(x => x.updateModel(TypeMoq.It.isAny())).returns(() => Promise.resolve());
|
||||
testContext.deployModelService.setup(x => x.deleteModel(TypeMoq.It.isAny())).returns(() => Promise.resolve());
|
||||
|
||||
let controller = new ModelManagementController(testContext.apiWrapper.object, '', testContext.azureModelService.object, testContext.deployModelService.object, testContext.predictService.object);
|
||||
const model: ImportedModel =
|
||||
{
|
||||
id: 1,
|
||||
modelName: 'name1',
|
||||
description: 'desc1',
|
||||
created: '2018-01-01',
|
||||
version: '1.1',
|
||||
table: {
|
||||
databaseName: 'db',
|
||||
tableName: 'tb',
|
||||
schema: 'dbo'
|
||||
}
|
||||
};
|
||||
const view = <EditModelDialog>await controller.editModel(model);
|
||||
should.notEqual(view?.editModelPage, undefined);
|
||||
if (view.editModelPage) {
|
||||
view.editModelPage.sendRequest(UpdateModelEventName, model);
|
||||
view.editModelPage.sendRequest(DeleteModelEventName, model);
|
||||
}
|
||||
testContext.deployModelService.verify(x => x.updateModel(model), TypeMoq.Times.atLeastOnce());
|
||||
testContext.deployModelService.verify(x => x.deleteModel(model), TypeMoq.Times.atLeastOnce());
|
||||
|
||||
should.notEqual(view, undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,102 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as should from 'should';
|
||||
import 'mocha';
|
||||
import { createContext, ParentDialog } from './utils';
|
||||
import { AzureModelsComponent } from '../../../views/models/azureModelsComponent';
|
||||
import { ListAccountsEventName, ListSubscriptionsEventName, ListGroupsEventName, ListWorkspacesEventName, ListAzureModelsEventName } from '../../../views/models/modelViewBase';
|
||||
import { azureResource } from '../../../typings/azure-resource';
|
||||
import { Workspace } from '@azure/arm-machinelearningservices/esm/models';
|
||||
import { ViewBase } from '../../../views/viewBase';
|
||||
import { WorkspaceModel } from '../../../modelManagement/interfaces';
|
||||
|
||||
describe('Azure Models Component', () => {
|
||||
it('Should create view components successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
let parent = new ParentDialog(testContext.apiWrapper.object);
|
||||
|
||||
let view = new AzureModelsComponent(testContext.apiWrapper.object, parent);
|
||||
view.registerComponent(testContext.view.modelBuilder);
|
||||
should.notEqual(view.component, undefined);
|
||||
});
|
||||
|
||||
it('Should load data successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
let parent = new ParentDialog(testContext.apiWrapper.object);
|
||||
|
||||
let view = new AzureModelsComponent(testContext.apiWrapper.object, parent, false);
|
||||
view.registerComponent(testContext.view.modelBuilder);
|
||||
|
||||
let accounts: azdata.Account[] = [
|
||||
{
|
||||
key: {
|
||||
accountId: '1',
|
||||
providerId: ''
|
||||
},
|
||||
displayInfo: {
|
||||
displayName: 'account',
|
||||
userId: '',
|
||||
accountType: '',
|
||||
contextualDisplayName: ''
|
||||
},
|
||||
isStale: false,
|
||||
properties: []
|
||||
}
|
||||
];
|
||||
let subscriptions: azureResource.AzureResourceSubscription[] = [
|
||||
{
|
||||
name: 'subscription',
|
||||
id: '2'
|
||||
}
|
||||
];
|
||||
let groups: azureResource.AzureResourceResourceGroup[] = [
|
||||
{
|
||||
name: 'group',
|
||||
id: '3'
|
||||
}
|
||||
];
|
||||
let workspaces: Workspace[] = [
|
||||
{
|
||||
name: 'workspace',
|
||||
id: '4'
|
||||
}
|
||||
];
|
||||
let models: WorkspaceModel[] = [
|
||||
{
|
||||
id: '5',
|
||||
name: 'model'
|
||||
}
|
||||
];
|
||||
parent.on(ListAccountsEventName, () => {
|
||||
parent.sendCallbackRequest(ViewBase.getCallbackEventName(ListAccountsEventName), { data: accounts });
|
||||
});
|
||||
parent.on(ListSubscriptionsEventName, () => {
|
||||
|
||||
parent.sendCallbackRequest(ViewBase.getCallbackEventName(ListSubscriptionsEventName), { data: subscriptions });
|
||||
});
|
||||
parent.on(ListGroupsEventName, () => {
|
||||
parent.sendCallbackRequest(ViewBase.getCallbackEventName(ListGroupsEventName), { data: groups });
|
||||
});
|
||||
parent.on(ListWorkspacesEventName, () => {
|
||||
parent.sendCallbackRequest(ViewBase.getCallbackEventName(ListWorkspacesEventName), { data: workspaces });
|
||||
});
|
||||
parent.on(ListAzureModelsEventName, () => {
|
||||
parent.sendCallbackRequest(ViewBase.getCallbackEventName(ListAzureModelsEventName), { data: models });
|
||||
});
|
||||
await view.refresh();
|
||||
testContext.onClick.fire(true);
|
||||
should.notEqual(view.data, undefined);
|
||||
should.equal(view.data?.length, 1);
|
||||
if (view.data) {
|
||||
should.deepEqual(view.data[0].account, accounts[0]);
|
||||
should.deepEqual(view.data[0].subscription, subscriptions[0]);
|
||||
should.deepEqual(view.data[0].group, groups[0]);
|
||||
should.deepEqual(view.data[0].workspace, workspaces[0]);
|
||||
should.deepEqual(view.data[0].model, models[0]);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as should from 'should';
|
||||
import 'mocha';
|
||||
import { createContext } from './utils';
|
||||
import { ImportedModel } from '../../../modelManagement/interfaces';
|
||||
import { EditModelDialog } from '../../../views/models/manageModels/editModelDialog';
|
||||
|
||||
describe('Edit Model Dialog', () => {
|
||||
it('Should create view components successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
const model: ImportedModel =
|
||||
{
|
||||
id: 1,
|
||||
modelName: 'name1',
|
||||
description: 'desc1',
|
||||
created: '2018-01-01',
|
||||
version: '1.1',
|
||||
table: {
|
||||
databaseName: 'db',
|
||||
tableName: 'tb',
|
||||
schema: 'dbo'
|
||||
}
|
||||
};
|
||||
let view = new EditModelDialog(testContext.apiWrapper.object, '', undefined, model);
|
||||
view.open();
|
||||
|
||||
should.notEqual(view.dialogView, undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,203 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as should from 'should';
|
||||
import 'mocha';
|
||||
import { createContext } from './utils';
|
||||
import {
|
||||
ListModelsEventName, ListAccountsEventName, ListSubscriptionsEventName, ListGroupsEventName, ListWorkspacesEventName,
|
||||
ListAzureModelsEventName, ListDatabaseNamesEventName, ListTableNamesEventName, ListColumnNamesEventName, LoadModelParametersEventName, DownloadAzureModelEventName, DownloadRegisteredModelEventName, ModelSourceType
|
||||
}
|
||||
from '../../../views/models/modelViewBase';
|
||||
import { ImportedModel, ModelParameters } from '../../../modelManagement/interfaces';
|
||||
import { azureResource } from '../../../typings/azure-resource';
|
||||
import { Workspace } from '@azure/arm-machinelearningservices/esm/models';
|
||||
import { ViewBase } from '../../../views/viewBase';
|
||||
import { WorkspaceModel } from '../../../modelManagement/interfaces';
|
||||
import { PredictWizard } from '../../../views/models/prediction/predictWizard';
|
||||
import { DatabaseTable, TableColumn } from '../../../prediction/interfaces';
|
||||
|
||||
describe('Predict Wizard', () => {
|
||||
it('Should create view components successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
|
||||
let view = new PredictWizard(testContext.apiWrapper.object, '');
|
||||
await view.open();
|
||||
should.notEqual(view.wizardView, undefined);
|
||||
should.notEqual(view.modelSourcePage, undefined);
|
||||
});
|
||||
|
||||
it('Should load data successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
|
||||
let view = new PredictWizard(testContext.apiWrapper.object, '');
|
||||
view.importTable = {
|
||||
databaseName: 'db',
|
||||
tableName: 'tb',
|
||||
schema: 'dbo'
|
||||
};
|
||||
await view.open();
|
||||
let accounts: azdata.Account[] = [
|
||||
{
|
||||
key: {
|
||||
accountId: '1',
|
||||
providerId: ''
|
||||
},
|
||||
displayInfo: {
|
||||
displayName: 'account',
|
||||
userId: '',
|
||||
accountType: '',
|
||||
contextualDisplayName: ''
|
||||
},
|
||||
isStale: false,
|
||||
properties: []
|
||||
}
|
||||
];
|
||||
let subscriptions: azureResource.AzureResourceSubscription[] = [
|
||||
{
|
||||
name: 'subscription',
|
||||
id: '2'
|
||||
}
|
||||
];
|
||||
let groups: azureResource.AzureResourceResourceGroup[] = [
|
||||
{
|
||||
name: 'group',
|
||||
id: '3'
|
||||
}
|
||||
];
|
||||
let workspaces: Workspace[] = [
|
||||
{
|
||||
name: 'workspace',
|
||||
id: '4'
|
||||
}
|
||||
];
|
||||
let models: WorkspaceModel[] = [
|
||||
{
|
||||
id: '5',
|
||||
name: 'model'
|
||||
}
|
||||
];
|
||||
let localModels: ImportedModel[] = [
|
||||
{
|
||||
id: 1,
|
||||
modelName: 'model',
|
||||
table: {
|
||||
databaseName: 'db',
|
||||
tableName: 'tb',
|
||||
schema: 'dbo'
|
||||
}
|
||||
}
|
||||
];
|
||||
const dbNames: string[] = [
|
||||
'db1',
|
||||
'db2'
|
||||
];
|
||||
const tableNames: DatabaseTable[] = [
|
||||
{
|
||||
databaseName: 'db1',
|
||||
schema: 'dbo',
|
||||
tableName: 'tb1'
|
||||
},
|
||||
{
|
||||
databaseName: 'db1',
|
||||
tableName: 'tb2',
|
||||
schema: 'dbo'
|
||||
}
|
||||
];
|
||||
const columnNames: TableColumn[] = [
|
||||
{
|
||||
columnName: 'c1',
|
||||
dataType: 'int'
|
||||
},
|
||||
{
|
||||
columnName: 'c2',
|
||||
dataType: 'varchar'
|
||||
}
|
||||
];
|
||||
const modelParameters: ModelParameters = {
|
||||
inputs: [
|
||||
{
|
||||
'name': 'p1',
|
||||
'type': 'int'
|
||||
},
|
||||
{
|
||||
'name': 'p2',
|
||||
'type': 'varchar'
|
||||
}
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
'name': 'o1',
|
||||
'type': 'int'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
view.on(ListModelsEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListModelsEventName), { data: localModels });
|
||||
});
|
||||
view.on(ListAccountsEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListAccountsEventName), { data: accounts });
|
||||
});
|
||||
view.on(ListSubscriptionsEventName, () => {
|
||||
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListSubscriptionsEventName), { data: subscriptions });
|
||||
});
|
||||
view.on(ListGroupsEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListGroupsEventName), { data: groups });
|
||||
});
|
||||
view.on(ListWorkspacesEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListWorkspacesEventName), { data: workspaces });
|
||||
});
|
||||
view.on(ListAzureModelsEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListAzureModelsEventName), { data: models });
|
||||
});
|
||||
view.on(ListDatabaseNamesEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListDatabaseNamesEventName), { data: dbNames });
|
||||
});
|
||||
view.on(ListTableNamesEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListTableNamesEventName), { data: tableNames });
|
||||
});
|
||||
view.on(ListColumnNamesEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListColumnNamesEventName), { data: columnNames });
|
||||
});
|
||||
view.on(LoadModelParametersEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(LoadModelParametersEventName), { data: modelParameters });
|
||||
});
|
||||
view.on(DownloadAzureModelEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(DownloadAzureModelEventName), { data: 'path' });
|
||||
});
|
||||
view.on(DownloadRegisteredModelEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(DownloadRegisteredModelEventName), { data: 'path' });
|
||||
});
|
||||
if (view.modelBrowsePage) {
|
||||
view.modelBrowsePage.modelSourceType = ModelSourceType.Azure;
|
||||
}
|
||||
await view.refresh();
|
||||
should.notEqual(view.azureModelsComponent?.data, undefined);
|
||||
|
||||
if (view.modelBrowsePage) {
|
||||
view.modelBrowsePage.modelSourceType = ModelSourceType.RegisteredModels;
|
||||
}
|
||||
await view.refresh();
|
||||
testContext.onClick.fire(undefined);
|
||||
|
||||
should.equal(view.modelSourcePage?.data, ModelSourceType.RegisteredModels);
|
||||
should.notEqual(view.localModelsComponent?.data, undefined);
|
||||
should.notEqual(view.modelBrowsePage?.registeredModelsComponent?.data, undefined);
|
||||
if (view.modelBrowsePage?.registeredModelsComponent?.data) {
|
||||
should.equal(view.modelBrowsePage.registeredModelsComponent.data.length, 1);
|
||||
}
|
||||
|
||||
|
||||
should.notEqual(await view.getModelFileName(), undefined);
|
||||
await view.columnsSelectionPage?.onEnter();
|
||||
|
||||
should.notEqual(view.columnsSelectionPage?.data, undefined);
|
||||
should.equal(view.columnsSelectionPage?.data?.inputColumns?.length, modelParameters.inputs.length, modelParameters.inputs[0].name);
|
||||
should.equal(view.columnsSelectionPage?.data?.outputColumns?.length, modelParameters.outputs.length);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,131 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as should from 'should';
|
||||
import 'mocha';
|
||||
import { createContext } from './utils';
|
||||
import { ListModelsEventName, ListAccountsEventName, ListSubscriptionsEventName, ListGroupsEventName, ListWorkspacesEventName, ListAzureModelsEventName, ModelSourceType, ListDatabaseNamesEventName, ListTableNamesEventName } from '../../../views/models/modelViewBase';
|
||||
import { ImportedModel } from '../../../modelManagement/interfaces';
|
||||
import { azureResource } from '../../../typings/azure-resource';
|
||||
import { Workspace } from '@azure/arm-machinelearningservices/esm/models';
|
||||
import { ViewBase } from '../../../views/viewBase';
|
||||
import { WorkspaceModel } from '../../../modelManagement/interfaces';
|
||||
import { ImportModelWizard } from '../../../views/models/manageModels/importModelWizard';
|
||||
|
||||
describe('Register Model Wizard', () => {
|
||||
it('Should create view components successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
|
||||
let view = new ImportModelWizard(testContext.apiWrapper.object, '');
|
||||
view.importTable = {
|
||||
databaseName: 'db',
|
||||
tableName: 'table',
|
||||
schema: 'dbo'
|
||||
};
|
||||
await view.open();
|
||||
should.notEqual(view.wizardView, undefined);
|
||||
should.notEqual(view.modelSourcePage, undefined);
|
||||
});
|
||||
|
||||
it('Should load data successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
|
||||
let view = new ImportModelWizard(testContext.apiWrapper.object, '');
|
||||
view.importTable = {
|
||||
databaseName: 'db',
|
||||
tableName: 'tb',
|
||||
schema: 'dbo'
|
||||
};
|
||||
await view.open();
|
||||
let accounts: azdata.Account[] = [
|
||||
{
|
||||
key: {
|
||||
accountId: '1',
|
||||
providerId: ''
|
||||
},
|
||||
displayInfo: {
|
||||
displayName: 'account',
|
||||
userId: '',
|
||||
accountType: '',
|
||||
contextualDisplayName: ''
|
||||
},
|
||||
isStale: false,
|
||||
properties: []
|
||||
}
|
||||
];
|
||||
let subscriptions: azureResource.AzureResourceSubscription[] = [
|
||||
{
|
||||
name: 'subscription',
|
||||
id: '2'
|
||||
}
|
||||
];
|
||||
let groups: azureResource.AzureResourceResourceGroup[] = [
|
||||
{
|
||||
name: 'group',
|
||||
id: '3'
|
||||
}
|
||||
];
|
||||
let workspaces: Workspace[] = [
|
||||
{
|
||||
name: 'workspace',
|
||||
id: '4'
|
||||
}
|
||||
];
|
||||
let models: WorkspaceModel[] = [
|
||||
{
|
||||
id: '5',
|
||||
name: 'model'
|
||||
}
|
||||
];
|
||||
let localModels: ImportedModel[] = [
|
||||
{
|
||||
id: 1,
|
||||
modelName: 'model',
|
||||
table: {
|
||||
databaseName: 'db',
|
||||
tableName: 'tb',
|
||||
schema: 'dbo'
|
||||
}
|
||||
}
|
||||
];
|
||||
view.on(ListModelsEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListModelsEventName), { data: localModels });
|
||||
});
|
||||
view.on(ListDatabaseNamesEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListDatabaseNamesEventName), { data: [
|
||||
'db', 'db1'
|
||||
] });
|
||||
});
|
||||
view.on(ListTableNamesEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListTableNamesEventName), { data: [
|
||||
'tb', 'tb1'
|
||||
] });
|
||||
});
|
||||
view.on(ListAccountsEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListAccountsEventName), { data: accounts });
|
||||
});
|
||||
view.on(ListSubscriptionsEventName, () => {
|
||||
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListSubscriptionsEventName), { data: subscriptions });
|
||||
});
|
||||
view.on(ListGroupsEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListGroupsEventName), { data: groups });
|
||||
});
|
||||
view.on(ListWorkspacesEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListWorkspacesEventName), { data: workspaces });
|
||||
});
|
||||
view.on(ListAzureModelsEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListAzureModelsEventName), { data: models });
|
||||
});
|
||||
|
||||
if (view.modelBrowsePage) {
|
||||
view.modelBrowsePage.modelSourceType = ModelSourceType.Azure;
|
||||
}
|
||||
await view.refresh();
|
||||
should.notEqual(view.azureModelsComponent?.data ,undefined);
|
||||
should.notEqual(view.localModelsComponent?.data, undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as should from 'should';
|
||||
import 'mocha';
|
||||
import { createContext } from './utils';
|
||||
import { ManageModelsDialog } from '../../../views/models/manageModels/manageModelsDialog';
|
||||
import { ListModelsEventName } from '../../../views/models/modelViewBase';
|
||||
import { ImportedModel } from '../../../modelManagement/interfaces';
|
||||
import { ViewBase } from '../../../views/viewBase';
|
||||
|
||||
describe('Registered Models Dialog', () => {
|
||||
it('Should create view components successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
|
||||
let view = new ManageModelsDialog(testContext.apiWrapper.object, '');
|
||||
view.open();
|
||||
|
||||
should.notEqual(view.dialogView, undefined);
|
||||
should.notEqual(view.currentLanguagesTab, undefined);
|
||||
});
|
||||
|
||||
it('Should load data successfully ', async function (): Promise<void> {
|
||||
let testContext = createContext();
|
||||
|
||||
let view = new ManageModelsDialog(testContext.apiWrapper.object, '');
|
||||
view.open();
|
||||
let models: ImportedModel[] = [
|
||||
{
|
||||
id: 1,
|
||||
modelName: 'model',
|
||||
table: {
|
||||
databaseName: 'db',
|
||||
tableName: 'tb',
|
||||
schema: 'dbo'
|
||||
}
|
||||
}
|
||||
];
|
||||
view.on(ListModelsEventName, () => {
|
||||
view.sendCallbackRequest(ViewBase.getCallbackEventName(ListModelsEventName), { data: models });
|
||||
});
|
||||
await view.refresh();
|
||||
});
|
||||
});
|
||||
50
extensions/machine-learning/src/test/views/models/utils.ts
Normal file
50
extensions/machine-learning/src/test/views/models/utils.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { ApiWrapper } from '../../../common/apiWrapper';
|
||||
import { createViewContext } from '../utils';
|
||||
import { ModelViewBase } from '../../../views/models/modelViewBase';
|
||||
import { AzureModelRegistryService } from '../../../modelManagement/azureModelRegistryService';
|
||||
import { DeployedModelService } from '../../../modelManagement/deployedModelService';
|
||||
import { PredictService } from '../../../prediction/predictService';
|
||||
|
||||
export interface TestContext {
|
||||
apiWrapper: TypeMoq.IMock<ApiWrapper>;
|
||||
view: azdata.ModelView;
|
||||
onClick: vscode.EventEmitter<any>;
|
||||
azureModelService: TypeMoq.IMock<AzureModelRegistryService>;
|
||||
deployModelService: TypeMoq.IMock<DeployedModelService>;
|
||||
predictService: TypeMoq.IMock<PredictService>;
|
||||
}
|
||||
|
||||
export class ParentDialog extends ModelViewBase {
|
||||
public refresh(): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
public reset(): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
constructor(
|
||||
apiWrapper: ApiWrapper) {
|
||||
super(apiWrapper, '');
|
||||
}
|
||||
}
|
||||
|
||||
export function createContext(): TestContext {
|
||||
|
||||
let viewTestContext = createViewContext();
|
||||
|
||||
return {
|
||||
apiWrapper: viewTestContext.apiWrapper,
|
||||
view: viewTestContext.view,
|
||||
onClick: viewTestContext.onClick,
|
||||
azureModelService: TypeMoq.Mock.ofType(AzureModelRegistryService),
|
||||
deployModelService: TypeMoq.Mock.ofType(DeployedModelService),
|
||||
predictService: TypeMoq.Mock.ofType(PredictService)
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user