Commit a10e3713 authored by Carles Garcia Cabot's avatar Carles Garcia Cabot Committed by Mihai Patrascoiu
Browse files

Add parsing of params in bulk file

parent 05e4498a
......@@ -172,8 +172,9 @@ class JobSubmitter(Base):
def _build_transfers(self):
if self.options.bulk_file:
filecontent = open(self.options.bulk_file).read()
bulk = json.loads(filecontent)
with open(self.options.bulk_file, 'r') as file:
filecontent = file.read()
bulk = json.loads(filecontent)
if "files" in bulk:
return bulk["files"]
elif "Files" in bulk:
......@@ -184,6 +185,15 @@ class JobSubmitter(Base):
else:
return [{"sources": [self.source], "destinations": [self.destination]}]
def _build_params(self):
with open(self.options.bulk_file, 'r') as file:
filecontent = file.read()
bulk = json.loads(filecontent)
params = None
if 'params' in bulk:
params = bulk['params']
return params
def _do_submit(self, context):
#Backwards compatibility: compare_checksum parameter
if self.options.compare_checksum:
......@@ -213,7 +223,8 @@ class JobSubmitter(Base):
submitter = Submitter(context)
job_id = submitter.submit(
self._build_transfers(),
transfers=self._build_transfers(),
params=self._build_params(),
checksum=self.checksum,
bring_online=self.options.bring_online,
archive_timeout=self.options.archive_timeout,
......
......@@ -27,10 +27,12 @@ class Submitter(object):
self.context = context
@staticmethod
def build_submission(transfers=None, delete=None, staging=None, **kwargs):
def build_submission(transfers=None, delete=None, staging=None, params=None, **kwargs):
job = dict()
job['params'] = dict()
if params:
job['params'] = params
else:
job['params'] = dict()
job['params'].update(kwargs)
if delete:
......@@ -55,8 +57,11 @@ class Submitter(object):
return json.dumps(job, indent=2)
def submit(self, transfers=None, delete=None, **kwargs):
job = Submitter.build_submission(transfers, delete, **kwargs)
def submit(self, transfers=None, delete=None, params=None, **kwargs):
job = Submitter.build_submission(transfers=transfers,
delete=delete,
params=params,
**kwargs)
r = json.loads(self.context.post_json('/jobs', job))
return r['job_id']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment