Create a class that extends Reporter
and implement the report
function.
Report should return true/false based on if it is able to successfully report,
this allows other reporters to try when the current one is unable to.
def load_ndarray(path):
with open(path, mode="rb") as f:
return np.load(f)
class NDArrayDiffReporter(Reporter):
def report(self, received_path: str, approved_path: str) -> bool:
if not Path(approved_path).is_file():
self._create_empty_array(approved_path)
received = load_ndarray(received_path)
approved = load_ndarray(approved_path)
to_approve_msg = (
f"To approve run:\n {get_command_text(received_path,approved_path)}"
)
print(np.testing.build_err_msg([received, approved], err_msg=to_approve_msg))
return True