Machine Learning - Supporting multiple model import (#9869)

* Machine Learning Extension - Changed the deploy wizard to deploy multiple files
This commit is contained in:
Leila Lali
2020-04-13 10:26:10 -07:00
committed by GitHub
parent 15fc4517ee
commit 3aa357629d
23 changed files with 743 additions and 332 deletions

View File

@@ -248,9 +248,10 @@ describe('DeployedModelService', () => {
testContext.config.object,
testContext.queryRunner.object,
testContext.modelClient.object);
testContext.modelClient.setup(x => x.deployModel(connection, '')).returns(() => {
testContext.queryRunner.setup(x => x.safeRunQuery(TypeMoq.It.isAny(), TypeMoq.It.is(x => x.indexOf('Insert into') > 0))).returns(() => {
deployed = true;
return Promise.resolve();
return Promise.resolve(result);
});
testContext.queryRunner.setup(x => x.safeRunQuery(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => {
return deployed ? Promise.resolve(updatedResult) : Promise.resolve(result);
@@ -259,7 +260,15 @@ describe('DeployedModelService', () => {
testContext.config.setup(x => x.registeredModelDatabaseName).returns(() => 'db');
testContext.config.setup(x => x.registeredModelTableName).returns(() => 'table');
testContext.config.setup(x => x.registeredModelTableSchemaName).returns(() => 'dbo');
await should(service.deployLocalModel('', model)).resolved();
let tempFilePath: string = '';
try {
tempFilePath = path.join(os.tmpdir(), `ads_ml_temp_${UUID.generateUuid()}`);
await fs.promises.writeFile(tempFilePath, 'test');
await should(service.deployLocalModel(tempFilePath, model)).resolved();
}
finally {
await utils.deleteFile(tempFilePath);
}
});
it('getConfigureQuery should escape db name', async function (): Promise<void> {
@@ -306,7 +315,7 @@ describe('DeployedModelService', () => {
CREATE TABLE [dbo].[ta[[b]]le](
[artifact_id] [int] IDENTITY(1,1) NOT NULL,
[artifact_name] [varchar](256) NOT NULL,
[group_path] [varchar](256) NOT NULL,
[group_path] [varchar](256) NULL,
[artifact_content] [varbinary](max) NOT NULL,
[artifact_initial_size] [bigint] NULL,
[name] [varchar](256) NULL,
@@ -345,7 +354,7 @@ describe('DeployedModelService', () => {
should.deepEqual(expected, actual);
});
it('getUpdateModelQuery should escape db name', async function (): Promise<void> {
it('getInsertModelQuery should escape db name', async function (): Promise<void> {
const testContext = createContext();
const dbName = 'curre[n]tDb';
const model: RegisteredModel =
@@ -367,16 +376,17 @@ describe('DeployedModelService', () => {
testContext.config.setup(x => x.registeredModelTableName).returns(() => 'ta[b]le');
testContext.config.setup(x => x.registeredModelTableSchemaName).returns(() => 'dbo');
const expected = `
UPDATE [dbo].[ta[[b]]le]
SET
name = 'title1',
version = '1.1',
description = 'desc1'
WHERE artifact_id = 1`;
const actual = service.getUpdateModelQuery(dbName, model);
Insert into [dbo].[ta[[b]]le]
(artifact_name, group_path, artifact_content, name, version, description)
values (
'name1',
'ADS',
,
'title1',
'1.1',
'desc1')`;
const actual = service.getInsertModelQuery(dbName, model);
should.equal(actual.indexOf(expected) > 0, true);
//should.deepEqual(actual, expected);
});
it('getModelContentQuery should escape db name', async function (): Promise<void> {