Source code for config.run_information
import dataclasses
import logging
from logging import Logger
[docs]
@dataclasses.dataclass
class RunInformation:
"""Holds parameters and derived metrics for a run of the dataset generator.
Attributes:
number_of_tickets (int): Total number of tickets to generate.
number_translation_nodes (int): Number of translation nodes per ticket.
graph_runs_per_batch (int): Number of graph executions in each batch.
"""
number_of_tickets: int
number_translation_nodes: int
graph_runs_per_batch: int
def __post_init__(self):
"""Initialize logger and validate batch size."""
self._logger: Logger = logging.getLogger(__name__)
self.__check_batch_size()
@property
def graph_ticket_runs(self) -> int:
"""Calculate how many ticket graphs will be run.
Returns:
int: The number of ticket-graph runs (tickets divided by translation nodes).
"""
return self.number_of_tickets // self.number_translation_nodes
@property
def amount_batches(self) -> int:
"""Calculate how many batches are required.
Returns:
int: Total batches, computed as (tickets / batch size) / translation nodes.
"""
return int(
(self.number_of_tickets / self.graph_runs_per_batch)
/ self.number_translation_nodes
)
def __check_batch_size(self) -> None:
"""Warn if the configured batch size yields zero batches."""
if self.amount_batches == 0:
self._logger.warning(
"Amount of Batches is 0. Change the number of tickets or the batch size."
)