skyllh.scripting package
Submodules
skyllh.scripting.argparser module
This module contains utility functions for the argument parser of an analysis script.
- skyllh.scripting.argparser.create_argparser(description=None, options=True)
Creates an argparser with the given description and adds common options useful for analysis scripts.
- Parameters:
description (str | None) – The description for the argparser.
options (bool | dict | None) – If set to None or False, no options will be added. If set to True, all common analysis script options will be added. If set to a dictionary, individual options can be turned on and off. See the
add_argparser_options()
for possible options. Default isTrue
.
- skyllh.scripting.argparser.add_argparser_options(parser, config=True, data_basepath=True, debug_logfile=True, enable_tracing=True, n_cpu=True, seed=True)
Adds common argparser options to the given argparser instance, useful for analysis scripts.
- Parameters:
parser (instance of ArgumentParser) – The instance of ArgumentParser to which options should get added.
config (bool) – If set to
True
, the--config
option of typestr
will be added. It specifies the configuration file. The default value isNone
. The option destination isconfig
.data_basepath (bool) – If set to
True
, the--data-basepath
option of typestr
will be added. It specifies the base path to the data samples. The default value isNone
. The option destination isdata_basepath
.debug_logfile (bool) – If set to
True
, the--debug-logfile
option of typestr
will be added. If notNone
, it specifies the log file for dubug information. The default value isNone
. The option destination isdebug_logfile
.enable_tracing (bool) – If set to
True
, the--enable-tracing
option of typebool
will be added. If specified, enables the logging on the tracing level, i.e. a lot of DEBUG messages. The default value isFalse
. The option destination isenable_tracing
.n_cpu (bool) – If set to
True
, the--n-cpu
option of typeint
will be added. It specifies the number of CPUs to utilize where parallelization is possible. The default value is1
. The option destination isn_cpu
.seed (bool) – If set to
True
, the--seed
option of typeint
will be added. It specifies the seed for the random number generator. The default value is0
. The option destination isseed
.
skyllh.scripting.logging module
This module contains utility functions for logging functionalities of an analysis script.
- skyllh.scripting.logging.setup_logging(cfg, script_logger_name, log_format=None, log_level=20, debug_pathfilename=None)
Installs console handlers for the
skyllh
andscript_logger_name
loggers. If a debug file is specified, file handlers for debug messages will be installed as well.- Parameters:
cfg (instance of Config) – The instance of Config holding the local configuration.
script_logger_name (str) – The name of the logger used by the script.
log_format (str | None) – The format template of the log message. If set to
None
, the format will be taken fromcfg['debugging']['log_format']
.log_level (int) – The log level of the loggers. The default is
logging.INFO
.debug_pathfilename (str | None) – If not
None
, file handlers for DEBUG messages will be installed and those messages will be stored in the given file.
- Returns:
script_logger (instance of logging.Logger) – The logger instance of the script, specified by
script_logger_name
.