Skip to content

Commit

Permalink
add a json reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
ferugit committed Mar 10, 2023
1 parent 08460af commit 3b360ea
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/keyword_spotting/reporter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import json

class Reporter:
def __init__(self, experiment_path, filename):
self.experiment_path = experiment_path
self.file_name = filename
self.output_file = os.path.join(experiment_path, self.file_name)
self.data = {}

def __del__(self):
with open(self.output_file , 'w', encoding='utf-8') as f:
json.dump(self.data, f, ensure_ascii=False, indent=4)

def report(self, key, data):
self.data[key] = data

def load(self, filepath):
self.data = json.load(open(filepath, 'r'))

0 comments on commit 3b360ea

Please sign in to comment.