aiaccel.config package#
Submodules#
aiaccel.config.config module#
- aiaccel.config.config.load_config(config_filename: str | Path, parent_config: dict[str, Any] | DictConfig | ListConfig | None = None) DictConfig | ListConfig [source]#
Load YAML configuration
When the user specifies
_base_
, the specified YAML file is loaded as the base, and the original configuration is merged with the base config. If the configuration specified in_base_
also contains_base_
, the process is handled recursively.Additionally, if bootstrap_config is provided, it is merged with the final configuration to ensure any default values or overrides are applied.
- Parameters:
config (Path) – Path to the configuration
parent_config (dict[str, Any] | DictConfig | ListConfig | None) – A configuration that is merged to the loaded configuration. This is intended to define default config paths (e.g., working_directory) dynamically.
- Returns:
The merged configuration of the base config and the original config user_config(DictConfig | ListConfig) : The configuration without
_base_
- Return type:
merge_user_config (DictConfig)
- aiaccel.config.config.overwrite_omegaconf_dumper(mode: str = '|') None [source]#
Overwrites the default string representation in OmegaConf’s YAML dumper.
This function modifies the OmegaConfDumper to represent multi-line strings using the specified style (mode). By default, it uses the | block style for multi-line strings. Single-line strings remain unchanged.
- Parameters:
mode (str, optional) – The YAML style character for multi-line strings. Defaults to “|”.
- aiaccel.config.config.pathlib2str_config(config: ListConfig | DictConfig) ListConfig | DictConfig [source]#
Convert pathlib.Path objects in the configuration to strings.
This function recursively traverses the configuration and replaces all pathlib.Path objects with their string representations. This is useful for saving the configuration in a YAML file, as YAML does not support Path objects.
- Parameters:
config (ListConfig | DictConfig) – The configuration to convert.
- Returns:
The modified configuration with Path objects replaced by strings.
- Return type:
ListConfig | DictConfig
- aiaccel.config.config.print_config(config: ListConfig | DictConfig, line_length: int = 80) None [source]#
Print the given configuration with syntax highlighting.
This function converts pathlib.Path objects to strings before printing, ensuring that the output YAML format remains valid. It also highlights configuration keys in yellow for better readability.
- Parameters:
config (ListConfig | DictConfig) – The configuration to print.
line_length (int, optional) – The width of the separator line (default: 80).
- aiaccel.config.config.resolve_inherit(config: DictConfig | ListConfig) DictConfig | ListConfig [source]#
Resolve _inherit_ in config
Merge the dict in
_inherit_
into a dict of the same hierarchy._inherit_
is specified by omegaconf interpolation- Parameters:
config (DictConfig | ListConfig) – The configuration loaded by load_config
- Returns:
The configuration without
_inherit_
- Return type:
DictConfig | ListConfig
aiaccel.config.git module#
- class aiaccel.config.git.PackageGitStatus(package_name: str, commit_id: str, status: list[str])[source]#
Bases:
object
Represents the Git status of a package.
- package_name#
The name of the package.
- Type:
str
- commit_id#
The current Git commit ID of the repository.
- Type:
str
- status#
A list of uncommitted files in the repository.
- Type:
list[str]
- commit_id: str#
- package_name: str#
- ready() bool [source]#
Determines if there are no uncommitted changes.
- Returns:
True if there are no uncommitted files, otherwise False.
- Return type:
bool
- status: list[str]#
- aiaccel.config.git.collect_git_status_from_config(config: DictConfig | ListConfig) list[PackageGitStatus] [source]#
Collects the Git status of packages specified in the given configuration.
- Parameters:
config (DictConfig | ListConfig) – The configuration containing package references.
- Returns:
- A list of PackageGitStatus objects representing
the Git status of the detected packages.
- Return type:
list[PackageGitStatus]
- aiaccel.config.git.print_git_status(status: PackageGitStatus | list[PackageGitStatus]) None [source]#
Prints the Git status of a package or a list of packages.
- Parameters:
status (PackageGitStatus | list[PackageGitStatus]) – The Git status to print.
Module contents#
- class aiaccel.config.PackageGitStatus(package_name: str, commit_id: str, status: list[str])[source]#
Bases:
object
Represents the Git status of a package.
- package_name#
The name of the package.
- Type:
str
- commit_id#
The current Git commit ID of the repository.
- Type:
str
- status#
A list of uncommitted files in the repository.
- Type:
list[str]
- commit_id: str#
- package_name: str#
- ready() bool [source]#
Determines if there are no uncommitted changes.
- Returns:
True if there are no uncommitted files, otherwise False.
- Return type:
bool
- status: list[str]#
- aiaccel.config.collect_git_status_from_config(config: DictConfig | ListConfig) list[PackageGitStatus] [source]#
Collects the Git status of packages specified in the given configuration.
- Parameters:
config (DictConfig | ListConfig) – The configuration containing package references.
- Returns:
- A list of PackageGitStatus objects representing
the Git status of the detected packages.
- Return type:
list[PackageGitStatus]
- aiaccel.config.load_config(config_filename: str | Path, parent_config: dict[str, Any] | DictConfig | ListConfig | None = None) DictConfig | ListConfig [source]#
Load YAML configuration
When the user specifies
_base_
, the specified YAML file is loaded as the base, and the original configuration is merged with the base config. If the configuration specified in_base_
also contains_base_
, the process is handled recursively.Additionally, if bootstrap_config is provided, it is merged with the final configuration to ensure any default values or overrides are applied.
- Parameters:
config (Path) – Path to the configuration
parent_config (dict[str, Any] | DictConfig | ListConfig | None) – A configuration that is merged to the loaded configuration. This is intended to define default config paths (e.g., working_directory) dynamically.
- Returns:
The merged configuration of the base config and the original config user_config(DictConfig | ListConfig) : The configuration without
_base_
- Return type:
merge_user_config (DictConfig)
- aiaccel.config.overwrite_omegaconf_dumper(mode: str = '|') None [source]#
Overwrites the default string representation in OmegaConf’s YAML dumper.
This function modifies the OmegaConfDumper to represent multi-line strings using the specified style (mode). By default, it uses the | block style for multi-line strings. Single-line strings remain unchanged.
- Parameters:
mode (str, optional) – The YAML style character for multi-line strings. Defaults to “|”.
- aiaccel.config.pathlib2str_config(config: ListConfig | DictConfig) ListConfig | DictConfig [source]#
Convert pathlib.Path objects in the configuration to strings.
This function recursively traverses the configuration and replaces all pathlib.Path objects with their string representations. This is useful for saving the configuration in a YAML file, as YAML does not support Path objects.
- Parameters:
config (ListConfig | DictConfig) – The configuration to convert.
- Returns:
The modified configuration with Path objects replaced by strings.
- Return type:
ListConfig | DictConfig
- aiaccel.config.print_config(config: ListConfig | DictConfig, line_length: int = 80) None [source]#
Print the given configuration with syntax highlighting.
This function converts pathlib.Path objects to strings before printing, ensuring that the output YAML format remains valid. It also highlights configuration keys in yellow for better readability.
- Parameters:
config (ListConfig | DictConfig) – The configuration to print.
line_length (int, optional) – The width of the separator line (default: 80).
- aiaccel.config.print_git_status(status: PackageGitStatus | list[PackageGitStatus]) None [source]#
Prints the Git status of a package or a list of packages.
- Parameters:
status (PackageGitStatus | list[PackageGitStatus]) – The Git status to print.
- aiaccel.config.resolve_inherit(config: DictConfig | ListConfig) DictConfig | ListConfig [source]#
Resolve _inherit_ in config
Merge the dict in
_inherit_
into a dict of the same hierarchy._inherit_
is specified by omegaconf interpolation- Parameters:
config (DictConfig | ListConfig) – The configuration loaded by load_config
- Returns:
The configuration without
_inherit_
- Return type:
DictConfig | ListConfig