use crate::experiment::{ComputeDevice, CpuArchitecture, ModelParadigm, PlatformEfficiency};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct RecipeResult {
pub recipe_name: String,
pub success: bool,
pub artifacts: Vec<String>,
pub metrics: HashMap<String, f64>,
pub error: Option<String>,
}
impl RecipeResult {
pub fn success(name: impl Into<String>) -> Self {
Self {
recipe_name: name.into(),
success: true,
artifacts: Vec::new(),
metrics: HashMap::new(),
error: None,
}
}
pub fn failure(name: impl Into<String>, error: impl Into<String>) -> Self {
Self {
recipe_name: name.into(),
success: false,
artifacts: Vec::new(),
metrics: HashMap::new(),
error: Some(error.into()),
}
}
pub fn with_artifact(mut self, artifact: impl Into<String>) -> Self {
self.artifacts.push(artifact.into());
self
}
pub fn with_metric(mut self, name: impl Into<String>, value: f64) -> Self {
self.metrics.insert(name.into(), value);
self
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExperimentTrackingConfig {
pub experiment_name: String,
pub paradigm: ModelParadigm,
pub device: ComputeDevice,
pub platform: PlatformEfficiency,
pub track_energy: bool,
pub track_cost: bool,
pub carbon_intensity: Option<f64>,
pub tags: Vec<String>,
}
impl Default for ExperimentTrackingConfig {
fn default() -> Self {
Self {
experiment_name: "default-experiment".to_string(),
paradigm: ModelParadigm::DeepLearning,
device: ComputeDevice::Cpu {
cores: 8,
threads_per_core: 2,
architecture: CpuArchitecture::X86_64,
},
platform: PlatformEfficiency::Server,
track_energy: true,
track_cost: true,
carbon_intensity: Some(400.0), tags: Vec::new(),
}
}
}