Skip to main content

ExperimentStorage

Trait ExperimentStorage 

Source
pub trait ExperimentStorage: Send + Sync {
    // Required methods
    fn create_experiment(
        &mut self,
        name: &str,
        config: Option<Value>,
    ) -> Result<String>;
    fn create_run(&mut self, experiment_id: &str) -> Result<String>;
    fn start_run(&mut self, run_id: &str) -> Result<()>;
    fn complete_run(&mut self, run_id: &str, status: RunStatus) -> Result<()>;
    fn log_metric(
        &mut self,
        run_id: &str,
        key: &str,
        step: u64,
        value: f64,
    ) -> Result<()>;
    fn log_artifact(
        &mut self,
        run_id: &str,
        key: &str,
        data: &[u8],
    ) -> Result<String>;
    fn get_metrics(&self, run_id: &str, key: &str) -> Result<Vec<MetricPoint>>;
    fn get_run_status(&self, run_id: &str) -> Result<RunStatus>;
    fn set_span_id(&mut self, run_id: &str, span_id: &str) -> Result<()>;
    fn get_span_id(&self, run_id: &str) -> Result<Option<String>>;
}
Expand description

Trait for experiment storage backends

This trait abstracts over different storage implementations, allowing for production use with TruenoDB and testing with in-memory storage.

§Thread Safety

All implementations must be Send + Sync to support concurrent access from multiple training threads.

Required Methods§

Source

fn create_experiment( &mut self, name: &str, config: Option<Value>, ) -> Result<String>

Create a new experiment

§Arguments
  • name - Human-readable experiment name
  • config - Optional JSON configuration for the experiment
§Returns

Unique experiment ID

Source

fn create_run(&mut self, experiment_id: &str) -> Result<String>

Create a new run within an experiment

The run starts in Pending status.

§Arguments
  • experiment_id - ID of the parent experiment
§Returns

Unique run ID

Source

fn start_run(&mut self, run_id: &str) -> Result<()>

Start a run, transitioning from Pending to Running

§Arguments
  • run_id - ID of the run to start
Source

fn complete_run(&mut self, run_id: &str, status: RunStatus) -> Result<()>

Complete a run with the given status

§Arguments
  • run_id - ID of the run
  • status - Final status (Success, Failed, or Cancelled)
Source

fn log_metric( &mut self, run_id: &str, key: &str, step: u64, value: f64, ) -> Result<()>

Log a metric value for a run

§Arguments
  • run_id - ID of the run
  • key - Metric name (e.g., “loss”, “accuracy”)
  • step - Training step or epoch number
  • value - Metric value
Source

fn log_artifact( &mut self, run_id: &str, key: &str, data: &[u8], ) -> Result<String>

Log an artifact for a run

§Arguments
  • run_id - ID of the run
  • key - Artifact name (e.g., “model.safetensors”)
  • data - Artifact data bytes
§Returns

Content-addressable hash of the artifact

Source

fn get_metrics(&self, run_id: &str, key: &str) -> Result<Vec<MetricPoint>>

Get metrics for a specific run and key

§Arguments
  • run_id - ID of the run
  • key - Metric name to retrieve
§Returns

Vector of metric points, ordered by step

Source

fn get_run_status(&self, run_id: &str) -> Result<RunStatus>

Get the current status of a run

Source

fn set_span_id(&mut self, run_id: &str, span_id: &str) -> Result<()>

Set renacer span ID for distributed tracing

Source

fn get_span_id(&self, run_id: &str) -> Result<Option<String>>

Get renacer span ID for a run

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§