diff --git a/e4e_data_management/cli.py b/e4e_data_management/cli.py index fe6a427..6d11c0a 100644 --- a/e4e_data_management/cli.py +++ b/e4e_data_management/cli.py @@ -14,7 +14,7 @@ from e4e_data_management import __version__ from e4e_data_management.core import DataManager from e4e_data_management.metadata import Metadata - +from e4e_data_management.data import Dataset T = TypeVar('T') @dataclass class Parameter: @@ -88,7 +88,7 @@ def __init__(self): self.__configure_config_parser(parsers['config']) self.__configure_activate_parser(parsers['activate']) self.__configure_ls_parser(parsers['ls']) - # self.__configure_validate_parser(parsers['validate']) + self.__configure_validate_parser(parsers['validate']) # self.__configure_zip_parser(parsers['zip']) # self.__configure_unzip_parser(parsers['unzip']) @@ -98,6 +98,21 @@ def __init__(self): self._log.exception('Exception during application load/configuration') raise exc + def __configure_validate_parser(self, parser: argparse.ArgumentParser): + parser.add_argument('root_dir', nargs='?', default=None, type=Path) + parser.set_defaults(func=self.__external_validate) + + def __external_validate(self, root_dir: Optional[Path]): + if root_dir is None: + dataset = self.app.active_dataset + else: + dataset = Dataset.load(path=root_dir) + + if not dataset.validate(): + print('Dataset validation failed') + else: + print('Dataset valid') + def __configure_logging(self) -> None: log_dir = Path(DataManager.dirs.user_log_dir).resolve() log_dir.mkdir(parents=True, exist_ok=True)