Write index JSON file to AI output directory
This commit is contained in:
parent
92574bc98c
commit
d9cf650019
1 changed files with 23 additions and 5 deletions
|
@ -41,7 +41,7 @@ class AITrainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
async train_all() {
|
async train_all() {
|
||||||
|
let index = {};
|
||||||
for(let gateway of this.repo_gateway.iterate()) {
|
for(let gateway of this.repo_gateway.iterate()) {
|
||||||
let filename = path.join(this.root_dir, "..", this.settings.ai.output_directory, `${gateway.id}`);
|
let filename = path.join(this.root_dir, "..", this.settings.ai.output_directory, `${gateway.id}`);
|
||||||
console.log(filename);
|
console.log(filename);
|
||||||
|
@ -49,11 +49,27 @@ class AITrainer {
|
||||||
if(!fs.existsSync(path.dirname(filename)))
|
if(!fs.existsSync(path.dirname(filename)))
|
||||||
await fs.promises.mkdir(path.dirname(filename), { recursive: true });
|
await fs.promises.mkdir(path.dirname(filename), { recursive: true });
|
||||||
|
|
||||||
await this.train_gateway(
|
if(!await this.train_gateway(gateway.id, filename)) {
|
||||||
gateway.id,
|
this.l.warn(`Warning: Failed to train AI for ${gateway.id}.`);
|
||||||
filename
|
continue;
|
||||||
);
|
}
|
||||||
|
|
||||||
|
index[gateway.id] = {
|
||||||
|
path: path.relative(
|
||||||
|
"./app",
|
||||||
|
this.settings.ai.output_directory
|
||||||
|
)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await fs.promises.writeFile(
|
||||||
|
path.join(
|
||||||
|
path.dirname(this.root_dir),
|
||||||
|
this.settings.ai.output_directory,
|
||||||
|
"index.json"
|
||||||
|
),
|
||||||
|
JSON.stringify(index)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,6 +101,8 @@ class AITrainer {
|
||||||
|
|
||||||
await this.model.save(`file://${destination_filename}`);
|
await this.model.save(`file://${destination_filename}`);
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue