Skip to content

Configuration

ADQA is configured using Pydantic models for type safety and validation.

adqa.config.model.ADQAConfig

Bases: BaseModel

Source code in src/adqa/config/model.py
class ADQAConfig(BaseModel):
    Mode: ClassVar[type[ExecutionMode]] = ExecutionMode
    TraceStore: ClassVar[type[TraceStoreType]] = TraceStoreType

    class Presets:
        @staticmethod
        def strict() -> ADQAConfig:
            return ADQAConfig(
                execution_mode=ExecutionMode.AUTOMATIC,
                tracing_enabled=True,
                lineage_enabled=True,
                ml_enabled=True,
                execution=ExecutionConfig(stop_on_block=True),
            )

        @staticmethod
        def advisory() -> ADQAConfig:
            return ADQAConfig(
                execution_mode=ExecutionMode.ADVISORY,
                tracing_enabled=True,
                lineage_enabled=True,
                ml_enabled=True,
            )

        @staticmethod
        def fast() -> ADQAConfig:
            return ADQAConfig(
                execution_mode=ExecutionMode.ADVISORY,
                profiling=ProfilingConfig(enable_ml=False, enable_correlation=False),
            )

    tracing_enabled: bool = False
    lineage_enabled: bool = False
    ml_enabled: bool = False
    trace_store: TraceStoreType | None = None
    execution_mode: ExecutionMode = ExecutionMode.ADVISORY
    profiling: ProfilingConfig = ProfilingConfig()
    detection: DetectionConfig = DetectionConfig()
    scoring: ScoringConfig = ScoringConfig()
    execution: ExecutionConfig = ExecutionConfig()

    @classmethod
    def from_cli_args(
        cls,
        mode: str,
        tracing_enabled: bool,
        ml_enabled: bool,
        lineage_enabled: bool,
        prof_ml_enabled: bool,
        sample_size: int,
        rounding_precision: int,
        profiling_thresholds: dict[str, Any],
        detection_thresholds: dict[str, Any],
        stop_on_block: bool,
    ) -> ADQAConfig:
        return cls(
            execution_mode=ExecutionMode(mode),
            tracing_enabled=tracing_enabled,
            ml_enabled=ml_enabled,
            lineage_enabled=lineage_enabled,
            profiling=ProfilingConfig(
                enable_ml=prof_ml_enabled,
                sample_size=sample_size,
                rounding_precision=rounding_precision,
                thresholds=ProfilingThresholds(**profiling_thresholds),
            ),
            detection=DetectionConfig(
                enable_ml=ml_enabled,
                thresholds=DetectionThresholds(**detection_thresholds),
            ),
            execution=ExecutionConfig(
                stop_on_block=stop_on_block,
            ),
        )

    model_config: ClassVar[ConfigDict] = ConfigDict(
        frozen=True, arbitrary_types_allowed=True
    )

    @model_validator(mode="before")
    @classmethod
    def set_defaults(cls, data: dict[str, Any]) -> dict[str, Any]:
        tracing = data.get("tracing_enabled", False)

        if tracing and data.get("trace_store") is None:
            data["trace_store"] = TraceStoreType.IN_MEMORY

        if not tracing:
            data["trace_store"] = None
            # If tracing is disabled, lineage MUST be disabled
            # too if not explicitly provided
            if "lineage_enabled" not in data:
                data["lineage_enabled"] = False

        return data

    @model_validator(mode="after")
    def validate_config(self) -> ADQAConfig:
        # Lineage requires tracing
        if self.lineage_enabled and not self.tracing_enabled:
            raise ConfigError("Lineage cannot be enabled without tracing")

        # Automatic execution requires tracing
        if self.execution_mode == ExecutionMode.AUTOMATIC and not self.tracing_enabled:
            raise ConfigError("Automatic execution requires tracing")

        # Human-in-loop requires tracing
        if (
            self.execution_mode == ExecutionMode.HUMAN_IN_LOOP
            and not self.tracing_enabled
        ):
            raise ConfigError("Human-in-loop execution requires tracing")

        return self

tracing_enabled = False class-attribute instance-attribute

lineage_enabled = False class-attribute instance-attribute

ml_enabled = False class-attribute instance-attribute

execution_mode = ExecutionMode.ADVISORY class-attribute instance-attribute

profiling = ProfilingConfig() class-attribute instance-attribute

detection = DetectionConfig() class-attribute instance-attribute

scoring = ScoringConfig() class-attribute instance-attribute

execution = ExecutionConfig() class-attribute instance-attribute

adqa.config.model.ProfilingConfig

Bases: BaseModel

Source code in src/adqa/config/model.py
class ProfilingConfig(BaseModel):
    enable_ml: bool = True
    enable_correlation: bool = True
    correlation_method: Literal["pearson", "kendall", "spearman"] = "pearson"
    rounding_precision: int = 4

    # Parallelization & Sampling settings
    max_workers: int | None = None
    sampling_threshold: int = 50000
    sample_size: int = 10000

    # Thresholds
    thresholds: ProfilingThresholds = ProfilingThresholds()

adqa.config.model.DetectionConfig

Bases: BaseModel

Source code in src/adqa/config/model.py
class DetectionConfig(BaseModel):
    enabled: bool = True
    enable_ml: bool = True

    # Thresholds
    thresholds: DetectionThresholds = DetectionThresholds()