3. Programmatic Interface

POptUS — a Python package that collects infrastructure and common code that could be used by other Python packages within the POptUS universe.

3.1. Infrastructure

poptus.test(verbosity=1)

Run the full set of tests in the package with results presented to caller using a simple text interface.

This is included so that users can test their actual installation directly or record test results in jupyter notebook output for reproducibility via:

poptus.test()
Parameters:

verbosity – verbosity level to pass to the unittest TestRunner

Returns:

True if all tests in package passed; False, otherwise.

3.2. Logging

poptus.create_logger(configuration=None)

Please refer to the general logging documentation in the User Guide for information on configuring POptUS loggers.

Parameters:

configurationNone or the full logger configuration specified as a dict.

Returns:

If configuration is None, then a standard ouput/standard error logger with the LOG_LEVEL_DEFAULT verbosity level is returned. Otherwise, a logger built with the provided configuration is returned.

poptus.create_log_functions(logger, caller)

Create a set of simple functions that a method can use for logging general information, debug information, warnings, and errors.

Parameters:
  • logger – Concrete logger object derived from AbstractLogger to be used for logging. Typically this will be created with create_logger().

  • caller – Name of element performing the logging. Depending on the logger, this name could appear in each log entry to identify the source of the message

Returns:

(log, log_debug, warn, log_and_abort) logging functions where

  • log(msg) logs the given general message at level LOG_LEVEL_DEFAULT

  • log_debug(msg, level) logs the given debug message at the given debug level, which must be between LOG_LEVEL_MIN_DEBUG and LOG_LEVEL_MAX inclusive

  • warn(msg) logs the given warning message

  • log_and_abort(*Error, msg) logs the given error message and then raises an exception of the given type (e.g., ValueError, TypeError)