Skip to content

Commit

Permalink
fix(nlu): queue multiple sync calls
Browse files Browse the repository at this point in the history
  • Loading branch information
slvnperron committed Feb 7, 2019
1 parent 1b4a686 commit 6023927
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 10 additions & 0 deletions modules/nlu/src/backend/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default class ScopedEngine {
}

private _isSyncing: boolean
private _isSyncingTwice: boolean
private _autoSyncInterval: number = 0
private _autoSyncTimer: NodeJS.Timer

Expand Down Expand Up @@ -75,6 +76,11 @@ export default class ScopedEngine {
}

async sync(): Promise<void> {
if (this._isSyncing) {
this._isSyncingTwice = true
return
}

try {
this._isSyncing = true
const intents = await this.storage.getIntents()
Expand All @@ -96,6 +102,10 @@ export default class ScopedEngine {
this._preloaded = true
} finally {
this._isSyncing = false
if (this._isSyncingTwice) {
this._isSyncingTwice = false
this.sync() // This floating promise is voluntary
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions modules/nlu/src/backend/pipelines/intents/ft_classifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ interface TrainSet {
export default class FastTextClassifier implements IntentClassifier {
private _modelsByContext: { [key: string]: sdk.MLToolkit.FastText.Model } = {}

model: sdk.MLToolkit.FastText.Model

constructor(private toolkit: typeof sdk.MLToolkit, private readonly logger: sdk.Logger) {}

private sanitizeText(text: string): string {
Expand Down Expand Up @@ -64,8 +62,6 @@ export default class FastTextClassifier implements IntentClassifier {
lr: 0.8
})

this.model = ft

return { ft, data: readFileSync(modelFn) }
}

Expand Down

0 comments on commit 6023927

Please sign in to comment.