Skip to content

Commit

Permalink
Merge branch 'main' into 37-zip-command
Browse files Browse the repository at this point in the history
  • Loading branch information
ntlhui authored Jan 11, 2025
2 parents f49afac + 95533b5 commit 1b573b5
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 68 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# CHANGELOG

## v0.1.5 (2025-01-11)

### Ci

* ci: Tests for prune behavior ([`31173a1`](https://github.com/UCSD-E4E/e4e-data-management/commit/31173a1ad25897de965548767d7cbbf42fb85f36))

* ci: Fixes failing tests ([`3810a02`](https://github.com/UCSD-E4E/e4e-data-management/commit/3810a029971cf5e146765d57fed36eb9bed5d12a))

### Documentation

* docs: Documents fixture ([`a98cfea`](https://github.com/UCSD-E4E/e4e-data-management/commit/a98cfead653cc847af04ae90ee23371062e91347))

### Fix

* fix: Adds exception logging to main invocation ([`9f0aa7f`](https://github.com/UCSD-E4E/e4e-data-management/commit/9f0aa7f21ccc75bc7e031bc7443ac148ada70d98))

### Style

* style: Fixes long line ([`0d795f7`](https://github.com/UCSD-E4E/e4e-data-management/commit/0d795f73b470b4824cbe9cac06dd52eb879ba1a3))

### Unknown

* Merge pull request #57 from UCSD-E4E/44-add-exception-and-traceback-to-logs

fix: Adds exception logging to main invocation ([`cb9c732`](https://github.com/UCSD-E4E/e4e-data-management/commit/cb9c732cd6e8426513615b36aad287493e21ebbc))

* Merge branch 'main' into 44-add-exception-and-traceback-to-logs ([`de9e0d5`](https://github.com/UCSD-E4E/e4e-data-management/commit/de9e0d5bbacd41a9ef8fcd7cce0e8ba5cd3f942c))

* Merge pull request #91 from UCSD-E4E/34-remove-dataset-after-pushing-to-server

34 remove dataset after pushing to server ([`8a811be`](https://github.com/UCSD-E4E/e4e-data-management/commit/8a811bec27556f1dfba5044f3875cbecdc9b38e4))

## v0.1.4 (2024-11-04)

### Fix
Expand Down
2 changes: 1 addition & 1 deletion e4e_data_management/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'''E4E Data Management Tools
'''
__version__ = '0.1.4'
__version__ = '0.1.5'
140 changes: 74 additions & 66 deletions e4e_data_management/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,71 +28,75 @@ class Parameter:
validator: Callable[[T], bool]


class DataMangerCLI:
class DataManagerCLI:
"""Data Manager Command Line Interface
"""
def __init__(self):
self.__configure_logging()
self._log = logging.getLogger('e4edm.cli')
self._log.debug('Invoking version %s from %s', __version__, __file__)
self.app = DataManager.load()
commands = [
'init_dataset',
'init_mission',
'status',
'list',
'config',
'activate',
'add',
'commit',
'duplicate',
'validate',
'push',
'zip',
'unzip',
'prune',
'ls',
]
self.parameters = [
Parameter(
name='dataset_dir',
getter=lambda: getattr(self.app, 'dataset_dir'),
setter=lambda x: setattr(self.app, 'dataset_dir', x),
parser=Path,
formatter=Path.as_posix,
validator=Path.is_dir
),
Parameter(
name='version',
getter=lambda: getattr(self.app, 'version'),
setter=None,
parser=int,
formatter=str,
validator=None
)
]
self.parser = argparse.ArgumentParser()
subparsers = self.parser.add_subparsers()
parsers = {cmd:subparsers.add_parser(cmd) for cmd in commands}

self.__configure_init_dataset_parser(parsers['init_dataset'])
self.__configure_init_mission_parser(parsers['init_mission'])
self.__configure_status_parser(parsers['status'])
self.__configure_list_parser(parsers['list'])
self.__configure_add_parser(parsers['add'])
self.__configure_commit_parser(parsers['commit'])
self.__configure_duplicate_parser(parsers['duplicate'])
self.__configure_push_parser(parsers['push'])
self.__configure_prune_parser(parsers['prune'])
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_zip_parser(parsers['zip'])
# self.__configure_unzip_parser(parsers['unzip'])

self.parser.add_argument('--version', action='version', version=f'e4edm {__version__}')
self.parser.set_defaults(func=self.parser.print_help)
try:
self.app = DataManager.load()
commands = [
'init_dataset',
'init_mission',
'status',
'list',
'config',
'activate',
'add',
'commit',
'duplicate',
'validate',
'push',
'zip',
'unzip',
'prune',
'ls',
]
self.parameters = [
Parameter(
name='dataset_dir',
getter=lambda: getattr(self.app, 'dataset_dir'),
setter=lambda x: setattr(self.app, 'dataset_dir', x),
parser=Path,
formatter=Path.as_posix,
validator=Path.is_dir
),
Parameter(
name='version',
getter=lambda: getattr(self.app, 'version'),
setter=None,
parser=int,
formatter=str,
validator=None
)
]
self.parser = argparse.ArgumentParser()
subparsers = self.parser.add_subparsers()
parsers = {cmd:subparsers.add_parser(cmd) for cmd in commands}

self.__configure_init_dataset_parser(parsers['init_dataset'])
self.__configure_init_mission_parser(parsers['init_mission'])
self.__configure_status_parser(parsers['status'])
self.__configure_list_parser(parsers['list'])
self.__configure_add_parser(parsers['add'])
self.__configure_commit_parser(parsers['commit'])
self.__configure_duplicate_parser(parsers['duplicate'])
self.__configure_push_parser(parsers['push'])
self.__configure_prune_parser(parsers['prune'])
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_zip_parser(parsers['zip'])
# self.__configure_unzip_parser(parsers['unzip'])

self.parser.add_argument('--version', action='version', version=f'e4edm {__version__}')
self.parser.set_defaults(func=self.parser.print_help)
except Exception as exc:
self._log.exception('Exception during application load/configuration')
raise exc

def __configure_logging(self) -> None:
log_dir = Path(DataManager.dirs.user_log_dir).resolve()
Expand Down Expand Up @@ -253,14 +257,18 @@ def prune_cmd(self):
def main(self):
"""Main function
"""
self._log.info("Invoked with %s", ' '.join(sys.argv))
args = self.parser.parse_args()
arg_dict = vars(args)
try:
self._log.info("Invoked with %s", ' '.join(sys.argv))
args = self.parser.parse_args()
arg_dict = vars(args)

arg_fn = args.func
arg_dict.pop('func')
arg_fn = args.func
arg_dict.pop('func')

arg_fn(**arg_dict)
arg_fn(**arg_dict)
except Exception as exc:
self._log.exception('Exception during main execution')
raise exc

def __configure_ls_parser(self, parser: argparse.ArgumentParser):
parser.add_argument('path', type=Path, default=Path('.'))
Expand Down Expand Up @@ -398,7 +406,7 @@ def __configure_init_dataset_parser(self, parser: argparse.ArgumentParser):
def main():
"""Main bootstrap
"""
DataMangerCLI().main()
DataManagerCLI().main()

if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "e4e-data-management"
version = "0.1.4"
version = "0.1.5"
description = "E4E Data Management Tool (Python)"
authors = [
"Nathan Hui <[email protected]>",
Expand Down

0 comments on commit 1b573b5

Please sign in to comment.