hwoutils.snapshot#

Workspace snapshot utilities for reproducible runs.

Records the state of all git repos in the hwo-dev workspace so that any pipeline or analysis run can be traced back to an exact set of library versions.

Usage in scripts:

# Development mode: just record what we used from hwoutils.snapshot import record

record(“data/manifest.json”)

# Production mode: refuse to run if anything is dirty from hwoutils.snapshot import require_clean, record

require_clean() # raises SystemExit if any repo has uncommitted changes record(“data/manifest.json”)

Attributes#

Functions#

_find_workspace_root()

Walk up from hwoutils to find the workspace root.

_git_info(repo_path)

Get git state for a single repository.

scan_workspace([workspace_root])

Scan all repos in the workspace and return their git state.

record(output_path[, workspace_root])

Record a snapshot of the workspace state to a JSON file.

require_clean([workspace_root, repos])

Require all workspace repos to be clean (no uncommitted changes).

Module Contents#

hwoutils.snapshot.WORKSPACE_REPOS = ['yippy', 'orbix', 'coronagraphoto', 'coronalyze', 'hwoutils', 'yieldplotlib', 'hwostyle',...#
hwoutils.snapshot._find_workspace_root()[source]#

Walk up from hwoutils to find the workspace root.

hwoutils.snapshot._git_info(repo_path)[source]#

Get git state for a single repository.

hwoutils.snapshot.scan_workspace(workspace_root=None)[source]#

Scan all repos in the workspace and return their git state.

Returns a dict with timestamp, python version, and per-repo info.

hwoutils.snapshot.record(output_path, workspace_root=None)[source]#

Record a snapshot of the workspace state to a JSON file.

Args:

output_path: Path to write the manifest JSON. workspace_root: Optional workspace root override.

Returns:

The snapshot dict.

hwoutils.snapshot.require_clean(workspace_root=None, repos=None)[source]#

Require all workspace repos to be clean (no uncommitted changes).

Call this at the top of production/final pipeline scripts. If any repo has uncommitted changes, prints a clear error and exits.

Args:

workspace_root: Optional workspace root override. repos: Optional list of repo names to check. If None, checks all.

Raises:

SystemExit: If any repo has uncommitted changes.