diff --git a/Source/Python/Classes/ControlFile.py b/Source/Python/Classes/ControlFile.py index 5a1485902e29ad25df6c4786c50d479e5193fb10..6b143835e30f5499e4278b95ceaf8440272ca99f 100644 --- a/Source/Python/Classes/ControlFile.py +++ b/Source/Python/Classes/ControlFile.py @@ -22,6 +22,9 @@ # - update default makefile to None # August 2020 - Leopold Haimberger # - added a class parameter for system installation path +# October 2022 - Anne Tipka (previously Philipp) +# - added class parameter for packingType (compression) of grib messages +# - added class parameter for event trigger for time critical jobs # # @License: # (C) Copyright 2014-2020. @@ -332,6 +335,13 @@ class ControlFile(object): Switch to select the calculation of extra ensemble members for the ELDA stream. It doubles the amount of retrieved ensemble members. + eventid : int + Id for one of the events for time critical jobs 1 at ECMWF servers. + + eventjobname : str + The name the ecaccess-job-submit command will be given. + This is how the job will be recognized in the list of jobs. + logicals : list of str List of the names of logical switches which controls the flow of the program. Default list is ['gauss', 'omega', 'omegadiff', 'eta', @@ -425,6 +435,8 @@ class ControlFile(object): self.purefc = 0 self.rrint = 0 self.doubleelda = 0 + self.eventid = None + self.eventjobname = '' self.logicals = ['gauss', 'omega', 'omegadiff', 'eta', 'etadiff', 'dpdeta', 'cwc', 'wrf', 'ecstorage', diff --git a/Source/Python/Mods/tools.py b/Source/Python/Mods/tools.py index 203dcbe069c50bd7f226ec4e7f6ebf033ce789e2..884668989a5d90d18e34f85f8831cf3cdf279690 100644 --- a/Source/Python/Mods/tools.py +++ b/Source/Python/Mods/tools.py @@ -704,7 +704,7 @@ def submit_sbatch_job(jobname): print('SUBMITTED SBATCH JOB ',jobname) return job_id.decode() -def submit_job_to_ecserver(target, jobname): +def submit_job_to_ecserver(target, jobfile): '''Uses ecaccess-job-submit command to submit a job to the ECMWF server. Note @@ -718,7 +718,7 @@ def submit_job_to_ecserver(target, jobname): target : str The target where the file should be sent to, e.g. the queue. - jobname : str + jobfile : str The name of the jobfile to be submitted to the ECMWF server. Return @@ -729,7 +729,64 @@ def submit_job_to_ecserver(target, jobname): try: job_id = subprocess.check_output(['ecaccess-job-submit', '-queueName', - target, jobname]) + target, jobfile]) + + except subprocess.CalledProcessError as e: + print('... ERROR CODE: ' + str(e.returncode)) + print('... ERROR MESSAGE:\n \t ' + str(e)) + + print('\n... Do you have a valid ecaccess certification key?') + sys.exit('... ecaccess-job-submit FAILED!') + except OSError as e: + print('... ERROR CODE: ' + str(e.errno)) + print('... ERROR MESSAGE:\n \t ' + str(e.strerror)) + + print('\n... Most likely the ECACCESS library is not available!') + sys.exit('... ecaccess-job-submit FAILED!') + + return job_id.decode() + +def submit_eventjob_to_ecserver(target, jobfile, eventid, jobname, ecuid): + '''Uses ecaccess-job-submit command to submit a job to the ECMWF server. + + Note + ---- + The return value is just for testing reasons. It does not have + to be used from the calling function since the whole error handling + is done in here. + + Parameters + ---------- + target : str + The target where the file should be sent to, e.g. the queue. + + jobfile : str + The name of the jobfile to be submitted to the ECMWF server. + + eventid : int + The id number from an event listed by ECMWF through ecaccess-event-list. + + jobname : str + The name of the job, helps to distingush between jobs. + Will be shown in the queue and list of jobs. + + ecuid : str + The user id on ECMWF server. + + Return + ------ + job_id : int + The id number of the job as a reference at the ECMWF server. + ''' + + try: + job_id = subprocess.check_output(['ecaccess-job-submit', + '-queueName', target, '-jobName', jobname, + '-onStart', '-onSuccess', '-onFailure', + '-onRetry', '-retryCount', '5', + '-mailTo', ecuid, + '-eventIds', eventid, + jobfile]) except subprocess.CalledProcessError as e: print('... ERROR CODE: ' + str(e.returncode)) diff --git a/Source/Python/submit.py b/Source/Python/submit.py index 6d5eb8b6d2dded1a25bb3cbd6fcaf3bd703af0b2..0c6c66fb698c98e4207fbae6d59aa2e977c19aab 100755 --- a/Source/Python/submit.py +++ b/Source/Python/submit.py @@ -201,7 +201,10 @@ def submit(jtemplate, c, queue): mk_jobscript(jtemplate, job_file, clist) - job_id = submit_job_to_ecserver(queue, job_file) + #job_id = submit_job_to_ecserver(queue, job_file) + job_id = submit_eventjob_to_ecserver(queue, c.eventjobname, + c.eventid, c.ecuid) + print('The job id is: ' + str(job_id.strip())) print('You should get an email per job with subject flex.hostname.pid')