Changeset 0540bd0 in flex_extract.git for Source/Python/Mods/tools.py


Ignore:
Timestamp:
Oct 25, 2022, 8:48:28 AM (18 months ago)
Author:
Anne Tipka <anne.tipka@…>
Branches:
dev
Children:
6e16c9d
Parents:
7d77efa
Message:

added option to provide event(ECMWF trigger events) information to CONTROL files and start the job in operational mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Source/Python/Mods/tools.py

    r73d2e4e r0540bd0  
    705705    return job_id.decode()
    706706
    707 def submit_job_to_ecserver(target, jobname):
     707def submit_job_to_ecserver(target, jobfile):
    708708    '''Uses ecaccess-job-submit command to submit a job to the ECMWF server.
    709709
     
    719719        The target where the file should be sent to, e.g. the queue.
    720720
    721     jobname : str
     721    jobfile : str
    722722        The name of the jobfile to be submitted to the ECMWF server.
    723723
     
    730730    try:
    731731        job_id = subprocess.check_output(['ecaccess-job-submit', '-queueName',
    732                                           target, jobname])
     732                                          target, jobfile])
     733
     734    except subprocess.CalledProcessError as e:
     735        print('... ERROR CODE: ' + str(e.returncode))
     736        print('... ERROR MESSAGE:\n \t ' + str(e))
     737
     738        print('\n... Do you have a valid ecaccess certification key?')
     739        sys.exit('... ecaccess-job-submit FAILED!')
     740    except OSError as e:
     741        print('... ERROR CODE: ' + str(e.errno))
     742        print('... ERROR MESSAGE:\n \t ' + str(e.strerror))
     743
     744        print('\n... Most likely the ECACCESS library is not available!')
     745        sys.exit('... ecaccess-job-submit FAILED!')
     746
     747    return job_id.decode()
     748
     749def submit_eventjob_to_ecserver(target, jobfile, eventid, jobname, ecuid):
     750    '''Uses ecaccess-job-submit command to submit a job to the ECMWF server.
     751
     752    Note
     753    ----
     754    The return value is just for testing reasons. It does not have
     755    to be used from the calling function since the whole error handling
     756    is done in here.
     757
     758    Parameters
     759    ----------
     760    target : str
     761        The target where the file should be sent to, e.g. the queue.
     762
     763    jobfile : str
     764        The name of the jobfile to be submitted to the ECMWF server.
     765
     766    eventid : int
     767        The id number from an event listed by ECMWF through ecaccess-event-list.
     768
     769    jobname : str
     770        The name of the job, helps to distingush between jobs.
     771        Will be shown in the queue and list of jobs.
     772
     773    ecuid : str
     774        The user id on ECMWF server.
     775
     776    Return
     777    ------
     778    job_id : int
     779        The id number of the job as a reference at the ECMWF server.
     780    '''
     781
     782    try:
     783        job_id = subprocess.check_output(['ecaccess-job-submit',
     784                                          '-queueName', target, '-jobName', jobname,
     785                                          '-onStart', '-onSuccess', '-onFailure',
     786                                          '-onRetry', '-retryCount', '5',
     787                                          '-mailTo', ecuid,
     788                                          '-eventIds', eventid,
     789                                          jobfile])
    733790
    734791    except subprocess.CalledProcessError as e:
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG