tts_tower.checkers

Submodules

tts_tower.checkers.checker_base

class tts_tower.checkers.checker_base.CheckerBase

Bases: ABC

Abstract Base Class for all Tower Checkers.

This class provides the standard interface for defining flight rule logic. It handles the initialization of RuleResults objects based on the defined FR_IDS and manages the execution lifecycle of the check.

These properties and methods must implement: * FR_IDS * INPUTS * _impl_init * _impl_do_rulecheck

abstract class property FR_IDS

List of tuples identifying all of the Rules checked by this checker.

Each entry should be of the form: (“FOO-1234”, 56789)

Where: * “FOO-1234” is the Rule ID * 56789 is the latest approved revision number

Note that this is called FR_IDS because it was originally written with Flight Rules in mind, but it is flexible enough to be any kind of rule.

abstract class property INPUTS

List of tuples identifying all of the InputClients that this checker accepts.

Must be in the order the inputs are accepted in __init__.

Each entry should be of the form: (“input_name”, bool)

Where: * “input_name” is the name of the InputClient previously supplied to the InputManager * True means the checker requires the input * False means the checker will accept None if it’s not available

Init method sets up the RuleResults containers for every Flight Rule ID defined in FR_IDS. If multiple rules are defined, self.rule becomes a dictionary mapping IDs to results. If a single rule is defined, self.rule is the direct RuleResults object.

check_complete()

Check if the rule check has successfully completed.

Returns:

True if checks are complete, False otherwise.

Return type:

bool

do_rulecheck(*args)

Execute the rule checking logic.

This wrapper ensures that the check is only run once. It delegates the actual initialization and checking logic to _impl_init and _impl_do_rulecheck.

Parameters:

args – Variable length argument list containing the inputs requested in INPUTS.

Raises:

Exception – If the checker has already completed its checks.

flag_all_error(message)

Sets the status of all associated rules to ‘ERROR’ with a provided message.

This is typically used when required inputs are missing or malformed, preventing the actual logic from running.

Parameters:

message (str) – The error message to attach to the rule dispositions.

get_rule(rule_id)

Retrieve a specific RuleResults object by its Flight Rule ID.

Parameters:

rule_id (str) – The unique identifier of the flight rule.

Returns:

The requested RuleResults object.

Return type:

RuleResults

Raises:

ValueError – If the checker does not manage the specified rule ID.

yield_rules()

Generator yielding all RuleResult objects managed by this checker.

Yield:

RuleResults object.

Return type:

Iterator[RuleResults]

tts_tower.checkers.checker_manager

class tts_tower.checkers.checker_manager.CheckerManager(checkers)

Bases: object

Manager class responsible for instantiating, configuring, and executing a collection of Checkers.

This class handles the retrieval of required inputs for each checker from the InputManager, executes the checks safely (catching exceptions per checker), and aggregates the final results.

Initializes the manager and instantiates the provided checker classes.

Parameters:

checkers (list[Type[CheckerBase]]) – A list of CheckerBase subclasses to be managed.

do_all_checks(icm)

Executes the rule check logic for all managed checkers.

For each checker: 1. Identifies required inputs defined in checker.INPUTS. 2. Retrieves those inputs from the InputManager (icm). 3. Verifies inputs are present and not in a Failed state. 4. Calls checker.do_rulecheck() with the retrieved inputs. 5. Catches and logs any exceptions causing a checker to fail, ensuring other checkers proceed.

Parameters:

icm (InputManager) – The populated InputManager instance containing data for checks.

get_all_rule_results()

Aggregates the RuleResult objects from all checkers that successfully completed.

Returns:

A flat list of RuleResult objects from all complete checkers.

Return type:

list[RuleResults]

set_rule_status_enum(rule_status_enum_class)

Propagates the specific Rule Status Enum to all managed checkers and their rules.

This sets the initial status of all rules to PENDING.

Parameters:

rule_status_enum_class (EnumMeta) – The Enum class defining valid rule statuses (e.g., PASSED, VIOLATING).

tts_tower.checkers.checker_manager.log_checker_exception(classname, e, tb)

Helper function to standardize logging for exceptions raised within a Checker.

Logs a warning with the exception type and arguments, and a condensed traceback. Also logs the full traceback to debug.

Parameters:
  • classname (type or str) – The class object or name of the Checker where the exception occurred.

  • e (Exception) – The exception instance caught.

  • tb (str) – A formatted traceback string identifying the location of the error.

tts_tower.checkers.util

tts_tower.checkers.util.load_checkers(*source_dirs)

Dynamically imports and retrieves Checker classes from specified module paths.

This function iterates through the provided source directory dot-paths, imports the corresponding modules, and inspects their members to gather all classes that inherit from CheckerBase.

Parameters:

source_dirs (str) – Variable length argument list of Python dot-paths to modules (e.g., ‘my_project.checkers’).

Returns:

A list of discovered Checker class objects (not instances).

Return type:

list