Skip to content
Snippets Groups Projects
Commit f3c10881 authored by Detlev Casanova's avatar Detlev Casanova
Browse files

lava-submit: Make metadata optional

parent 6e39bc8a
No related branches found
No related tags found
1 merge request!424Adaptations to ease debugging
......@@ -28,19 +28,16 @@ from urllib.request import urlopen
parser = argparse.ArgumentParser(description="submit LAVA jobs for Apertis")
parser.add_argument('--jobid-file', type=argparse.FileType("w"), help="output file for the list of created job ids")
parser.add_argument('--metadata-file', type=argparse.FileType("r"), required=True,
parser.add_argument('--metadata-file', type=argparse.FileType("r"),
help="set the metadata file location")
parser.add_argument('-u', '--callback-url', type=str, required=True,
parser.add_argument('-u', '--callback-url', type=str,
help="specify the callback URL")
parser.add_argument('--callback-secret', type=str, required=True,
parser.add_argument('--callback-secret', type=str,
help="specify the secret token to use for the callback")
args, unknown = parser.parse_known_args()
# Make job generator generate metadata in a file
try:
metadata = json.load(args.metadata_file)
except Exception as e:
print(f"Cannot load metadata file {e}")
if args.metadata_file and (not args.callback_url or not args.callback_secret):
print("--callback-url and --callback-secret must be set with --metadata-file")
exit(1)
# Run lqa with the given arguments
......@@ -61,17 +58,25 @@ for job in result.stderr.decode('utf-8').splitlines():
submitted.append(job_id)
# Notify the phab bridge about the job
request = {
'status_string': 'submitted',
'metadata': metadata,
'id': job_id,
'token': args.callback_secret
}
try:
urlopen(args.callback_url, data=json.dumps(request).encode('UTF-8'))
except URLError:
pass
if args.metadata_file:
# Load metadata for phabbridge
try:
metadata = json.load(args.metadata_file)
except Exception as e:
print(f"Cannot load metadata file {e}")
continue
# Notify the phab bridge about the job
request = {
'status_string': 'submitted',
'metadata': metadata,
'id': job_id,
'token': args.callback_secret
}
try:
urlopen(args.callback_url, data=json.dumps(request).encode('UTF-8'))
except URLError:
pass
if args.jobid_file:
json.dump({ "jobids": submitted }, args.jobid_file)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment