autonomy_toolkit.utils.atk_config#

Abstracted helper class ATKConfig used for reading/writing configuration files for autonomy-toolkit.

Module Contents#

Classes#

ATKConfig

Helper class that abstracts reading the atk.yml file that defines configurations.

class ATKConfig(filename: pathlib.Path | str, services: List[str], *, compose_file: pathlib.Path | str = '.atk-compose.yml', env_files: List[pathlib.Path | str] = ['.env', 'atk.env'])[source]#

Helper class that abstracts reading the atk.yml file that defines configurations.

Parameters:
  • filename (Union[Path, str]) – The name of the file to read. This can be a path or just the name of the file. The file should be located at or above the current working directory.

  • services (List[str]) – List of services to use when running the docker compose command.

Keyword Arguments:
  • compose_file (Union[Path, str]) – The name of the compose file to use. Relative to filename. Defaults to .atk-compose.yml.

  • env_files (List[Union[Path, str]]) – env_files that are passed to docker compose using the --env-file flag. Defaults to [atk.env, .env].

update_services(arg)[source]#

Uses mergedeep to update the services with the given argument

Parameters:

arg (Any) – The argument to update the services with. This can be a dictionary, list, or any other type that mergedeep supports.

update_services_with_optionals(optionals: List[str]) bool[source]#

Updates the services with the given optionals.

The optionals arg defines which optionals to add to the services. The optionals are defined in the x-optionals field of the atk.yml file.

Parameters:

optionals (List[str]) – List of optionals to add to the services.

write(filename: pathlib.Path | str | None = None) bool[source]#

Dump the config to the compose file to be read by docker compose

read(filename: pathlib.Path | str | None = None) bool[source]#

Read the config to the compose file to be used by docker compose

load(client: DockerClient, opts: List[str]) bool[source]#

Loads the config file using docker compose config

This allows us to use docker’s multi-file loading (e.g. -f <file1>.yaml -f <file2>.yaml), include and other docker compose features.

Parameters:

client (DockerClient) – The docker client to use to write the compose file.