From 4eb3fef8e5876c69dc6bac70fdc010805d5b97f2 Mon Sep 17 00:00:00 2001 From: Ruomei Yan Date: Tue, 13 Dec 2022 22:02:21 +0000 Subject: MLIA-741/2 Report test results - add version extraction function in compat.py - create Metadata, MLIAMetadata, TOSAMetadata and MetadataDisplay classes - update the reporting functions so tosa and mlia version will be displayed in output json - update unit test test_configure_and_get_tosa_advisor to mock the get_events function - update the copyright information of all changed/added files - handle exception and report to json when program crashes - write new context managers for capturing stderr and stdout - support reporting stderr to json output - support reporting model checksum and model name to json output - made changes in test_e2e.py handling {model_name} replacement in --output - add unit tests Change-Id: I6629fd1c5754378e6accd488217c83d87c7eb6f1 --- src/mlia/core/metadata.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/mlia/core/metadata.py (limited to 'src/mlia/core') diff --git a/src/mlia/core/metadata.py b/src/mlia/core/metadata.py new file mode 100644 index 0000000..f0a0e03 --- /dev/null +++ b/src/mlia/core/metadata.py @@ -0,0 +1,37 @@ +# SPDX-FileCopyrightText: Copyright 2023, Arm Limited and/or its affiliates. +# SPDX-License-Identifier: Apache-2.0 +"""Classes for metadata.""" +from pathlib import Path + +from mlia.utils.misc import get_file_checksum +from mlia.utils.misc import get_pkg_version + + +class Metadata: # pylint: disable=too-few-public-methods + """Base class metadata.""" + + def __init__(self, data_name: str) -> None: + """Init Metadata.""" + self.version = self.get_version(data_name) + + def get_version(self, data_name: str) -> str: + """Get version of the python package.""" + return get_pkg_version(data_name) + + +class MLIAMetadata(Metadata): # pylint: disable=too-few-public-methods + """MLIA metadata.""" + + +class ModelMetadata: # pylint: disable=too-few-public-methods + """Model metadata.""" + + def __init__(self, path_name: Path) -> None: + """Init ModelMetadata.""" + self.model_name = path_name.name + self.path_name = path_name + self.checksum = self.get_checksum() + + def get_checksum(self) -> str: + """Get checksum of the model.""" + return get_file_checksum(self.path_name) -- cgit v1.2.1