hwoutils.snapshot
=================

.. py:module:: hwoutils.snapshot

.. autoapi-nested-parse::

   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
----------

.. autoapisummary::

   hwoutils.snapshot.WORKSPACE_REPOS


Functions
---------

.. autoapisummary::

   hwoutils.snapshot._find_workspace_root
   hwoutils.snapshot._git_info
   hwoutils.snapshot.scan_workspace
   hwoutils.snapshot.record
   hwoutils.snapshot.require_clean


Module Contents
---------------

.. py:data:: WORKSPACE_REPOS
   :value: ['yippy', 'orbix', 'coronagraphoto', 'coronalyze', 'hwoutils', 'yieldplotlib', 'hwostyle',...


.. py:function:: _find_workspace_root()

   Walk up from hwoutils to find the workspace root.


.. py:function:: _git_info(repo_path)

   Get git state for a single repository.


.. py:function:: scan_workspace(workspace_root=None)

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

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


.. py:function:: record(output_path, workspace_root=None)

   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.


.. py:function:: require_clean(workspace_root=None, repos=None)

   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.


