Skip to content

Commit

Permalink
Merge pull request #2389 from botpress/ya-fix-logs-nlu
Browse files Browse the repository at this point in the history
fix(logs): fixed log emitter
  • Loading branch information
slvnperron committed Sep 16, 2019
2 parents 45700b5 + 1d6f191 commit 63b7343
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
12 changes: 6 additions & 6 deletions modules/nlu/src/backend/engine.ts
Expand Up @@ -170,7 +170,7 @@ export default class ScopedEngine implements Engine {
}

if (!loaded) {
debugTrain('Retraining model')
debugTrain.forBot(this.botId, 'Retraining model')
await this.trainModels(intents, modelHash, confusionVersion)
await this.loadModels(intents, modelHash)
}
Expand Down Expand Up @@ -259,7 +259,7 @@ export default class ScopedEngine implements Engine {
)

protected async loadModels(intents: sdk.NLU.IntentDefinition[], modelHash: string) {
debugTrain(`Restoring models '${modelHash}' from storage`)
debugTrain.forBot(this.botId, `Restoring models '${modelHash}' from storage`)
const trainableLangs = _.intersection(this.getTrainingLanguages(intents), this.languages)

for (const lang of this.languages) {
Expand Down Expand Up @@ -291,13 +291,13 @@ export default class ScopedEngine implements Engine {
await this.intentClassifiers[lang].load(intentModels)

if (_.isEmpty(crfModel)) {
debugTrain(`No slots (CRF) model found for hash ${modelHash}`)
debugTrain.forBot(this.botId, `No slots (CRF) model found for hash ${modelHash}`)
} else {
await this.slotExtractors[lang].load(trainingSet, crfModel.model)
}
}

debugTrain(`Done restoring models '${modelHash}' from storage`)
debugTrain.forBot(this.botId, `Done restoring models '${modelHash}' from storage`)
}

private _makeModel(context: string, hash: string, model: Buffer, type: string): Model {
Expand Down Expand Up @@ -350,7 +350,7 @@ export default class ScopedEngine implements Engine {
modelHash: string,
lang: string
): Promise<Model[]> {
debugTrain('Training slot tagger')
debugTrain.forBot(this.botId, 'Training slot tagger')

try {
let trainingSet = await this.getTrainingSets(intentDefs, lang)
Expand Down Expand Up @@ -396,7 +396,7 @@ export default class ScopedEngine implements Engine {
this.intentClassifiers[lang].token2vec // TODO: compute token2vec in pipeline instead, made it a public property for now
)

debugTrain('Done training slot tagger')
debugTrain.forBot(this.botId, 'Done training slot tagger')

return crf ? [this._makeModel('global', modelHash, crf, MODEL_TYPES.SLOT_CRF)] : []
} catch (err) {
Expand Down
34 changes: 20 additions & 14 deletions src/bp/bootstrap.ts
Expand Up @@ -24,20 +24,8 @@ async function setupEnv() {
await Db.initialize()
}

async function start() {
if (cluster.isMaster) {
// The master process only needs getos and rewire
return setupMasterNode(await Logger('Cluster'))
}

await setupEnv()

const logger = await Logger('Launcher')
logger.info(chalk`========================================
{bold ${center(`Botpress Server`, 40)}}
{dim ${center(`Version ${sdk.version}`, 40)}}
{dim ${center(`OS ${process.distro.toString()}`, 40)}}
========================================`)
async function getLogger(loggerName: string) {
const logger = await Logger(loggerName)

global.printErrorDefault = err => {
logger.attachError(err).error('Unhandled Rejection')
Expand All @@ -54,6 +42,24 @@ async function start() {
.debug(message.trim(), rest)
}

return logger
}

async function start() {
if (cluster.isMaster) {
// The master process only needs getos and rewire
return setupMasterNode(await getLogger('Cluster'))
}

await setupEnv()

const logger = await getLogger('Launcher')
logger.info(chalk`========================================
{bold ${center(`Botpress Server`, 40)}}
{dim ${center(`Version ${sdk.version}`, 40)}}
{dim ${center(`OS ${process.distro.toString()}`, 40)}}
========================================`)

if (!fs.existsSync(process.APP_DATA_PATH)) {
try {
fs.mkdirSync(process.APP_DATA_PATH)
Expand Down

0 comments on commit 63b7343

Please sign in to comment.