mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-08-28 05:27:41 +00:00
Restore rewound run metadata from the store
This commit is contained in:
parent
14464776f2
commit
ea4cf7033b
2 changed files with 28 additions and 3 deletions
|
|
@ -107,7 +107,29 @@ async fn reset_rewound_run_state(
|
|||
run_id: &fabro_types::RunId,
|
||||
run_dir: &std::path::Path,
|
||||
) -> Result<()> {
|
||||
let run_record = RunRecord::load(run_dir)?;
|
||||
let existing_run_store = durable_store
|
||||
.open_run_reader(run_id)
|
||||
.await
|
||||
.map_err(|err| anyhow::anyhow!("failed to open durable store run before rewind: {err}"))?;
|
||||
let store_run_record = if let Some(run_store) = existing_run_store.as_ref() {
|
||||
run_store.get_run().await.ok().flatten()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let store_start_record = if let Some(run_store) = existing_run_store.as_ref() {
|
||||
run_store.get_start().await.ok().flatten()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let store_graph = if let Some(run_store) = existing_run_store.as_ref() {
|
||||
run_store.get_graph().await.ok().flatten()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let run_record = store_run_record
|
||||
.or_else(|| RunRecord::load(run_dir).ok())
|
||||
.context("failed to restore run record after rewind: missing run metadata")?;
|
||||
let checkpoint = MetadataStore::read_checkpoint(git_store.repo_dir(), &run_id.to_string())?
|
||||
.context("rewound metadata branch is missing checkpoint.json")?;
|
||||
checkpoint.save(&run_dir.join("checkpoint.json"))?;
|
||||
|
|
@ -136,13 +158,15 @@ async fn reset_rewound_run_state(
|
|||
.put_run(&run_record)
|
||||
.await
|
||||
.map_err(|err| anyhow::anyhow!("failed to restore run record after rewind: {err}"))?;
|
||||
if let Ok(start_record) = StartRecord::load(run_dir) {
|
||||
if let Some(start_record) = store_start_record.or_else(|| StartRecord::load(run_dir).ok()) {
|
||||
run_store
|
||||
.put_start(&start_record)
|
||||
.await
|
||||
.map_err(|err| anyhow::anyhow!("failed to restore start record after rewind: {err}"))?;
|
||||
}
|
||||
if let Ok(dot_source) = std::fs::read_to_string(run_dir.join("workflow.fabro")) {
|
||||
if let Some(dot_source) =
|
||||
store_graph.or_else(|| std::fs::read_to_string(run_dir.join("workflow.fabro")).ok())
|
||||
{
|
||||
run_store
|
||||
.put_graph(&dot_source)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ fn rewind_target_updates_metadata_and_resume_hint() {
|
|||
|
||||
let mut cmd = context.command();
|
||||
cmd.current_dir(&setup.repo_dir);
|
||||
std::fs::remove_file(setup.run.run_dir.join("run.json")).unwrap();
|
||||
cmd.args(["rewind", &setup.run.run_id, "@1", "--no-push"]);
|
||||
|
||||
let (snapshot, output) = run_and_format(&mut cmd, &git_filters(&context));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue