HPS-MC
JobTemplate Class Reference

Template engine for transforming input job template into JSON job store. More...

Public Member Functions

def __init__ (self, template_file=None, output_file='jobs.json')
 
def add_input_files (self, key, file_list, nreads=1)
 Add new input files to dict of input files. More...
 
def add_itervar (self, name, vals)
 Add new iteration variable to dict of iteration variables. More...
 
def add_itervars (self, iter_dict)
 Add several iter variables at once. More...
 
def add_itervars_json (self, json_file)
 Add iter variables from json file. More...
 
def get_itervars (self)
 Return all combinations of the iteration variables. More...
 
def run (self)
 Generate the JSON jobs from processing the template and write to file. More...
 
def parse_args (self)
 Parse arguments for template engine. More...
 

Public Attributes

 template_file
 template file from which parameters are read More...
 
 env
 
 job_id_start
 start ID for jobs More...
 
 input_files
 dict of input files More...
 
 itervars
 dict of iteration variables More...
 
 output_file
 name of output file More...
 
 template
 
 repeat
 
 max_jobs
 

Private Member Functions

def _get_max_iterations (self)
 Get the maximum number of iterations based on file input parameters. More...
 
def _create_jobs (self)
 
def _read_input_file_list (self, input_file_list)
 Read the input file list from arg parsing. More...
 

Detailed Description

Template engine for transforming input job template into JSON job store.

Accepts a set of iteration variables of which all combinations will be turned into jobs. Also accepts lists of input files with a unique key from which one or more can be read per job. The user's template should be a JSON dict with jinja2 markup.

Definition at line 98 of file job_template.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  template_file = None,
  output_file = 'jobs.json' 
)

Definition at line 107 of file job_template.py.

Member Function Documentation

◆ _create_jobs()

def _create_jobs (   self)
private

Definition at line 210 of file job_template.py.

◆ _get_max_iterations()

def _get_max_iterations (   self)
private

Get the maximum number of iterations based on file input parameters.

Definition at line 197 of file job_template.py.

◆ _read_input_file_list()

def _read_input_file_list (   self,
  input_file_list 
)
private

Read the input file list from arg parsing.

Definition at line 254 of file job_template.py.

◆ add_input_files()

def add_input_files (   self,
  key,
  file_list,
  nreads = 1 
)

Add new input files to dict of input files.

Parameters
keykey under which new input files are added
file_listlist of new input files to be added
nreadsnbr of times the input files are read
Todo:
check if this is correct

Definition at line 127 of file job_template.py.

◆ add_itervar()

def add_itervar (   self,
  name,
  vals 
)

Add new iteration variable to dict of iteration variables.

Parameters
namename of new variable
valslist of values for iteration variable

Definition at line 137 of file job_template.py.

◆ add_itervars()

def add_itervars (   self,
  iter_dict 
)

Add several iter variables at once.

Parameters
iter_dictnew dict of iteration variables to be added

Definition at line 146 of file job_template.py.

◆ add_itervars_json()

def add_itervars_json (   self,
  json_file 
)

Add iter variables from json file.

Parameters
json_filename of json file

Definition at line 153 of file job_template.py.

◆ get_itervars()

def get_itervars (   self)

Return all combinations of the iteration variables.

Definition at line 159 of file job_template.py.

◆ parse_args()

def parse_args (   self)

Parse arguments for template engine.

Definition at line 272 of file job_template.py.

◆ run()

def run (   self)

Generate the JSON jobs from processing the template and write to file.

Definition at line 172 of file job_template.py.

Member Data Documentation

◆ env

env

Definition at line 110 of file job_template.py.

◆ input_files

input_files

dict of input files

Definition at line 121 of file job_template.py.

◆ itervars

itervars

dict of iteration variables

Definition at line 123 of file job_template.py.

◆ job_id_start

job_id_start

start ID for jobs

Definition at line 119 of file job_template.py.

◆ max_jobs

max_jobs

Definition at line 291 of file job_template.py.

◆ output_file

output_file

name of output file

Definition at line 125 of file job_template.py.

◆ repeat

repeat

Definition at line 289 of file job_template.py.

◆ template

template

Definition at line 176 of file job_template.py.

◆ template_file

template_file

template file from which parameters are read

Definition at line 109 of file job_template.py.


The documentation for this class was generated from the following file: