OpenQuake Utilities

The Utils Sub-package

Utility functions that are of interest to and shared by the entire OpenQuake python code base.

version

Utility functions related to OpenQuake version information.

openquake.engine.utils.version.info(version_data)[source]

Return a string with the OpenQuake version infomation.

Version info data set to -1 will be ignored and assumed to have value zero. Release dates that lie more than 30 days in the future are ignored.

Parameters:version_data – A 4-tuple of integers that are the major, minor and sprint number respectively. The last datum is the number of seconds since epoch and represents the release date.
Returns:A string with human readable OpenQuake version information.

config

Various utility functions concerned with configuration.

openquake.engine.utils.config.OQ_CONFIG_FILE_VAR = 'OQ_CONFIG_FILE'

Environment variable name for specifying a custom openquake.cfg. The file name doesn’t matter.

openquake.engine.utils.config.abort_if_no_config_available()[source]

Call sys.exit() if no openquake configuration file is readable.

openquake.engine.utils.config.context(*args, **kwds)[source]

Context manager used to change the parameters of a configuration section on the fly. For use in the tests.

openquake.engine.utils.config.flag_set(section, setting)[source]

True if the given boolean setting is enabled in openquake.cfg

Parameters:
  • section (string) – name of the configuration file section
  • setting (string) – name of the configuration file setting
Returns:

True if the setting is enabled in openquake.cfg, False otherwise

openquake.engine.utils.config.get(section, key)[source]

The configuration value for the given section and key or None.

openquake.engine.utils.config.get_section(section)[source]

A dictionary of key/value pairs for the given section or None.

openquake.engine.utils.config.refresh()[source]

Re-parse config files and refresh the cached configuration.

NOTE: Use with caution. Calling this during some phases of a calculation could cause undesirable side-effects.

tasks

Various utility functions related to splitting work into tasks and/or managing these.

Utility functions related to splitting work into tasks.