Skip to content

Commit

Permalink
feat(cli): implement run_copy command
Browse files Browse the repository at this point in the history
This commit adds the `run_copy` command to the CLI, which copies all configuration files from the configuration directory to the current working directory. It also includes new configuration files necessary to support the new command, such as the `cpconf.yaml` command configuration and `conf.yaml` copier configuration. Additionally, `__init__.yaml` task configuration was renamed to `about.yaml`.
  • Loading branch information
entelecheia committed May 4, 2023
1 parent 74be1dc commit 0da557b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 14 deletions.
8 changes: 5 additions & 3 deletions src/hyfi/__cli__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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:
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions src/hyfi/conf/cmd/cpconf.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions src/hyfi/conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions src/hyfi/conf/copier/conf.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions src/hyfi/conf/hconf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 0 additions & 5 deletions src/hyfi/conf/task/__init__.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions src/hyfi/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <entelecheia@hotmail.com>"
description: str = (
Expand All @@ -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:
Expand Down

0 comments on commit 0da557b

Please sign in to comment.