configuration
Configuration
SCT General Configuration.
Attributes
Classes
GeneralConfiguration
dataclass
SCT general configuration
Attributes
Methods:
__init__
__init__(save_log: bool = True, save_config_copy: bool = True, toml_path: Path | None = None) -> None
from_toml
classmethod
Generating a GeneralConfiguration dataclass from a .toml configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
str | Path
|
path to the .toml configuration file |
required |
Returns:
| Type | Description |
|---|---|
GeneralConfiguration
|
GeneralConfiguration dataclass set from .toml file |
to_toml
Saving to disk a .toml file from the dataclass instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_file
|
Path
|
path to the output .toml file |
required |
Functions:
SCT Abstract Base Class for Analyses Configurations.
Common utilities for analyses configurations.
Classes
InvalidConfigurationFile
Bases: RuntimeError
Invalid SCT .toml configuration file
Functions:
toml_schema_validation
Logger
SCT Logger
Attributes
Classes
AnsiColors
ConsoleFormatter
Bases: Formatter
Custom logger formatter with colors
Attributes
fmt
class-attribute
instance-attribute
FORMATS
class-attribute
instance-attribute
FORMATS = {logging.DEBUG: AnsiColors.GREY.value + fmt + AnsiColors.RESET.value, logging.INFO: AnsiColors.GREY.value + fmt + AnsiColors.RESET.value, logging.WARNING: AnsiColors.YELLOW.value + fmt + AnsiColors.RESET.value, logging.ERROR: AnsiColors.RED.value + fmt + AnsiColors.RESET.value, logging.CRITICAL: AnsiColors.BOLD_RED.value + fmt + AnsiColors.RESET.value, logging.FAIL: AnsiColors.BOLD.value + AnsiColors.HIGHLIGHT_RED.value + fmt + AnsiColors.RESET.value, logging.SUCCESS: AnsiColors.BOLD.value + AnsiColors.HIGHLIGHT_GREEN.value + fmt + AnsiColors.RESET.value}
Methods:
FileFormatter
Bases: Formatter
Custom logger formatter with colors
ConsoleHandler
Bases: StreamHandler
Custom logging stream handler to centralize logging
SCTFileHandler
Bases: FileHandler
Custom logging file handler to centralize logging
Methods:
__init__
File handler to write log to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
Path
|
log filename |
required |
Functions:
add_logging_level
Comprehensively adds a new logging level to the logging module and the
currently configured logging class.
level_name becomes an attribute of the logging module with the value
levelNum. method_name becomes a convenience method for both logging
itself and the class returned by logging.getLoggerClass() (usually just
logging.Logger). If method_name is not specified, level_name.lower() is
used.
To avoid accidental clobbering of existing attributes, this method will
raise an AttributeError if the level name is already an attribute of the
logging module or if the method name is already present
Example
addLoggingLevel("TRACE", logging.DEBUG - 5) logging.getLogger(name).setLevel("TRACE") logging.getLogger(name).trace("that worked") logging.trace("so did this") logging.TRACE 5
enable_quality_logger
Enabling quality logger with the same handler of the sct common logger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_handler
|
FileHandler | None
|
if provided, a file handler is added to the logger, by default None |
None
|