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

Commit 83314e2

Browse files
up versioned orchestrator-core to 4.13.1 (#1211)
* Update package.json Use orchestrator-core v 4.13.1 * Update pnpm-lock.yaml * skip empty lu file, added empty lu file to test * Update orchestratorhelper.ts fixed lint issues * use forward slash for file path in orchestrator.settings.json to be compatible with non windows platform * addressed PR comments Co-authored-by: Emilio Munoz <[email protected]>
1 parent 21d302d commit 83314e2

File tree

9 files changed

+45
-174
lines changed

9 files changed

+45
-174
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/orchestratorlib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@types/node-fetch": "~2.5.5",
4141
"node-fetch": "~2.6.0",
4242
"tslib": "^2.0.3",
43-
"orchestrator-core": "4.13.0",
43+
"orchestrator-core": "4.13.1",
4444
"@types/fs-extra": "~8.1.0",
4545
"fs-extra": "~9.0.0",
4646
"read-text-file": "~1.1.0",

packages/orchestratorlib/src/build.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class OrchestratorBuild {
4444
let hasLuConfig: boolean = false;
4545
if (!inputs || inputs.length === 0) {
4646
if (!luConfig || !luConfig.models || luConfig.models.length === 0) {
47-
throw new Error('Please provide lu input');
47+
throw new Error('Please provide valid lu input(s)');
4848
} else {
4949
hasLuConfig = true;
5050
}
@@ -72,7 +72,7 @@ export class OrchestratorBuild {
7272
};
7373
} = {
7474
orchestrator: {
75-
modelFolder: baseModelPath,
75+
modelFolder: baseModelPath.replace(/\\/g, '/'),
7676
snapshots: new Map<string, string>(),
7777
},
7878
};
@@ -282,11 +282,14 @@ export class OrchestratorBuild {
282282
private static async processLuConfig(luConfig: any, labelResolvers: Map<string, LabelResolver>, fullEmbeddings: boolean = false): Promise<any[]> {
283283
const luObjects: any[] = [];
284284
for (const file of (luConfig.models || [])) {
285-
const luObject: any = {
286-
content: OrchestratorHelper.readFile(file),
287-
id: path.basename(file, '.lu'),
288-
};
289-
luObjects.push(luObject);
285+
const content: string = OrchestratorHelper.readFile(file);
286+
if (content) {
287+
const luObject: any = {
288+
content: content,
289+
id: path.basename(file, '.lu'),
290+
};
291+
luObjects.push(luObject);
292+
}
290293
}
291294
return OrchestratorBuild.processInput(luObjects, labelResolvers, fullEmbeddings);
292295
}

packages/orchestratorlib/src/orchestratorhelper.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,11 @@ import * as path from 'path';
77
import * as fs from 'fs-extra';
88
require('fast-text-encoding');
99

10-
import {ITextUtteranceLabelMapDataStructure} from '@microsoft/bf-dispatcher';
11-
import {Label} from '@microsoft/bf-dispatcher';
12-
import {LabelStructureUtility} from '@microsoft/bf-dispatcher';
13-
import {LabelType} from '@microsoft/bf-dispatcher';
14-
import {ScoreEntity} from '@microsoft/bf-dispatcher';
15-
import {ScoreIntent} from '@microsoft/bf-dispatcher';
16-
// import {Span} from '@microsoft/bf-dispatcher';
17-
10+
import {ITextUtteranceLabelMapDataStructure, Label, LabelStructureUtility, LabelType, ScoreEntity, ScoreIntent} from '@microsoft/bf-dispatcher';
1811
import {LabelResolver} from './labelresolver';
1912
import {UtilityLabelResolver} from './utilitylabelresolver';
20-
2113
import {PrebuiltToRecognizerMap} from './resources/recognizer-map';
22-
23-
import {OrchestratorBuild} from '.';
24-
14+
import {OrchestratorBuild, OrchestratorSettings} from '.';
2515
import {Utility} from './utility';
2616
import {Utility as UtilityDispatcher} from '@microsoft/bf-dispatcher';
2717

@@ -63,7 +53,11 @@ export class OrchestratorHelper {
6353
}
6454

6555
public static readFile(filePath: string): string {
66-
return ReadText.readSync(filePath);
56+
try {
57+
return ReadText.readSync(filePath);
58+
} catch {
59+
return '';
60+
}
6761
}
6862

6963
public static writeToFile(filePath: string, content: string, options: any = {encoding: 'utf8', flag: 'w'}): string {
@@ -264,7 +258,6 @@ export class OrchestratorHelper {
264258
utteranceEntityLabelsMap: Map<string, Label[]>,
265259
utteranceEntityLabelDuplicateMap: Map<string, Label[]>): Promise<void> {
266260
const ext: string = path.extname(filePath);
267-
268261
if (ext !== '.lu' &&
269262
ext !== '.json' &&
270263
ext !== '.qna' &&
@@ -295,6 +288,9 @@ export class OrchestratorHelper {
295288
utteranceLabelDuplicateMap);
296289
break;
297290
case '.json':
291+
if (filePath.endsWith(OrchestratorSettings.OrchestratorSettingsFileName)) {
292+
return;
293+
}
298294
if (OrchestratorHelper.getIntentsEntitiesUtterances(
299295
fs.readJsonSync(filePath),
300296
routingName,
@@ -395,6 +391,9 @@ export class OrchestratorHelper {
395391
utteranceLabelDuplicateMap: Map<string, Set<string>>,
396392
utteranceEntityLabelsMap: Map<string, Label[]>,
397393
utteranceEntityLabelDuplicateMap: Map<string, Label[]>): Promise<void> {
394+
if (!luContent || luContent.length === 0) {
395+
return;
396+
}
398397
const luObject: any = {
399398
content: luContent,
400399
id: luFile,
@@ -1123,16 +1122,16 @@ export class OrchestratorHelper {
11231122
(idsToFind || []).forEach((ask: any) => {
11241123
const resourceToFind: string = path.isAbsolute(ask.filePath) ? ask.filePath : path.resolve(path.join(baseDir, ask.filePath));
11251124
const fileContent: string = OrchestratorHelper.readFile(resourceToFind);
1126-
if (!processedFiles.includes(resourceToFind)) {
1127-
processedFiles.push(resourceToFind);
1128-
}
11291125
if (fileContent) {
11301126
retPayload.push({
11311127
content: fileContent,
11321128
options: {
11331129
id: ask.filePath,
11341130
},
11351131
});
1132+
if (!processedFiles.includes(resourceToFind)) {
1133+
processedFiles.push(resourceToFind);
1134+
}
11361135
} else {
11371136
throw new Error(`Content not found for ${resourceToFind}.`);
11381137
}
@@ -1150,10 +1149,13 @@ export class OrchestratorHelper {
11501149
} else {
11511150
const ext: string = path.extname(inputPath);
11521151
if (ext === '.lu') {
1153-
retPayload.push({
1154-
content: OrchestratorHelper.readFile(inputPath),
1155-
id: path.basename(inputPath, '.lu'),
1156-
});
1152+
const content: string = OrchestratorHelper.readFile(inputPath);
1153+
if (content) {
1154+
retPayload.push({
1155+
content: content,
1156+
id: path.basename(inputPath, '.lu'),
1157+
});
1158+
}
11571159
}
11581160
}
11591161
}
@@ -1204,7 +1206,7 @@ export class OrchestratorHelper {
12041206
Utility.debuggingLog(`Multi language recognizer file written to ${multiRecoFileName}`);
12051207
}
12061208

1207-
bluPaths[baseName] = snapshotFile;
1209+
bluPaths[baseName] = snapshotFile.replace(/\\/g, '/');
12081210
}
12091211
}
12101212

packages/orchestratorlib/test/build.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ describe('OrchestratorBuildTests', function () {
352352
assert.ok(retPayload !== null);
353353
assert.ok(retPayload.outputs !== null);
354354
assert.ok(retPayload.outputs.length === 5);
355-
assert.ok(retPayload.settings.orchestrator.modelFolder === baseModelPath);
355+
assert.ok(retPayload.settings.orchestrator.modelFolder === baseModelPath.replace(/\\/g, '/'));
356356

357357
const payLoadOutputs: any[] = retPayload.outputs;
358358
const snapshots: Map<string, Uint8Array> = new Map<string, Uint8Array>();
@@ -384,6 +384,9 @@ describe('OrchestratorBuildTests', function () {
384384
assert.ok(Utility.exists('./test/fixtures/output/RootDialog.blu'));
385385
assert.ok(Utility.exists('./test/fixtures/output/RootDialog.en-us.lu.dialog'));
386386
assert.ok(Utility.exists('./test/fixtures/output/RootDialog.lu.dialog'));
387+
388+
const snapshotSettings: any = retPayload.settings.orchestrator.snapshots;
389+
assert.ok(snapshotSettings.RootDialog === 'test/fixtures/output/RootDialog.blu');
387390
});
388391

389392
it('Test.0008 - runAsync changing files', async function () {

packages/orchestratorlib/test/fixtures/adaptive/BotTourDialog.en-us.lu

Whitespace-only changes.

0 commit comments

Comments
 (0)