Skip to content

Commit

Permalink
fix: azure deploy bugfix (#3901)
Browse files Browse the repository at this point in the history
* azure deploy bugfix

* code refactor

Co-authored-by: Chris Whitten <[email protected]>
Co-authored-by: VanyLaw <[email protected]>
  • Loading branch information
3 people authored Aug 27, 2020
1 parent 062bd41 commit f190785
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
3 changes: 3 additions & 0 deletions Composer/packages/client/src/utils/luUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { getBaseName, getExtension } from './fileUtil';

export * from '@bfc/indexers/lib/utils/luUtil';

/*
* checkoutContent: will check out the file content by default
*/
export function getReferredLuFiles(luFiles: LuFile[], dialogs: DialogInfo[], checkContent = true) {
return luFiles.filter((file) => {
const idWithOutLocale = getBaseName(file.id);
Expand Down
68 changes: 35 additions & 33 deletions Composer/plugins/azurePublish/src/luisAndQnA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,41 +384,43 @@ export class LuisAndQnaPublish {
) {
const { authoringKey, authoringRegion } = luisSettings;
const { subscriptionKey } = qnaSettings;
if ((authoringKey && authoringRegion) || subscriptionKey) {
const botFiles = await this.getFiles(this.remoteBotPath);
const luFiles = botFiles.filter((name) => {
return name.endsWith('.lu') && this.notEmptyModel(name);
});
const qnaFiles = botFiles.filter((name) => {
return name.endsWith('.qna') && this.notEmptyModel(name);
});
const botFiles = await this.getFiles(this.remoteBotPath);
const luFiles = botFiles.filter((name) => {
return name.endsWith('.lu');
});
const qnaFiles = botFiles.filter((name) => {
return name.endsWith('.qna');
});

if (luFiles.length > 0 && !(authoringKey && authoringRegion)) {
throw 'Should have luis authoringKey and authoringRegion when lu file not empty';
}
if (qnaFiles.length > 0 && !subscriptionKey) {
throw 'Should have qna subscriptionKey when qna file not empty';
}
const dialogFiles = botFiles.filter((name) => {
return name.endsWith('.dialog') && this.notEmptyModel(name);
});
// check content
const notEmptyLuFiles = luFiles.some((name) => this.notEmptyModel(name));
const notEmptyQnaFiles = qnaFiles.some((name) => this.notEmptyModel(name));

await this.setCrossTrainConfig(name, dialogFiles, luFiles);
await this.createGeneratedDir();
await this.crossTrain(luFiles, qnaFiles);
const { interruptionLuFiles, interruptionQnaFiles } = await this.getInterruptionFiles();
const luisAppIds = await this.publishLuis(
name,
environment,
accessToken,
language,
luisSettings,
interruptionLuFiles,
luisResource
);
const qnaConfig = await this.publishQna(name, environment, language, qnaSettings, interruptionQnaFiles);
await this.cleanCrossTrain();
return { luisAppIds, qnaConfig };
if (notEmptyLuFiles && !(authoringKey && authoringRegion)) {
throw Error('Should have luis authoringKey and authoringRegion when lu file not empty');
}
if (notEmptyQnaFiles && !subscriptionKey) {
throw Error('Should have qna subscriptionKey when qna file not empty');
}
const dialogFiles = botFiles.filter((name) => {
return name.endsWith('.dialog') && this.notEmptyModel(name);
});

await this.setCrossTrainConfig(name, dialogFiles, luFiles);
await this.createGeneratedDir();
await this.crossTrain(luFiles, qnaFiles);
const { interruptionLuFiles, interruptionQnaFiles } = await this.getInterruptionFiles();
const luisAppIds = await this.publishLuis(
name,
environment,
accessToken,
language,
luisSettings,
interruptionLuFiles,
luisResource
);
const qnaConfig = await this.publishQna(name, environment, language, qnaSettings, interruptionQnaFiles);
await this.cleanCrossTrain();
return { luisAppIds, qnaConfig };
}
}

0 comments on commit f190785

Please sign in to comment.