Python client library for DC/OS Metronome. This library inspired by thefactory/marathon-python.
- For Metronome 0.2.0, use at least dcos-metronome-python 0.3.0
- Run integration tests on CircleCI with docker-compose
- Create schedules at the same time when call
create_job
.
pip install dcos-metronome
TODO
Create a MetronomeClient()
instance pointing at your Metronome server(s):
>>> from metronome import MetronomeClient
>>> c = MetronomeClient('http://localhost:8080')
>>> # or multiple servers:
>>> c = MetronomeClient(['http://host1:8080', 'http://host2:8080'])
Then try calling some methods:
>>> c.list_jobs()
[id: "example"
description: "Example Job"
labels {
key: "location"
value: "olympus"
}
...
]
Create job
>>> from google.protobuf.json_format import Parse
>>> from metronome.models import JobSpec
>>> json_text = """{"description":"desc","id":"example","labels":{},"run":{"artifacts":[],"cmd":"example","cpus":0.1,"disk":0,"env":{},"maxLaunchDelay":3600,"mem":32,"restart":{"activeDeadlineSeconds":120,"policy":"NEVER"},"volumes":[]}}"""
>>> job = Parse(json_text, JobSpec())
>>> c.create_job(job)
id: "example"
description: "desc"
run {
cpus: 0.1
mem: 32.0
cmd: "example"
placement {
}
maxLaunchDelay: 3600
restart {
policy: NEVER
activeDeadlineSeconds: 120
}
}
Other methods
- create_job
- list_jobs
- get_job
- update_job
- delete_job
- create_schedule
- list_schedules
- get_schedule
- update_schedule
- delete_schedule
- run_job
- list_runs
- get_run
- stop_run
- ping
See following code for details.
Not implemented (TODO)
- /v1/metrics (GET)
- /v0/scheduled-jobs (POST)
- /v0/scheduled-jobs/{jobId} (PUT)
brew install protobuf
# protoc --version
# libprotoc 3.2.0
pip install -r requirements.txt
pip install tox
make tests
make itests
# edit protobuf/metronome.proto
make codegen
make package
make publish
Open source under the MIT License. See LICENSE.