Skip to content

Commit

Permalink
Added dataset dir value
Browse files Browse the repository at this point in the history
  • Loading branch information
ntlhui committed Mar 12, 2023
1 parent 3e37ce2 commit 1f2ec04
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions e4e_data_management/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,11 @@ def __configure_init_dataset_parser(app: DataManager, parser: argparse.ArgumentP
parser.add_argument('--location', '-l',
help='Expedition location (common name)',
required=True)
data_dir = Path(app.dataset_dir)
parser.add_argument('--path',
default=Path('.'),
default=data_dir,
type=Path,
help='Dataset location, defaults to current directory',
help=f'Dataset location, defaults to {data_dir.as_posix()}',
dest='directory')
parser.set_defaults(func=app.initialize_dataset)

Expand Down
15 changes: 9 additions & 6 deletions e4e_data_management/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,28 @@ class DataManager:
"""Data Manager Application Core
"""
__CONFIG_NAME = 'config.pkl'
__VERSION = 1
config_dir = Path(appdirs.user_config_dir(
__VERSION = 2

dirs = appdirs.AppDirs(
appname='E4EDataManagement',
appauthor='Engineers for Exploration'
))
)
def __init__(self, *, app_config_dir: Optional[Path] = None):
# self.__log = logging.getLogger('DataManager')
self.config_path = app_config_dir
self.active_dataset: Optional[Dataset] = None
self.active_mission: Optional[Mission] = None
self.datasets: Dict[str, Dataset] = {}
self.version = self.__VERSION
self.dataset_dir = Path(self.dirs.user_data_dir)
self.save()

def upgrade(self):
"""Upgrades self to current version
"""
if self.version < 1:
pass
if self.version < 2:
self.dataset_dir = Path(self.dirs.user_data_dir)
self.version = 2

@classmethod
def load(cls, *, config_dir: Optional[Path] = None) -> DataManager:
Expand All @@ -51,7 +54,7 @@ def load(cls, *, config_dir: Optional[Path] = None) -> DataManager:
"""
try:
if config_dir is None:
config_dir = cls.config_dir
config_dir = cls.dirs.user_config_dir
config_file = config_dir.joinpath(cls.__CONFIG_NAME)
if not config_file.exists():
return DataManager(app_config_dir=config_dir)
Expand Down

0 comments on commit 1f2ec04

Please sign in to comment.