Skip to content

Save demonstration files atomically - #61

Open
eust-w wants to merge 1 commit into
NeuracoreAI:masterfrom
eust-w:upstream/atomic-demo-save
Open

Save demonstration files atomically#61
eust-w wants to merge 1 commit into
NeuracoreAI:masterfrom
eust-w:upstream/atomic-demo-save

Conversation

@eust-w

@eust-w eust-w commented Aug 6, 2026

Copy link
Copy Markdown

Summary

  • write demonstration safetensors to a unique temporary file in the destination directory
  • fsync the completed file before atomically replacing the destination
  • fsync the parent directory where supported
  • clean up temporary files after both successful and failed saves
  • add regression coverage for failure preservation and successful replacement

Why

Demo.save currently writes directly to the final path. If serialization is interrupted, the process crashes, or the filesystem returns an error, an existing demonstration can be truncated or replaced by a partial file.

Saving in the same directory and using os.replace keeps the previous demonstration intact until a complete safetensors file is ready. This is especially useful for long visual demonstrations, where recollection is expensive.

Compatibility

There is no public API or safetensors schema change. DemoRecorder.save_demo continues to return the same final path, and errors still propagate to the caller.

Validation

  • regression test: simulated partial write raises while the previous demo remains byte-for-byte unchanged
  • regression test: successful save atomically replaces the previous file and removes the temporary file
  • real safetensors write/read round-trip passed with a temporary filename
  • Black 23.3.0, Ruff 0.0.272, Python compilation and git diff checks passed

Supersedes #56 after the source branch was renamed to remove the agent/ prefix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant