Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 0a1f5ee

Browse files
authored
fix activeVersion issue (#827)
1 parent c2db878 commit 0a1f5ee

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

packages/lu/src/parser/lubuild/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export class Builder {
306306
async updateApplication(currentApp: any, luBuildCore: LuBuildCore, recognizer: Recognizer, delayDuration: number, deleteOldVersion: boolean) {
307307
await delay(delayDuration)
308308
const appInfo = await luBuildCore.getApplicationInfo(recognizer.getAppId())
309-
recognizer.versionId = appInfo.activeVersion
309+
recognizer.versionId = appInfo.activeVersion || appInfo.endpoints.PRODUCTION.versionId
310310

311311
await delay(delayDuration)
312312
const existingApp = await luBuildCore.exportApplication(recognizer.getAppId(), recognizer.versionId)

packages/luis/test/commands/luis/build.test.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,4 +792,74 @@ describe('luis:build create a new application successfully with locale set to it
792792
expect(ctx.stdout).to.contain('publishing finished')
793793
expect(ctx.stdout.includes('personName is not available for the requested locale: it-it')).to.be.false
794794
})
795+
})
796+
797+
describe('luis:build update application succeed when activeVersion is null', () => {
798+
const existingLuisApp = require('./../../fixtures/testcases/lubuild/sandwich/luis/test(development)-sandwich.utteranceAdded.en-us.lu.json')
799+
before(function () {
800+
nock('https://westus.api.cognitive.microsoft.com')
801+
.get(uri => uri.includes('apps'))
802+
.reply(200, [{
803+
name: 'test(development)-sandwich.en-us.lu',
804+
id: 'f8c64e2a-8635-3a09-8f78-39d7adc76ec5'
805+
}])
806+
807+
nock('https://westus.api.cognitive.microsoft.com')
808+
.get(uri => uri.includes('apps'))
809+
.reply(200, {
810+
name: 'test(development)-sandwich.en-us.lu',
811+
id: 'f8c64e2a-8635-3a09-8f78-39d7adc76ec5',
812+
activeVersion: null,
813+
endpoints: {
814+
PRODUCTION: {
815+
versionId: '0.1'
816+
}
817+
}
818+
})
819+
820+
nock('https://westus.api.cognitive.microsoft.com')
821+
.get(uri => uri.includes('export'))
822+
.reply(200, existingLuisApp)
823+
824+
nock('https://westus.api.cognitive.microsoft.com')
825+
.post(uri => uri.includes('import'))
826+
.reply(201, '0.2')
827+
828+
nock('https://westus.api.cognitive.microsoft.com')
829+
.post(uri => uri.includes('train'))
830+
.reply(202, {
831+
statusId: 2,
832+
status: 'UpToDate'
833+
})
834+
835+
nock('https://westus.api.cognitive.microsoft.com')
836+
.get(uri => uri.includes('train'))
837+
.reply(200, [{
838+
modelId: '99999',
839+
details: {
840+
statusId: 0,
841+
status: 'Success',
842+
exampleCount: 0
843+
}
844+
}])
845+
846+
nock('https://westus.api.cognitive.microsoft.com')
847+
.post(uri => uri.includes('publish'))
848+
.reply(201, {
849+
versionId: '0.2',
850+
isStaging: true
851+
})
852+
})
853+
854+
test
855+
.stdout()
856+
.command(['luis:build', '--in', './test/fixtures/testcases/lubuild/sandwich/lufiles/sandwich.en-us.lu', '--authoringKey', uuidv1(), '--botName', 'test', '--log', '--suffix', 'development'])
857+
.it('should update a luis application when activeVersion is null', ctx => {
858+
expect(ctx.stdout).to.contain('Handling applications...')
859+
expect(ctx.stdout).to.contain('creating version=0.2')
860+
expect(ctx.stdout).to.contain('training version=0.2')
861+
expect(ctx.stdout).to.contain('waiting for training for version=0.2')
862+
expect(ctx.stdout).to.contain('publishing version=0.2')
863+
expect(ctx.stdout).to.contain('publishing finished')
864+
})
795865
})

0 commit comments

Comments
 (0)