hazimp.config_build

Functions to assist in converting a yaml configuration file to jobs and calcs.

Module Contents

Functions

find_attributes(config: dict, keys: Union[str, list]) → Union[str, dict]

Find attributes from config by the preferred key, keys must be

add_job(jobs, new_job, atts=None)

Given a list of jobs, add a new job and it's att's to the job.

get_job_or_calcs(job_names)

Given a list of job or calc names, return a list of job or calc

_get_job_or_calc(name)

Given a job or calc name, return the job or calc instance.

check_1st_level_keys(bad_name)

Give an informative error if a calc name is wrong.

validate_job_instance(job_inst, atts)

Check the job instance for various errors.

file_can_open(file2load)

Check if a file can be opened.

check_files_to_load(atts)

Check the context, based on config attributes.

check_attributes(job_calc_function, config_args)

Check the attributes of the jobs/cal functions for spelling.

Attributes

LOGGER

CONFIGKEYS

SPELLCHECK

hazimp.config_build.LOGGER
hazimp.config_build.CONFIGKEYS
hazimp.config_build.SPELLCHECK
hazimp.config_build.find_attributes(config: dict, keys: Union[str, list]) Union[str, dict]

Find attributes from config by the preferred key, keys must be provided in order of preference.

Parameters:
  • config – configuration

  • keys – configuration element to locate

hazimp.config_build.add_job(jobs, new_job, atts=None)

Given a list of jobs, add a new job and it’s att’s to the job.

Parameters:
  • jobs – A list of jobs.

  • new_job – The new job, as a string.

  • atts – The attributes of the new job.

hazimp.config_build.get_job_or_calcs(job_names)

Given a list of job or calc names, return a list of job or calc instances.

Parameters:

job_names – a list of job or calc names.

Returns:

A list of Job or Calc instances.

hazimp.config_build._get_job_or_calc(name)

Given a job or calc name, return the job or calc instance.

Parameters:

name – The name if a job or calc.

Returns:

A list of Job or Calc instance.

hazimp.config_build.check_1st_level_keys(bad_name)

Give an informative error if a calc name is wrong.

Parameters:

bad_name – A job name that can not be resolved.

Raises:

RuntimeError

hazimp.config_build.validate_job_instance(job_inst, atts)

Check the job instance for various errors.

Parameters:
  • job_inst – A reference to the job function.

  • atts – The function attributes from config.

hazimp.config_build.file_can_open(file2load)

Check if a file can be opened. :param file2load: file. :returns: True if file2load can be opened.

hazimp.config_build.check_files_to_load(atts)

Check the context, based on config attributes.

This function relies on some assumptions. All jobs/calcs that load files label the files as:: * file_name OR * file_list - for a list of files or a file

Parameters:

atts – The function attributes from config.

Raises:

True for testing or RuntimeError

hazimp.config_build.check_attributes(job_calc_function, config_args)

Check the attributes of the jobs/cal functions for spelling. It will check if all attributes are:: * Missing when they are mandatory * typo args

Parameters:
  • job_calc_function – A reference to the job function.

  • config_args – The function attributes from config

Raises:

RuntimeError