# -*- coding: utf-8 -*- import json from dataclasses import asdict, dataclass from pathlib import Path @dataclass class BaseArgs: def __post_init__(self): self._validate() def _validate(self): """Override this method to add argument validation.""" pass def dict(self): return json.loads(json.dumps(asdict(self), default=str)) @dataclass class CommonArgs(BaseArgs): """ General arguments Args: dataset_name (str): Name of the dataset being created output_dir (Path): Where the data should be generated cache_dir (Path): Cache directory where to save the full size downloaded images. log_parameters (bool): Save every parameters to a JSON file. """ dataset_name: str output_dir: Path cache_dir: Path = Path(".cache") log_parameters: bool = True def __post_init__(self): super().__post_init__() self.output_dir.mkdir(exist_ok=True, parents=True) self.cache_dir.mkdir(exist_ok=True, parents=True)