ML - Bug fixing (#13018)

* Fixing couple of bugs
This commit is contained in:
Leila Lali
2020-10-26 17:36:37 -07:00
committed by GitHub
parent 20ed569a71
commit eec6f64d62
10 changed files with 121 additions and 44 deletions

View File

@@ -6,12 +6,13 @@
import * as azdata from 'azdata';
import * as vscode from 'vscode';
import { ApiWrapper } from '../../common/apiWrapper';
import * as Queries from '../../prediction/queries';
import * as TypeMoq from 'typemoq';
import * as should from 'should';
import { PredictService } from '../../prediction/predictService';
import { QueryRunner } from '../../common/queryRunner';
import { ImportedModel } from '../../modelManagement/interfaces';
import { PredictParameters, DatabaseTable, TableColumn } from '../../prediction/interfaces';
import { PredictParameters, DatabaseTable, TableColumn, PredictColumn } from '../../prediction/interfaces';
import * as path from 'path';
import * as os from 'os';
import * as UUID from 'vscode-languageclient/lib/utils/uuid';
@@ -114,11 +115,13 @@ describe('PredictService', () => {
const expected: TableColumn[] = [
{
columnName: 'c1',
dataType: 'INT'
dataType: 'INT',
maxLength: undefined
},
{
columnName: 'c2',
dataType: 'VARCHAR'
dataType: 'VARCHAR',
maxLength: 10
}
];
const table: DatabaseTable =
@@ -141,6 +144,11 @@ describe('PredictService', () => {
displayValue: 'int',
isNull: false,
invariantCultureDisplayValue: ''
},
{
displayValue: '',
isNull: true,
invariantCultureDisplayValue: ''
}
], [
{
@@ -152,6 +160,11 @@ describe('PredictService', () => {
displayValue: 'varchar',
isNull: false,
invariantCultureDisplayValue: ''
},
{
displayValue: '10',
isNull: false,
invariantCultureDisplayValue: ''
}
]]
};
@@ -175,12 +188,14 @@ describe('PredictService', () => {
{
paramName: 'p1',
dataType: 'int',
columnName: ''
columnName: '',
maxLength: undefined
},
{
paramName: 'p2',
dataType: 'varchar',
columnName: ''
columnName: '',
maxLength: 10
}
],
outputColumns: [
@@ -298,4 +313,35 @@ describe('PredictService', () => {
should.notEqual(actual, undefined);
should.equal(actual.indexOf('FROM PREDICT(MODEL = 0X') > 0, true);
});
it('getInputColumnNames should user column max length for varchar type', async function (): Promise<void> {
const columns: PredictColumn[] = [
{
paramName: 'p1',
paramType: 'VARCHAR(MAX)',
columnName: 'c1',
dataType: 'VARCHAR',
maxLength: 20
},
{
paramName: 'p2',
paramType: 'VARCHAR(MAX)',
columnName: 'c2',
dataType: 'DATETIME',
maxLength: undefined
},
{
paramName: 'p3',
paramType: 'INT',
columnName: 'c2',
dataType: 'INT',
maxLength: undefined
},
];
const tableName = 'tbname';
let actual = Queries.getInputColumnNames(columns, tableName);
let expected =`CAST([tbname].[c1] AS VARCHAR(20)) AS p1,\n\tCAST([tbname].[c2] AS VARCHAR(100)) AS p2,\n\t[tbname].[c2] AS p3`;
should.deepEqual(actual, expected);
});
});

View File

@@ -180,7 +180,7 @@ describe('Predict Wizard', () => {
view.modelBrowsePage.modelSourceType = ModelSourceType.Azure;
}
await view.refresh();
should.notEqual(view.azureModelsComponent?.data, undefined);
should.notEqual(view.azureModelsComponent?.data, undefined, 'Data from Azure component should not be null');
if (view.modelBrowsePage) {
view.modelBrowsePage.modelSourceType = ModelSourceType.RegisteredModels;
@@ -188,19 +188,21 @@ describe('Predict Wizard', () => {
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);
should.equal(view.modelSourcePage?.data, ModelSourceType.RegisteredModels, 'Model source should be registered models');
should.notEqual(view.localModelsComponent?.data, undefined, 'Data from local model component should not be null');
should.notEqual(view.modelBrowsePage?.registeredModelsComponent?.data, undefined, 'Data from registered model component should not be null');
if (view.modelBrowsePage?.registeredModelsComponent?.data) {
should.equal(view.modelBrowsePage.registeredModelsComponent.data.length, 1);
should.equal(view.modelBrowsePage.registeredModelsComponent.data.length, 1, 'Data from registered model component should not be empty');
}
should.notEqual(await view.getModelFileName(), undefined);
should.notEqual(await view.getModelFileName(), undefined, 'Model file name should not be null');
await view.columnsSelectionPage?.onEnter();
await view.columnsSelectionPage?.inputColumnsComponent?.loadWithTable(tableNames[0]);
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);
should.notEqual(view.columnsSelectionPage?.data, undefined, 'Data from column selection component should not be null');
should.equal(view.columnsSelectionPage?.data?.inputColumns?.length, modelParameters.inputs.length, `unexpected number of inputs. ${view.columnsSelectionPage?.data?.inputColumns?.length}` );
should.equal(view.columnsSelectionPage?.data?.outputColumns?.length, modelParameters.outputs.length, `unexpected number of outputs. ${view.columnsSelectionPage?.data?.outputColumns?.length}`);
});
});