Skip to content

Commit

Permalink
Merge pull request #47 from UCSD-E4E/42-implement-e4edm-validate
Browse files Browse the repository at this point in the history
42 implement e4edm validate
  • Loading branch information
ntlhui authored Jan 11, 2025
2 parents 95533b5 + b114488 commit e5b4340
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions e4e_data_management/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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'])

Expand All @@ -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)
Expand Down

0 comments on commit e5b4340

Please sign in to comment.