nomad-pydantic

Typed Python models for building, validating, rendering, and managing Nomad jobs.

Build Status codecov License PyPI

nomad-pydantic represents jobs, task groups, tasks, resources, services, volumes, and periodic schedules as Pydantic models. It renders the JSON envelope accepted by nomad job run -json and provides a mockable client for common Nomad CLI lifecycle operations.

from nomad_pydantic import Job, NomadConfiguration, Task, TaskGroup

config = NomadConfiguration(
    job=Job(
        id="hello",
        type="batch",
        task_groups=[
            TaskGroup(
                name="hello",
                tasks=[
                    Task(
                        name="hello",
                        driver="docker",
                        config={"image": "alpine:3", "args": ["echo", "hello"]},
                    )
                ],
            )
        ],
    )
)

config.write()

Documentation

  • Tutorial builds and renders a first job.

  • How-to guides cover Hydra, periodic jobs, and lifecycle operations.

  • Concepts explains the model hierarchy and JSON boundary.

  • API reference documents every public model and client.

Ecosystem

nomad-pydantic follows the same configuration pattern as supervisor-pydantic, systemd-pydantic, and cron-pydantic. The broader declarative Airflow stack is built from airflow-pydantic and airflow-config, with runtime integrations provided by airflow-nomad, airflow-supervisor, airflow-systemd, and airflow-cron.

Installation

pip install nomad-pydantic