parsing_utils module

class parsing_utils.ArgumentStruct(**entries)[source]

Bases: object

Class that converts a python dictionary into an object with named entries given by the dictionary keys. This structure simplifies the calling convention for accessing the dictionary values (corresponding to problem parameters). After the object instantiation both modes of access (dictionary or object entries) can be used.

class parsing_utils.ListOfListsAction(option_strings, dest, type, **kwargs)[source]

Bases: argparse.Action

This class extends the argparse.Action class by instantiating an argparser that constructs a list-of-lists from an input (command-line option or argument) given as a string.

parsing_utils.args_overwrite_config(args, config)[source]

Overwrite configuration parameters with parameters specified via command-line.

Parameters
  • args (ArgumentParser object) – Parameters specified via command-line

  • config (python dictionary) – Parameters read from configuration file

parsing_utils.check_file_parameters_exists(params_parser, params_benchmark, params_file)[source]

Functionality to verify that the parameters defined in the configuraion file are recognizable by the command line parser (i.e. no uknown keywords are used in the configuration file).

Parameters
  • params_parser (python dictionary) – Includes parameters set via the command line.

  • params_benchmark (python list) – Includes additional parameters defined in the benchmark.

  • params_file (python dictionary) –

    Includes parameters read from the configuration file.

    Global: PARAMETERS_CANDLE : python list

    Includes all the core keywords that are specified in CANDLE.

parsing_utils.check_flag_conflicts(params)[source]
Check if parameters that must be exclusive are used in conjunction.

The check is made against CONFLICT_LIST, a global list that describes parameter pairs that should be exclusive. Raises an exception if pairs of parameters in CONFLICT_LIST are specified simulataneously.

Parameters

params (python dictionary) – list to extract keywords from

parsing_utils.extract_keywords(lst_dict, kw)[source]

Extract the value associated to a specific keyword in a list of dictionaries. Returns the list of values extracted from the keywords.

Parameters
  • lst_dict (python list of dictionaries) – list to extract keywords from

  • kw (string) – keyword to extract from dictionary

parsing_utils.finalize_parameters(bmk)[source]

Utility to parse parameters in common as well as parameters particular to each benchmark.

Parameters

bmk (benchmark object) – Object that has benchmark filepaths and specifications

Returns

gParameters (python dictionary) – Dictionary with all the parameters necessary to run the benchmark. Command line overwrites config file specifications

parsing_utils.get_choice(name)[source]

Maps name string to the right type of argument

parsing_utils.parse_common(parser)[source]

Functionality to parse options. :param parser: Current parser :type parser: ArgumentParser object

parsing_utils.parse_from_dictlist(dictlist, parser)[source]

Functionality to parse options. :param pardict: Specification of parameters :type pardict: python list of dictionaries :param parser: Current parser :type parser: ArgumentParser object