__init__

msAI package initialization.

See package README for introduction.

Todo
  • Move configuration functions to separate modules

class msAI.__init__.LogMode[source]

Bases: enum.Enum

Enumeration of arguments accepted by the set_logging function’s mode parameter.

See set_logging for mode details.

DEV = 1

Specifies logging mode for development.

RELEASE = 2

Specifies logging mode for release.

LIB = 3

Specifies logging mode for use as a library.

NONE = 4

Specifies a silent logging mode.

msAI.__init__.set_logging(mode: msAI.__init__.LogMode) → logging.Logger[source]

Configures msAI logging for development, release, library, or silent use.

Parameters

mode

The logging configuration to set.

LogMode.DEV:
  • Logging exceptions will be raised

  • Messages of severity INFO and higher are displayed on console

  • Messages of severity DEBUG and higher are saved to the log file

  • Log file is overwritten each run

LogMode.RELEASE:
  • Logging exceptions will NOT be raised

  • Messages of severity WARNING and higher are displayed on console

  • Messages of severity INFO and higher are saved to the log file

  • All log files are saved for each run - named with date/time

LogMode.LIB:
  • Logging exceptions will NOT be raised

  • Log handlers are left unconfigured Python default will write messages or severity WARNING or higher to console

LogMode.NONE:
  • Logging exceptions will NOT be raised

  • Root logger will use NullHandler to prevent messages from being displayed

Returns

The msAI root logger.

Raises

RootError – For an invalid logging mode.

msAI.__init__.set_mp_support(mode: str = 'auto', workers: Union[str, int] = 'auto') → Tuple[bool, int][source]

Configures msAI multiprocessing.

The package variable MP_SUPPORT is a boolean set to enable / disable multiprocessing in the msAI package. This is necessary as certain operations will fail if the multiprocessing module uses the ‘spawn’ start method. The start method default is determined by OS type.

Parameters
  • mode

    A string specifying the multiprocessing configuration.

    auto: Configures multiprocessing support automatically based on OS. Multiprocessing will be enabled if the multiprocessing start method in use is ‘fork’.

    enable: Manually enables multiprocessing. Errors may occur if multiprocessing is not fully supported by OS.

    disable: Manually disables multiprocessing.

  • workers

    The number of worker processes to use for multiprocessing.

    auto: Sets number of workers to CPU count.

Returns

A Tuple specifying MP_SUPPORT and working count.

Raises

RootError – For an invalid multiprocessing mode.