mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-07 08:27:12 +00:00
Remove dead .save() methods, write_run_status, save_json, and ConclusionExt
These disk-write methods had no production callers — all data is now persisted via events in SlateDB. Removes save_json helper, .save() from RunRecord/StartRecord/Checkpoint traits, the entire ConclusionExt trait, and the write_run_status function. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9d7d942128
commit
3fc3daa79d
8 changed files with 5 additions and 63 deletions
|
|
@ -29,18 +29,6 @@ pub(crate) fn millis_u64(d: std::time::Duration) -> u64 {
|
|||
u64::try_from(d.as_millis()).unwrap_or(u64::MAX)
|
||||
}
|
||||
|
||||
/// Save a value as pretty-printed JSON to a file.
|
||||
pub(crate) fn save_json<T: serde::Serialize>(
|
||||
value: &T,
|
||||
path: &std::path::Path,
|
||||
label: &str,
|
||||
) -> error::Result<()> {
|
||||
let json = serde_json::to_string_pretty(value)
|
||||
.map_err(|e| error::FabroError::Checkpoint(format!("{label} serialize failed: {e}")))?;
|
||||
std::fs::write(path, json)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Load a value from a JSON file.
|
||||
pub(crate) fn load_json<T: DeserializeOwned>(
|
||||
path: &std::path::Path,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ pub trait CheckpointExt {
|
|||
) -> Self
|
||||
where
|
||||
Self: Sized;
|
||||
fn save(&self, path: &Path) -> CrateResult<()>;
|
||||
fn load(path: &Path) -> CrateResult<Self>
|
||||
where
|
||||
Self: Sized;
|
||||
|
|
@ -55,11 +54,6 @@ impl CheckpointExt for Checkpoint {
|
|||
}
|
||||
}
|
||||
|
||||
fn save(&self, path: &Path) -> CrateResult<()> {
|
||||
tracing::debug!(path = %path.display(), node = %self.current_node, "Saving checkpoint");
|
||||
crate::save_json(self, path, "checkpoint")
|
||||
}
|
||||
|
||||
fn load(path: &Path) -> CrateResult<Self> {
|
||||
tracing::debug!(path = %path.display(), "Loading checkpoint");
|
||||
crate::load_json(path, "checkpoint")
|
||||
|
|
|
|||
|
|
@ -1,22 +1 @@
|
|||
use std::path::Path;
|
||||
|
||||
pub use fabro_types::conclusion::{Conclusion, StageSummary};
|
||||
|
||||
use crate::error::Result as CrateResult;
|
||||
|
||||
pub trait ConclusionExt {
|
||||
fn save(&self, path: &Path) -> CrateResult<()>;
|
||||
fn load(path: &Path) -> CrateResult<Self>
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
||||
impl ConclusionExt for Conclusion {
|
||||
fn save(&self, path: &Path) -> CrateResult<()> {
|
||||
crate::save_json(self, path, "conclusion")
|
||||
}
|
||||
|
||||
fn load(path: &Path) -> CrateResult<Self> {
|
||||
crate::load_json(path, "conclusion")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ mod run;
|
|||
mod start;
|
||||
|
||||
pub use checkpoint::{Checkpoint, CheckpointExt};
|
||||
pub use conclusion::{Conclusion, ConclusionExt, StageSummary};
|
||||
pub use conclusion::{Conclusion, StageSummary};
|
||||
pub use run::{RunRecord, RunRecordExt};
|
||||
pub use start::{StartRecord, StartRecordExt};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ pub trait RunRecordExt {
|
|||
fn file_name() -> &'static str
|
||||
where
|
||||
Self: Sized;
|
||||
fn save(&self, run_dir: &Path) -> CrateResult<()>;
|
||||
fn load(run_dir: &Path) -> CrateResult<Self>
|
||||
where
|
||||
Self: Sized;
|
||||
|
|
@ -25,10 +24,6 @@ impl RunRecordExt for RunRecord {
|
|||
FILE_NAME
|
||||
}
|
||||
|
||||
fn save(&self, run_dir: &Path) -> CrateResult<()> {
|
||||
crate::save_json(self, &run_dir.join(FILE_NAME), "run record")
|
||||
}
|
||||
|
||||
fn load(run_dir: &Path) -> CrateResult<Self> {
|
||||
crate::load_json(&run_dir.join(FILE_NAME), "run record")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ pub trait StartRecordExt {
|
|||
fn file_name() -> &'static str
|
||||
where
|
||||
Self: Sized;
|
||||
fn save(&self, run_dir: &Path) -> CrateResult<()>;
|
||||
fn load(run_dir: &Path) -> CrateResult<Self>
|
||||
where
|
||||
Self: Sized;
|
||||
|
|
@ -21,10 +20,6 @@ impl StartRecordExt for StartRecord {
|
|||
FILE_NAME
|
||||
}
|
||||
|
||||
fn save(&self, run_dir: &Path) -> CrateResult<()> {
|
||||
crate::save_json(self, &run_dir.join(FILE_NAME), "start record")
|
||||
}
|
||||
|
||||
fn load(run_dir: &Path) -> CrateResult<Self> {
|
||||
crate::load_json(&run_dir.join(FILE_NAME), "start record")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,26 +5,15 @@ pub use fabro_types::status::{
|
|||
};
|
||||
|
||||
pub trait RunStatusRecordExt {
|
||||
fn save(&self, path: &Path) -> std::io::Result<()>;
|
||||
fn load(path: &Path) -> std::io::Result<Self>
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
||||
impl RunStatusRecordExt for RunStatusRecord {
|
||||
fn save(&self, path: &Path) -> std::io::Result<()> {
|
||||
let json = serde_json::to_string_pretty(self).map_err(std::io::Error::other)?;
|
||||
std::fs::write(path, json)
|
||||
}
|
||||
|
||||
fn load(path: &Path) -> std::io::Result<Self> {
|
||||
let data = std::fs::read_to_string(path)?;
|
||||
serde_json::from_str(&data)
|
||||
.map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidData, e))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_run_status(run_dir: &Path, status: RunStatus, reason: Option<StatusReason>) {
|
||||
let record = RunStatusRecord::new(status, reason);
|
||||
let _ = record.save(&run_dir.join("status.json"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use crate::handler::HandlerRegistry;
|
|||
use crate::outcome::Outcome;
|
||||
use crate::pipeline;
|
||||
use crate::pipeline::types::Initialized;
|
||||
use crate::records::{Checkpoint, CheckpointExt};
|
||||
use crate::records::Checkpoint;
|
||||
use crate::run_options::RunOptions;
|
||||
|
||||
struct InitializedOptions {
|
||||
|
|
@ -192,7 +192,9 @@ async fn persist_run_artifacts_for_tests(run_store: &SlateRunStore, run_dir: &st
|
|||
};
|
||||
|
||||
if let Some(checkpoint) = state.checkpoint.as_ref() {
|
||||
let _ = checkpoint.save(&run_dir.join("checkpoint.json"));
|
||||
if let Ok(json) = serde_json::to_string_pretty(checkpoint) {
|
||||
let _ = std::fs::write(run_dir.join("checkpoint.json"), json);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(final_patch) = state.final_patch.as_ref() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue