src.core.configurator package
Submodules
src.core.configurator.argument_parser module
This module provides command-line argument parsing functionality for a sequencing data processing script.
- It defines:
- IArgumentParser:
An interface (via Protocol) specifying a parse() method that returns parsed arguments.
- ArgumentParser:
Implements IArgumentParser using Python’s argparse module to define and parse command-line arguments.
- Main features:
Supports arguments for log file, output directory,
report language, number of threads, and flags for demultiplexor and table manager. - Provides a clear and extendable way to handle command-line inputs for the script.
- Usage:
Create an instance of ArgumentParser and call its parse() method to get an argparse.Namespace object with all parsed arguments.
- class src.core.configurator.argument_parser.IArgumentParser(*args, **kwargs)[source]
Bases:
ProtocolInterface for argument parser classes. Defines a method parse() that returns parsed command-line arguments.
- static parse() Namespace[source]
Parses command-line arguments and returns a Namespace object containing the arguments.
- _abc_impl = <_abc._abc_data object>
- _is_protocol = True
- class src.core.configurator.argument_parser.ArgumentParser(*args, **kwargs)[source]
Bases:
IArgumentParserImplements argument parsing using argparse for sequencing data processing.
Defines command-line arguments such as log file, output directory, report language, etc.
- static parse() Namespace[source]
Set a list of command line arguments and return a compiled object stored these arguments attributes.
- _abc_impl = <_abc._abc_data object>
- _is_protocol = False
src.core.configurator.config_loader module
This module provides functionality to load configuration settings from a file.
- It defines:
- IConfigLoader:
An interface (via Protocol) that specifies a load() method for loading configuration data.
- ConfigLoader:
Implements IConfigLoader and LoggerMixin to load configuration from an INI file.
- Main features:
Loads configuration from a specified file path,
defaulting to ‘src/conf/config.ini’. - Reads a specific section (default ‘Pathes’) from the configuration file. - Returns a dictionary containing configuration key-value pairs. - Raises FileNotFoundError if the configuration file does not exist. - Raises ConfigurationError if the section is missing or invalid.
- Usage:
Instantiate ConfigLoader, optionally passing a logger, and call load() with the desired file path and section.
- class src.core.configurator.config_loader.IConfigLoader(*args, **kwargs)[source]
Bases:
ProtocolInterface for configuration loader classes. Defines a load() method to load configuration data.
- load() dict[source]
Loads configuration from a file.
- Returns:
A dictionary containing the loaded configuration. Returns an empty dictionary if the file doesn’t exist or is invalid.
- Raises:
FileNotFoundError – if loading fails.
- _abc_impl = <_abc._abc_data object>
- _is_protocol = True
- class src.core.configurator.config_loader.ConfigLoader(logger: Logger | None = None)[source]
Bases:
LoggerMixin,IConfigLoaderLoads configuration data from an INI file, with logging support.
- load(base_config_filepath: PathLike | None = '/home/docs/checkouts/readthedocs.org/user_builds/ngs-analyzer/checkouts/latest/docs/source/src/conf/config.ini', target_section: AnyStr = 'Pathes') dict[source]
Loads configuration from the specified INI file and section.
- Parameters:
base_config_filepath (PathLike) – Path to the configuration file.
target_section (str) – Section in the configuration file to load.
- Returns:
Dictionary with configuration entries from the section.
- Return type:
- Raises:
FileNotFoundError – if the configuration file does not exist.
ConfigurationError – if the section is missing or cannot be parsed.
- _abc_impl = <_abc._abc_data object>
- _is_protocol = False
src.core.configurator.configuration_error module
This module provides the base ConfigurationError exception for the project.
src.core.configurator.logging_configurator module
This module provides functions for validating and potentially creating file and directory paths. It aims to ensure consistent path handling throughout a larger system, preventing errors related to missing or incorrectly specified paths. The module leverages the IPathValidator interface for flexibility and maintainability.
- Functions:
- validate_path:
Validates a path and optionally creates it if it doesn’t exist.
- Classes:
- FileValidator:
Validates file paths, checking for existence and potentially raising exceptions.
- DirectoryValidator:
Validates directory paths, checking for existence and potentially creating directories.
- IPathValidator:
Abstract base class defining the contract for path validation.
- class src.core.configurator.logging_configurator.ILoggingConfigurator(*args, **kwargs)[source]
Bases:
ProtocolProtocol for configuring logging. Implementations should provide a method to set a logger instance.
- set_logger(silent: bool = False) Logger[source]
Configures and returns a logger instance.
- Parameters:
silent (bool, optional) – If True, suppresses output to console. Defaults to False.
- Returns:
Configured logger instance.
- Return type:
- _abc_impl = <_abc._abc_data object>
- _is_protocol = True
- class src.core.configurator.logging_configurator.LoggingConfigurator(path_validator: IPathValidator, log_path: PathLike = '.', args: Namespace = None)[source]
Bases:
ILoggingConfiguratorConfigures logging to a specified file or console.
- _abc_impl = <_abc._abc_data object>
- _is_protocol = False
- set_logger(silent: bool = False) Logger[source]
Sets up logging configuration, creating log files and handlers.
- Parameters:
silent (bool) – If True, disables console output. Defaults to False.
- Returns:
Configured logger instance.
- Return type:
- Raises:
SystemExit – If verification or creation of log path fails.
src.core.configurator.path_validator module
This module defines an interface for validating file paths.
The IPathValidator protocol outlines the method for verifying the existence of a given path.
It’s designed to be used by classes that need to ensure the validity of file paths before proceeding with operations.
The module also imports necessary modules, including logging for logging, os for path manipulation, and typing for type hinting.
Crucially, it imports touch from src.core.base which provides a function to create a file or directory if it doesn’t exist.
- class src.core.configurator.path_validator.IPathValidator(*args, **kwargs)[source]
Bases:
ProtocolInterface for validating file or directory paths.
This abstract class defines the contract for classes responsible for verifying the existence and potentially creating paths.
Subclasses must implement the verify_path method.
This class is intended to be used in a larger system to enforce consistent path handling and validation.
- verify_path(src: PathLike, create_if_missing: bool = False) bool[source]
Verifies the existence of the specified path.
- _abc_impl = <_abc._abc_data object>
- _is_protocol = True
- class src.core.configurator.path_validator.PathValidator(logger: Logger = None)[source]
Bases:
LoggerMixin,IPathValidatorValidates the existence of a file, optionally creating it if missing.
- verify_path(src: PathLike, create_if_missing: bool = False) bool[source]
Checks the existence of the file or directory at the given path src.
If the path does not exist, creates the necessary directories and the file.
- _abc_impl = <_abc._abc_data object>
- _is_protocol = False