80 lines
1.6 KiB
Python
80 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, asdict
|
|
from datetime import datetime
|
|
from typing import Any, Dict, List
|
|
|
|
|
|
def _to_iso(dt: datetime) -> str:
|
|
if isinstance(dt, datetime):
|
|
return dt.isoformat()
|
|
return dt # type: ignore
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class LocalProblem:
|
|
id: str
|
|
domain: str
|
|
assets: Dict[str, Any]
|
|
objectives: List[str]
|
|
constraints: Dict[str, Any]
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return dict(asdict(self))
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class SharedSignals:
|
|
forecast: Dict[str, Any]
|
|
capacity_proxies: Dict[str, Any]
|
|
privacy_budget: float
|
|
version: int
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return dict(asdict(self))
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class PlanDelta:
|
|
delta: Dict[str, Any]
|
|
timestamp: datetime
|
|
author: str
|
|
contract_id: str
|
|
signature: str
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
d = dict(asdict(self))
|
|
d["timestamp"] = _to_iso(self.timestamp)
|
|
return d
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class DualVariables:
|
|
multipliers: Dict[str, float]
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return dict(asdict(self))
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class AuditLog:
|
|
entry: str
|
|
signer: str
|
|
timestamp: datetime
|
|
contract_id: str
|
|
version: int
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
d = dict(asdict(self))
|
|
d["timestamp"] = _to_iso(self.timestamp)
|
|
return d
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class PolicyBlock:
|
|
safety_exposure: float
|
|
data_exposure_limit: float
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return dict(asdict(self))
|