From 97ba92f3cffd0c17353595c61bd5d22c7a4e8c4e Mon Sep 17 00:00:00 2001 From: M Bernt Date: Fri, 9 Nov 2018 16:19:16 +0100 Subject: [PATCH] external_runner: load json template first if the JSON is loaded first the cluster_files_directory does not need to be accessible by the real user (ie all users) --- scripts/drmaa_external_runner.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/drmaa_external_runner.py b/scripts/drmaa_external_runner.py index 1e02d740dc3..71dddd8162b 100755 --- a/scripts/drmaa_external_runner.py +++ b/scripts/drmaa_external_runner.py @@ -19,9 +19,7 @@ DRMAA_jobTemplate_attributes = ['args', 'remoteCommand', 'outputPath', 'errorPat 'workingDirectory', 'jobName', 'email', 'project'] -def load_job_template_from_file(jt, filename): - f = open(filename, 'r') - data = json.load(f) +def load_job_template(jt, data): for attr in DRMAA_jobTemplate_attributes: if attr in data: setattr(jt, attr, data[attr]) @@ -116,15 +114,20 @@ def set_user(uid, assign_all_groups): def main(): userid, json_filename, assign_all_groups = validate_paramters() - set_user(userid, assign_all_groups) + # load JSON job template data before changing the user + # then the pbs cluster_files_directory does not need to + # be readable by all users json_file_exists(json_filename) + with open(json_filename, 'r') as f: + data = json.load(f) + set_user(userid, assign_all_groups) # Added to disable LSF generated messages that would interfer with this # script. Fix thank to Chong Chen at IBM. os.environ['BSUB_QUIET'] = 'Y' s = drmaa.Session() s.initialize() jt = s.createJobTemplate() - load_job_template_from_file(jt, json_filename) + load_job_template(jt, data) # runJob will raise if there's a submittion error jobId = s.runJob(jt) s.deleteJobTemplate(jt)