aiaccel.config package#

Submodules#

aiaccel.config.config module#

aiaccel.config.config.apply_recursively(func: Callable[[DictConfig | ListConfig], DictConfig | ListConfig]) Callable[[DictConfig | ListConfig], DictConfig | ListConfig][source]#

Recursively apply a function to all elements in a DictConfig or ListConfig.

This function traverses the configuration structure and applies the provided function to each element, allowing for custom transformations or operations.

Parameters:
  • config (DictConfig | ListConfig) – The configuration to traverse.

  • func (callable) – The function to apply to each element.

Returns:

The modified configuration with the function applied.

Return type:

DictConfig | ListConfig

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: DictConfig | ListConfig) DictConfig | ListConfig[source]#
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]#

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: DictConfig | ListConfig) DictConfig | ListConfig[source]#
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]#