Source code for revise.backend.contracts

from __future__ import annotations

from abc import ABC
from abc import abstractmethod
from typing import Any, Dict

if False:  # pragma: no cover
    from revise.recon.context import PipelineContext
    from revise.svc import SVC


[docs] class LocalRefinementStrategy(ABC): """Task-level reconstruction strategy contract.""" strategy_id: str
[docs] @abstractmethod def prepare_context(self, ctx: "PipelineContext") -> None: raise NotImplementedError
[docs] @abstractmethod def global_anchoring(self, ctx: "PipelineContext") -> None: raise NotImplementedError
[docs] def prepare_local_units(self, ctx: "PipelineContext") -> None: return None
[docs] def build_graph(self, ctx: "PipelineContext") -> None: return None
[docs] def build_ot_problem(self, ctx: "PipelineContext") -> None: return None
[docs] @abstractmethod def solve_ot(self, ctx: "PipelineContext") -> None: raise NotImplementedError
[docs] def update_expression(self, ctx: "PipelineContext") -> None: return None
[docs] @abstractmethod def finalize_svc(self, ctx: "PipelineContext") -> "SVC": raise NotImplementedError
class InputValidationPolicy(ABC): @abstractmethod def validate(self, ctx: "PipelineContext") -> None: raise NotImplementedError class EvaluationPolicy(ABC): @abstractmethod def should_evaluate(self, ctx: "PipelineContext") -> bool: raise NotImplementedError
[docs] class PlatformAdapter(ABC):
[docs] @abstractmethod def adapt(self, payload: Dict[str, Any]) -> Dict[str, Any]: raise NotImplementedError
[docs] class OTSolver(ABC):
[docs] @abstractmethod def solve(self, payload: Dict[str, Any]) -> Any: raise NotImplementedError
[docs] class CFStrategy(ABC):
[docs] @abstractmethod def apply(self, payload: Dict[str, Any]) -> Dict[str, Any]: raise NotImplementedError