Skip to content

Commit

Permalink
show train logs when loading model (#273)
Browse files Browse the repository at this point in the history
* path

* config path for log

* config path for log .

* model log endpoint

* model log in reducer

* no print

* oops dont forget about kaldi
  • Loading branch information
benfoley committed Dec 6, 2021
1 parent 89b0327 commit 54f0f26
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion elpis/endpoints/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def load():
app.config['CURRENT_PRON_DICT'] = model.pron_dict
app.config['CURRENT_MODEL'] = model
data = {
"config": model.config._load()
"config": model.config._load(),
"log": model.log
}
return jsonify({
"status": 200,
Expand Down
3 changes: 2 additions & 1 deletion elpis/engines/hft/objects/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def __init__(self, **kwargs):

# Prepare logging
self.run_log_path = self.path.joinpath('train.log')
self.config['run_log_path'] = self.run_log_path.as_posix()
if not Path(self.run_log_path).is_file():
run(f'touch {self.run_log_path};')
sys.stdout = open(self.run_log_path, 'w')
Expand All @@ -129,7 +130,7 @@ def load(cls, base_path: Path):

@property
def log(self):
with open(self.run_log_path) as logs:
with open(self.config['run_log_path']) as logs:
return logs.read()

def _set_finished_training(self, has_finished: bool) -> None:
Expand Down
7 changes: 3 additions & 4 deletions elpis/engines/kaldi/objects/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, **kwargs):
self.settings = {'ngram': 1}
print("model default settings", self.settings)
self.run_log_path = self.path.joinpath('train.log')
self.config['run_log_path'] = self.run_log_path.as_posix()
if not Path(self.run_log_path).is_file():
run(f"touch {self.run_log_path};")

Expand All @@ -51,7 +52,7 @@ def load(cls, base_path: Path):

@property
def log(self):
with open(self.run_log_path) as logs:
with open(self.config['run_log_path']) as logs:
return logs.read()

def link_pron_dict(self, pron_dict: PronDict):
Expand Down Expand Up @@ -259,9 +260,7 @@ def background_train_task():

def get_train_results(self):
results = {}
# self.run_log_path isn't available...
run_log_path = self.path.joinpath('train.log')
with run_log_path.open() as log_file:
with self.config['run_log_path'].open() as log_file:
wer_lines = []
for line in reversed(list(log_file)):
line = line.rstrip()
Expand Down
2 changes: 2 additions & 0 deletions elpis/gui/src/redux/reducers/modelReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const model = (state = initState, action) => {
case actionTypes.MODEL_LOAD_SUCCESS: {
var {name, dataset_name, engine_name, pron_dict_name, settings, results} = action.response.data.data.config;
let model_status = action.response.data.data.config;
let log = action.response.data.data.log;

console.log("model reducer load success");
console.log(settings);
Expand All @@ -48,6 +49,7 @@ const model = (state = initState, action) => {
...state,
name,
results,
log,
status: model_status,
datasetName: dataset_name,
engineName: engine_name,
Expand Down

0 comments on commit 54f0f26

Please sign in to comment.