Skip to navigation

nemo_gym.data.tasks.harbor.build_options

View as Markdown

The builds table of the run configuration.

BuildOptions carries whether builds are enabled, which tool to use, the repository to push to and the platform to build for. It is read from a Hydra config mapping and, before the run config exists, from the command line overrides and env.yaml by a side-effect-free Hydra parse. The module depends on the build tool list, the repository variable and the platform parser only.

Module Contents

Classes

NameDescription
BuildOptionsHow prepare treats Dockerfiles outside pull and overlay mode: the builds: configuration block.

Functions

NameDescription
_block_from_overridesThe key node (dotted) of the configuration the command names, resolved; a scalar as it is, None when
_build_setting-
_check_platformRefuse a platform setting platform_pair refuses, where it enters.
_merged_cli_configThe configuration the command line names, merged but unresolved, before the run config exists.
build_options_from_overridesThe builds: block of the configuration the command line names (see _block_from_overrides).

Data

BUILDS_KEY

BUILD_SETTINGS

HYDRA_QUIET_OVERRIDES

API

class nemo_gym.data.tasks.harbor.build_options.BuildOptions(
enabled: bool = True,
tool: str | None = None,
repository: str | None = None,
platform: str | None = None,
force: bool = False
)
Dataclass

How prepare treats Dockerfiles outside pull and overlay mode: the builds: configuration block.

tool builds them (buildah, podman or docker; default: the first one on PATH that fits, see nemo_gym.data.tasks.harbor.image_build.detect_tool). repository is the registry path built images are pushed under (default: the NEMO_GYM_BUILD_REPOSITORY variable; unset keeps them local in the Docker daemon). platform is passed to the tool (default linux/amd64). With enabled false nothing is built, and the tasks that need a build are skipped with the loader’s message. With force, a task’s Dockerfile is built even when the task declares [environment].docker_image, as Harbor’s --force-build does, and the task then runs the built image.

enabled
bool = True
force
bool = False
platform
str | None = None
repository
str | None = None
tool
str | None = None
config: collections.abc.Mapping[str, typing.Any] | None
classmethod

The builds: block of a merged configuration dict, applied over the defaults.

config is the merged global configuration (env.yaml, --config files and ++builds.<setting>=<value> overrides) or any dict shaped like it; a missing block keeps every default. Unknown settings, values of the wrong type and a platform the records could not tell from the baseline (an amd64 micro-architecture level above it, see _check_platform) are refused.

nemo_gym.data.tasks.harbor.build_options._block_from_overrides(
overrides: list[str],
key: str,
config_files: collections.abc.Sequence[pathlib.Path] = ()
) -> typing.Any

The key node (dotted) of the configuration the command names, resolved; a scalar as it is, None when absent. Only that node’s own interpolations are evaluated, so a provider block’s credentials are not needed to read a sibling key; a node that is configured but does not resolve (builds: ${missing_profile}) is reported as a configuration error rather than read as absent. Merged as _merged_cli_config does.

nemo_gym.data.tasks.harbor.build_options._build_setting(
block: collections.abc.Mapping[str, typing.Any],
name: str
) -> str | None
nemo_gym.data.tasks.harbor.build_options._check_platform(
block: collections.abc.Mapping[str, typing.Any]
) -> None

Refuse a platform setting platform_pair refuses, where it enters.

An amd64 micro-architecture level above the baseline (linux/amd64/v3) is another platform to docker, but the records keep an image’s os and architecture only, so a sidecar built for it (of a task whose main is prebuilt, with no base image to record first) would be pushed and recorded as linux/amd64 and reused by a later baseline run. ImageBuilder repeats the check for a BuildOptions made in code.

nemo_gym.data.tasks.harbor.build_options._merged_cli_config(
overrides: list[str],
config_files: collections.abc.Sequence[pathlib.Path] = ()
) -> typing.Any

The configuration the command line names, merged but unresolved, before the run config exists.

The sources the user controls, in the global config’s order: config_files, then the files the +config_paths tokens name (from --config and the asset selectors), then env.yaml, then the +/++ overrides. Nothing is resolved here, so a provider block’s credentials are not needed to read a sibling key. The full global config is still parsed once, at dispatch, with the run config added.

nemo_gym.data.tasks.harbor.build_options.build_options_from_overrides(
overrides: list[str]

The builds: block of the configuration the command line names (see _block_from_overrides).

nemo_gym.data.tasks.harbor.build_options.BUILDS_KEY = 'builds'
nemo_gym.data.tasks.harbor.build_options.BUILD_SETTINGS = ('tool', 'repository', 'platform', 'enabled', 'force')
nemo_gym.data.tasks.harbor.build_options.HYDRA_QUIET_OVERRIDES = ('hydra.run.dir=.', 'hydra.output_subdir=null', 'hydra/job_logging=none', 'hydra...