81 lines
1.5 KiB
Python
81 lines
1.5 KiB
Python
from dataclasses import dataclass, asdict
|
|
from typing import Any, Dict, Optional
|
|
|
|
|
|
@dataclass
|
|
class Experiment:
|
|
id: str
|
|
name: str
|
|
version: int
|
|
description: str
|
|
metadata: Dict[str, Any]
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return {"type": "Experiment", **asdict(self)}
|
|
|
|
|
|
@dataclass
|
|
class Run:
|
|
id: str
|
|
experiment_id: str
|
|
parameters: Dict[str, Any]
|
|
metrics: Dict[str, Any]
|
|
environment_hash: str
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return {"type": "Run", **asdict(self)}
|
|
|
|
|
|
@dataclass
|
|
class Dataset:
|
|
id: str
|
|
name: str
|
|
version: str
|
|
metadata: Dict[str, Any]
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return {"type": "Dataset", **asdict(self)}
|
|
|
|
|
|
@dataclass
|
|
class Model:
|
|
id: str
|
|
architecture: str
|
|
fingerprint: str
|
|
metadata: Dict[str, Any]
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return {"type": "Model", **asdict(self)}
|
|
|
|
|
|
@dataclass
|
|
class Environment:
|
|
id: str
|
|
language: str
|
|
version: str
|
|
dependencies: Dict[str, str] # package -> version
|
|
container_hash: Optional[str] = None
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return {"type": "Environment", **asdict(self)}
|
|
|
|
|
|
@dataclass
|
|
class EvaluationMetric:
|
|
name: str
|
|
value: float
|
|
unit: str
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return {"type": "EvaluationMetric", **asdict(self)}
|
|
|
|
|
|
@dataclass
|
|
class Policy:
|
|
id: str
|
|
rules: Dict[str, Any]
|
|
metadata: Dict[str, Any]
|
|
|
|
def to_dict(self) -> Dict[str, Any]:
|
|
return {"type": "Policy", **asdict(self)}
|