diff --git a/src/hyfi/__cli__.py b/src/hyfi/__cli__.py index fa4a6b43..30ad33be 100644 --- a/src/hyfi/__cli__.py +++ b/src/hyfi/__cli__.py @@ -6,6 +6,7 @@ from .env import HyfiConfig, __about__, __hydra_version_base__ from .main import DictConfig, HyFI, _about, getLogger +from .utils.copier import Copier logger = getLogger(__name__) @@ -25,10 +26,11 @@ def about(**args): _about(cfg) -def copy_config(**args): +def run_copy(**args): """Copy all config files in the config directory to the current working directory""" - cfg = HyfiConfig(**args) - HyFI.copy_config(cfg) + print(args) + with Copier(**args) as worker: + worker.run_copy() def cli_main(cfg: DictConfig) -> None: diff --git a/src/hyfi/conf/task/__copy_conf__.yaml b/src/hyfi/conf/cmd/about.yaml similarity index 100% rename from src/hyfi/conf/task/__copy_conf__.yaml rename to src/hyfi/conf/cmd/about.yaml diff --git a/src/hyfi/conf/cmd/cpconf.yaml b/src/hyfi/conf/cmd/cpconf.yaml new file mode 100644 index 00000000..62a64b50 --- /dev/null +++ b/src/hyfi/conf/cmd/cpconf.yaml @@ -0,0 +1,9 @@ +# @package _global_ +defaults: + - /project: __init__ + - /copier: conf + +_target_: hyfi.__cli__.run_copy +copier: + src_path: ${project.path.hyfi}/conf + dst_path: conf diff --git a/src/hyfi/conf/config.yaml b/src/hyfi/conf/config.yaml index dc1ff372..6cca7b71 100644 --- a/src/hyfi/conf/config.yaml +++ b/src/hyfi/conf/config.yaml @@ -3,13 +3,12 @@ defaults: - _self_ - about: __init__ - mode: __init__ - - task: __init__ + - cmd: about - override hydra/help: help - override hydra/hydra_logging: colorlog - override hydra/job_logging: colorlog -hyfi_config_module: ${oc.env:HYFI_CONFIG_MODULE,hyfi.conf} hyfi_user_config_path: ${oc.env:HYFI_USER_CONFIG_PATH,.} hydra: searchpath: diff --git a/src/hyfi/conf/copier/conf.yaml b/src/hyfi/conf/copier/conf.yaml new file mode 100644 index 00000000..199ed771 --- /dev/null +++ b/src/hyfi/conf/copier/conf.yaml @@ -0,0 +1,16 @@ +# Source path where to find the template. +src_path: conf +# Destination path where to render the template. +dst_path: . +# User-chosen additional file exclusion patterns. +exclude: +# User-chosen additional file skip patterns. +skip_if_exists: false +# Delete `dst_path` if there's an error? +cleanup_on_error: false +# When `True`, Overwrite files that already exist, without asking. +overwrite: false +# When `True`, produce no real rendering. +dry_run: false +# When `True`, show all output. +verbose: true diff --git a/src/hyfi/conf/hconf.yaml b/src/hyfi/conf/hconf.yaml index 0fd4622f..3316e05b 100644 --- a/src/hyfi/conf/hconf.yaml +++ b/src/hyfi/conf/hconf.yaml @@ -3,13 +3,12 @@ defaults: - _self_ - about: __init__ - mode: __init__ - - task: null + - cmd: null - override hydra/help: help - override hydra/hydra_logging: colorlog - override hydra/job_logging: colorlog -hyfi_config_module: ${oc.env:HYFI_CONFIG_MODULE,hyfi.conf} hyfi_user_config_path: ${oc.env:HYFI_USER_CONFIG_PATH,.} hydra: searchpath: diff --git a/src/hyfi/conf/task/__init__.yaml b/src/hyfi/conf/task/__init__.yaml deleted file mode 100644 index 7855af14..00000000 --- a/src/hyfi/conf/task/__init__.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# @package _global_ -defaults: - - /project: __init__ - -_target_: hyfi.__cli__.about diff --git a/src/hyfi/env.py b/src/hyfi/env.py index 624cd670..1f86cfb1 100644 --- a/src/hyfi/env.py +++ b/src/hyfi/env.py @@ -66,7 +66,7 @@ def _to_config( class AboutConfig(BaseModel): """About Configuration""" - _package_name_: str = "hyfi" + __package_name__: str = "hyfi" name: str = "HyFI" authors: str = "Young Joon Lee " description: str = ( @@ -82,7 +82,7 @@ class Config: @property def config_module(self) -> str: - return f"{self._package_name_}.conf" + return f"{self.__package_name__}.conf" @property def config_path(self) -> str: