Skip to content

Commit

Permalink
fix(nlu): dont train bot if got deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
EFF committed Feb 18, 2020
1 parent eeaca84 commit 386f841
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions modules/nlu/src/backend/module-lifecycle/on-bot-mount.ts
Expand Up @@ -61,6 +61,10 @@ export function getOnBotMount(state: NLUState) {
}
let model = await ModelService.getModel(ghost, hash, languageCode)
if (forceTrain || !model) {
// bot got deleted
if (!state.nluByBot[botId]) {
return { succes: false }
}
const trainSession = makeTrainingSession(languageCode, lock)
state.nluByBot[botId].trainSessions[languageCode] = trainSession

Expand All @@ -76,11 +80,10 @@ export function getOnBotMount(state: NLUState) {
} finally {
await lock.unlock()
}
// TODO remove training session from state, kvs will clear itself or not ?
})
},
10000
// { leading: true }
10000,
{ leading: true }
)
// register trainOrLoad with ghost file watcher
// we use local events so training occurs on the same node where the request for changes enters
Expand All @@ -92,7 +95,7 @@ export function getOnBotMount(state: NLUState) {
await bp.distributed.clearLock(key)
return state.broadcastCancelTraining(botId, lang)
})
await trainOrLoad()
trainOrLoad()
}
})

Expand Down

0 comments on commit 386f841

Please sign in to comment.