python-nomad

raw JSON →
2.1.0 verified Mon Apr 27 auth: no python

Client library for Hashicorp Nomad, currently at version 2.1.0. Provides a Pythonic interface to the Nomad HTTP API. Release cadence is irregular with occasional major breaking changes.

pip install python-nomad
error ImportError: cannot import name 'Nomad' from 'nomad'
cause The package is not installed or import path is incorrect. Usually means 'python-nomad' is not installed.
fix
Run 'pip install python-nomad' and ensure you import using 'from nomad import Nomad'.
error AttributeError: 'Nomad' object has no attribute 'jobs'
cause Initialization failed due to missing or invalid host/token, causing the client to not properly set up endpoints.
fix
Verify Nomad host is reachable and token is correct. Ensure host starts with http:// or https://.
error TypeError: get_jobs() got an unexpected keyword argument 'id'
cause Passing keyword argument 'id' to an API method after version 2.0.0, where it was renamed to 'id_'.
fix
Replace 'id=...' with 'id_=...' in your call.
breaking In version 2.0.0, arguments named 'id' and 'type' were renamed to 'id_' and 'type_' to avoid shadowing built-ins. Code using keyword arguments 'id=' or 'type=' will break.
fix Rename 'id' to 'id_' and 'type' to 'type_' in all API calls.
breaking Python 2 and Python 3.6 support dropped in version 2.0.0. Also drop Python 3.5 in 1.5.0.
fix Upgrade to Python 3.7+.
gotcha The environment variable NOMAD_ADDR is not read automatically; you must pass 'host' explicitly to Nomad constructor. Only NOMAD_TOKEN is read from environment by default.
fix Always pass host='http://your-nomad-server:4646' or implement custom env var reading.
deprecated The 'registry' endpoint methods (e.g., client.registry) may be deprecated in favor of 'vars' and 'var' endpoints. Check Nomad API documentation.
fix Use client.vars and client.var for accessing variable endpoints.

Initialise a Nomad client and list all jobs.

from nomad import Nomad

client = Nomad(
    host='http://127.0.0.1:4646',
    token=os.environ.get('NOMAD_TOKEN', ''),
)
jobs = client.jobs.get_jobs()
print(jobs)