Created
November 2, 2017 09:21
-
-
Save stylesen/6bef23bf6b090249fadfb9700ba5919c to your computer and use it in GitHub Desktop.
Example LAVA job submission python script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import yaml | |
import xmlrpclib | |
USERNAME = "stylesen" | |
TOKEN = "yourtoken" | |
def submit_yaml_job(job_yaml_str): | |
server = xmlrpclib.ServerProxy("http://%s:%s@%s/RPC2" % (USERNAME, TOKEN, | |
sys.argv[1])) | |
try: | |
job_id = server.scheduler.submit_job(job_yaml_str) | |
print "Job %d submitted successfuly." % job_id | |
except xmlrpclib.Fault as e: | |
raise e | |
except: | |
raise | |
def main(): | |
if len(sys.argv) < 4: | |
print ("""usage: submit_job.py HOSTNAME SUBMIT_COUNT JOB_YAML""") | |
exit(1) | |
with open(sys.argv[3], 'r') as stream: | |
job_yaml = stream.read() | |
for count in range(0, int(sys.argv[2])): | |
submit_yaml_job(job_yaml) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment