# -*- coding: utf-8 -*-
from dataclasses import dataclass
from pathlib import Path


@dataclass
class BaseArgs:
    def json(self):
        return vars(self).copy()


@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):
        self.output_dir.mkdir(exist_ok=True, parents=True)
        self.cache_dir.mkdir(exist_ok=True, parents=True)

    def json(self):
        data = super().json()
        data.update(
            {
                "output_dir": str(self.output_dir),
                "cache_dir": str(self.cache_dir),
            }
        )
        return data