Skip to content

Commit

Permalink
Merge pull request #1923 from botpress/fl_nlu_matrix_not_found
Browse files Browse the repository at this point in the history
fix(nlu): log error only when it was trown for an unexpected reason
  • Loading branch information
slvnperron committed Jun 17, 2019
2 parents cdb680b + d20a6cd commit a881a18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion modules/nlu/src/backend/api.ts
Expand Up @@ -77,7 +77,9 @@ export default async (bp: typeof sdk, nlus: EngineByBot) => {
const matrix = await engine.storage.getConfusionMatrix(req.params.modelHash, req.params.version, lang)
res.send({ matrix, confusionComputing })
} catch (err) {
bp.logger.attachError(err).warn(`Could not get confusion matrix for ${req.params.modelHash}. It may not exist`)
if (err.code !== 'ENOENT') {
bp.logger.attachError(err).warn(`Could not get confusion matrix for ${req.params.modelHash}.`)
}
res.send({ confusionComputing })
}
})
Expand Down
7 changes: 5 additions & 2 deletions modules/nlu/src/backend/confusion-engine.ts
Expand Up @@ -52,8 +52,11 @@ export default class ConfusionEngine extends ScopedEngine {
this.originalModelHash = modelHash

this._confusionComputing = true
await folder.fold('intents', this._trainIntents.bind(this, lang), this._evaluateIntents.bind(this, lang))
this._confusionComputing = false
try {
await folder.fold('intents', this._trainIntents.bind(this, lang), this._evaluateIntents.bind(this, lang))
} finally {
this._confusionComputing = false
}

await this._processResults(folder.getResults(), lang, confusionVersion)
}
Expand Down

0 comments on commit a881a18

Please sign in to comment.