Docker images¶
The Docker images femforge builds, the femforge-elmer solver image, and the environment probe that checks this machine can mesh and solve.
femforge.execution.docker.image
¶
Images femforge builds itself: apt install scripts from typed sections, version tags guarded by a recipe hash, and the build on first use.
Classes:
-
AptPackage–An apt package an image installs and why it needs it.
-
DockerImage–An image a tool runs in: a published or built recipe image, or with no recipe, a tag Docker has or pulls.
-
ImageRecipe–An image femforge builds itself, with the version and recipe hash it was last released at.
-
Section–One titled block of an install script, listing each package it installs with its reason.
Functions:
-
apt_install–An
apt-get installofpackages, one per line. -
ensure_image–Make Docker hold
image: reuse a matching local tag, else pull a published one, else build its recipe; checked once per tag per process. -
install_run–A Dockerfile
RUNheredoc that runssectionsas one strict, non-interactive shell script.
Attributes:
-
REGISTRY–The registry namespace femforge publishes its released images under.
REGISTRY
module-attribute
¶
The registry namespace femforge publishes its released images under.
AptPackage
dataclass
¶
An apt package an image installs and why it needs it.
Attributes:
-
build_only(bool) –Whether the install purges the package once it is done with it.
DockerImage
dataclass
¶
DockerImage(tag: str, dockerfile: str | None = None, probe: tuple[str, ...] = (), published: bool = False, platform: str | None = None, labels: tuple[str, ...] = ())
An image a tool runs in: a published or built recipe image, or with no recipe, a tag Docker has or pulls.
Attributes:
-
probe(tuple[str, ...]) –A command run in the fresh image whose output the build logs, such as the installed tool's version.
-
published(bool) –Whether a registry serves the tag, so it is pulled before it is built.
-
platform(str | None) –The platform the image is pulled, built and run for, such as
linux/amd64; None lets Docker choose. -
labels(tuple[str, ...]) –The
KEY=VALUElabels a build stamps beside the recipe label. -
platform_args(list[str]) –The
--platformoption of a docker command, empty without a platform.
probe
class-attribute
instance-attribute
¶
A command run in the fresh image whose output the build logs, such as the installed tool's version.
published
class-attribute
instance-attribute
¶
published: bool = False
Whether a registry serves the tag, so it is pulled before it is built.
platform
class-attribute
instance-attribute
¶
platform: str | None = None
The platform the image is pulled, built and run for, such as linux/amd64; None lets Docker choose.
labels
class-attribute
instance-attribute
¶
The KEY=VALUE labels a build stamps beside the recipe label.
ImageRecipe
dataclass
¶
ImageRecipe(name: str, version: str, digest: str, dockerfile: str, source: Path, probe: tuple[str, ...] = (), registry: str = REGISTRY, platform: str | None = None, probe_label: str = '')
An image femforge builds itself, with the version and recipe hash it was last released at.
Methods:
-
image–The released image under the registry, or while the recipe differs from the released one, a local dev image that is never published.
Attributes:
-
digest(str) –The sha256 of the Dockerfile released as
version. -
source(Path) –The module whose
IMAGE_VERSIONandIMAGE_DIGESTlines a bump rewrites. -
registry(str) –The registry namespace a released version is published under.
-
platform(str | None) –The platform the image is built for and runs on; None lets Docker choose.
-
probe_label(str) –What
probereports the version of, such aselmerfem-csc.
source
instance-attribute
¶
source: Path
The module whose IMAGE_VERSION and IMAGE_DIGEST lines a bump rewrites.
registry
class-attribute
instance-attribute
¶
The registry namespace a released version is published under.
platform
class-attribute
instance-attribute
¶
platform: str | None = None
The platform the image is built for and runs on; None lets Docker choose.
probe_label
class-attribute
instance-attribute
¶
probe_label: str = ''
What probe reports the version of, such as elmerfem-csc.
image
¶
image() -> DockerImage
The released image under the registry, or while the recipe differs from the released one, a local dev image that is never published.
Source code in src/femforge/execution/docker/image.py
Section
dataclass
¶
Section(title: str, commands: tuple[str, ...], packages: tuple[AptPackage, ...] = ())
One titled block of an install script, listing each package it installs with its reason.
Methods:
-
render–The block as shell lines: a dashed banner, the package reasons, then the commands.
render
¶
render() -> str
The block as shell lines: a dashed banner, the package reasons, then the commands.
Source code in src/femforge/execution/docker/image.py
apt_install
¶
apt_install(packages: tuple[AptPackage, ...]) -> str
An apt-get install of packages, one per line.
Source code in src/femforge/execution/docker/image.py
ensure_image
¶
ensure_image(image: DockerImage, docker: DockerCli, *, pull: bool = True) -> None
Make Docker hold image: reuse a matching local tag, else pull a published one, else build its recipe; checked once per tag per process.
A tag without a recipe is pulled when Docker lacks it and never built, so a failed pull raises DockerError.
Parameters:
-
image(DockerImage) –The image to make available.
-
docker(DockerCli) –The client to run Docker through.
-
pull(bool, default:True) –Try the registry before building a published recipe.
Source code in src/femforge/execution/docker/image.py
install_run
¶
A Dockerfile RUN heredoc that runs sections as one strict, non-interactive shell script.
Source code in src/femforge/execution/docker/image.py
femforge.elmer.runtime.docker_image
¶
The femforge-elmer Docker image: headless Elmer from CSC's PPA on Ubuntu 24.04, with Open MPI and MUMPS.
Functions:
-
dockerfile–The image's Dockerfile, generated from
INSTALL.
Attributes:
-
ELMER_IMAGE–The image Elmer runs in under the Docker backend.
ELMER_IMAGE
module-attribute
¶
ELMER_IMAGE = ImageRecipe(name='femforge-elmer', version=IMAGE_VERSION, digest=IMAGE_DIGEST, dockerfile=dockerfile(), source=Path(__file__), probe=('dpkg-query', '--show', '--showformat=${Version}', ELMER_PACKAGE.name), platform=PLATFORM, probe_label=ELMER_PACKAGE.name)
The image Elmer runs in under the Docker backend.
dockerfile
¶
dockerfile() -> str
The image's Dockerfile, generated from INSTALL.
Source code in src/femforge/elmer/runtime/docker_image.py
femforge.doctor
¶
femforge doctor: check that this machine can mesh and solve, and name the fix for whatever it cannot.
Classes:
-
Check–One doctor check: what it looked at, how it went, and how to fix it.
-
CheckName–The checks, in the order the doctor runs them.
-
CheckStatus–How a check went.
-
DoctorReport–Every doctor check in order, with the count of blockers and warnings.
Functions:
-
add_arguments–The
femforge doctoroptions. -
diagnose–Run every check against this machine.
-
render–Print the checks as a table, then the numbered fixes and the count of blockers and warnings.
-
run–Run the checks and report them; the exit code is 1 when any check failed.
Attributes:
-
COMMAND–The
femforgesubcommand.
Check
pydantic-model
¶
Bases: BaseModel
One doctor check: what it looked at, how it went, and how to fix it.
Config:
use_attribute_docstrings:True
Fields:
CheckStatus
¶
DoctorReport
pydantic-model
¶
Bases: BaseModel
Every doctor check in order, with the count of blockers and warnings.
Config:
use_attribute_docstrings:Truejson_schema_mode_override:serialization
Fields:
add_arguments
¶
add_arguments(parser: ArgumentParser) -> None
The femforge doctor options.
Source code in src/femforge/doctor.py
diagnose
¶
diagnose(runs_dir: Path, artifacts: Path | None = None, *, docker: DockerCli | None = None, recipe: ImageRecipe = ELMER_IMAGE) -> DoctorReport
Run every check against this machine.
Parameters:
-
runs_dir(Path) –The runs directory whose disk is checked.
-
artifacts(Path | None, default:None) –The artifact store whose disk is checked; None skips that check.
-
docker(DockerCli | None, default:None) –The Docker client to probe through; None makes one.
-
recipe(ImageRecipe, default:ELMER_IMAGE) –The image recipe whose image is checked.
Source code in src/femforge/doctor.py
render
¶
render(report: DoctorReport, console: Console) -> None
Print the checks as a table, then the numbered fixes and the count of blockers and warnings.
Source code in src/femforge/doctor.py
run
¶
Run the checks and report them; the exit code is 1 when any check failed.
Parameters:
-
args(Namespace) –The parsed
femforge doctoroptions. -
console(Console) –Where the table goes.
-
artifacts(str | None) –The artifact store root from the environment, or None.