def create_wf_task(task, cdump='gdas', cycledef=None, envar=None, dependency=None, \ metatask=None, varname=None, varval=None, vardict=None, \ final=False): if metatask is None: taskstr = f'{task}' else: taskstr = f'{task}#{varname}#' metataskstr = f'{cdump}{metatask}' metatask_dict = {'metataskname': metataskstr, \ 'varname': f'{varname}', \ 'varval': f'{varval}', \ 'vardict': vardict} taskstr = f'{cdump}{taskstr}' cycledefstr = cdump if cycledef is None else cycledef task_dict = {'taskname': f'{taskstr}', \ 'cycledef': f'{cycledefstr}', \ 'maxtries': '&MAXTRIES;', \ 'command': f'&JOBS_DIR;/{task}.sh', \ 'jobname': f'&PSLOT;_{taskstr}_@H', \ 'account': '&ACCOUNT;', \ 'queue': f'&QUEUE_{task.upper()}_{cdump.upper()};', \ 'walltime': f'&WALLTIME_{task.upper()}_{cdump.upper()};', \ 'native': f'&NATIVE_{task.upper()}_{cdump.upper()};', \ 'memory': f'&MEMORY_{task.upper()}_{cdump.upper()};', \ 'resources': f'&RESOURCES_{task.upper()}_{cdump.upper()};', \ 'log': f'&ROTDIR;/logs/@Y@m@d@H/{taskstr}.log', \ 'envar': envar, \ 'dependency': dependency, \ 'final': final} # Add PARTITION_BATCH to all non-service jobs on Orion (SLURM) if get_scheduler(detectMachine()) in ['slurm'] and detectMachine() in [ 'ORION', 'JET' ]: task_dict['partition'] = '&PARTITION_BATCH;' # Add PARTITION_SERVICE to all service jobs (SLURM) if get_scheduler(detectMachine()) in ['slurm'] and task in [ 'getic', 'arch', 'earc' ]: task_dict['partition'] = f'&PARTITION_{task.upper()}_{cdump.upper()};' if metatask is None: task = rocoto.create_task(task_dict) else: task = rocoto.create_metatask(task_dict, metatask_dict) task = ''.join(task) return task
def create_wf_task(task, cdump='gdas', cycledef=None, envar=None, dependency=None, \ metatask=None, varname=None, varval=None, vardict=None, \ final=False): if metatask is None: taskstr = '%s' % task else: taskstr = '%s#%s#' % (task, varname) metataskstr = '%s%s' % (cdump, metatask) metatask_dict = {'metataskname': metataskstr, \ 'varname': '%s' % varname, \ 'varval': '%s' % varval, \ 'vardict': vardict} taskstr = '%s%s' % (cdump, taskstr) cycledefstr = cdump if cycledef is None else cycledef task_dict = {'taskname': '%s' % taskstr, \ 'cycledef': '%s' % cycledefstr, \ 'maxtries': '&MAXTRIES;', \ 'command': '&JOBS_DIR;/%s.sh' % task, \ 'jobname': '&PSLOT;_%s_@H' % taskstr, \ 'account': '&ACCOUNT;', \ 'queue': '&QUEUE_%s_%s;' % (task.upper(), cdump.upper()), \ 'walltime': '&WALLTIME_%s_%s;' % (task.upper(), cdump.upper()), \ 'native': '&NATIVE_%s_%s;' % (task.upper(), cdump.upper()), \ 'memory': '&MEMORY_%s_%s;' % (task.upper(), cdump.upper()), \ 'resources': '&RESOURCES_%s_%s;' % (task.upper(), cdump.upper()), \ 'log': '&ROTDIR;/logs/@Y@m@d@H/%s.log' % taskstr, \ 'envar': envar, \ 'dependency': dependency, \ 'partition' : '&PARTITION_%s_%s;' % (task.upper(),cdump.upper()), \ 'final': final} if task in ['getic', 'arch', 'earc'] and check_slurm(): task_dict['partition'] = '&PARTITION_%s_%s;' % (task.upper(), cdump.upper()) else: task_dict['partition'] = None if metatask is None: task = rocoto.create_task(task_dict) else: task = rocoto.create_metatask(task_dict, metatask_dict) task = ''.join(task) return task