cryoswath.provenance module#

Provenance and history helpers for CryoSwath outputs.

class cryoswath.provenance.InputReference(path, role='input', version=None, commit_hash=None, metadata=<factory>)[source]#

Bases: object

Reference to one input used during processing.

Parameters:
  • path (str)

  • role (str)

  • version (str | None)

  • commit_hash (str | None)

  • metadata (dict[str, Any])

commit_hash: str | None#
metadata: dict[str, Any]#
path: str#
role: str#
to_dict()[source]#
Return type:

dict[str, Any]

version: str | None#
class cryoswath.provenance.ProvenanceRecord(created_utc, schema_version=1, package='cryoswath', steps=<factory>, metadata=<factory>)[source]#

Bases: object

Collection of provenance steps stored alongside an output.

Parameters:
  • created_utc (str)

  • schema_version (int)

  • package (str)

  • steps (list[ProvenanceStep])

  • metadata (dict[str, Any])

created_utc: str#
metadata: dict[str, Any]#
package: str#
schema_version: int#
steps: list[ProvenanceStep]#
to_dict()[source]#
Return type:

dict[str, Any]

class cryoswath.provenance.ProvenanceStep(step, timestamp_utc, function, cryoswath_version, cryoswath_commit=None, arguments=<factory>, inputs=<factory>, metadata=<factory>)[source]#

Bases: object

Machine-readable provenance for one processing step.

Parameters:
  • step (str)

  • timestamp_utc (str)

  • function (str)

  • cryoswath_version (str)

  • cryoswath_commit (str | None)

  • arguments (dict[str, Any])

  • inputs (list[InputReference])

  • metadata (dict[str, Any])

arguments: dict[str, Any]#
cryoswath_commit: str | None#
cryoswath_version: str#
function: str#
inputs: list[InputReference]#
metadata: dict[str, Any]#
step: str#
timestamp_utc: str#
to_dict()[source]#
Return type:

dict[str, Any]

cryoswath.provenance.append_history(history, step)[source]#

Append one history line to an existing CF history attribute.

Parameters:
Return type:

str

cryoswath.provenance.build_provenance_record(steps, *, metadata=None, created_utc=None)[source]#

Build a provenance record from one or more provenance steps.

Parameters:
  • steps (Iterable[ProvenanceStep])

  • metadata (Mapping[str, Any] | None)

  • created_utc (str | None)

Return type:

ProvenanceRecord

cryoswath.provenance.build_provenance_step(step, func, /, *args, inputs=None, include_defaults=False, metadata=None, **kwargs)[source]#

Build a provenance step with normalized arguments and inputs.

Parameters:
  • step (str)

  • func (Callable[[...], Any] | str)

  • args (Any)

  • inputs (Iterable[InputReference | str | Path | dict[str, Any]] | None)

  • include_defaults (bool)

  • metadata (Mapping[str, Any] | None)

  • kwargs (Any)

Return type:

ProvenanceStep

cryoswath.provenance.capture_call_arguments(func, /, *args, include_defaults=False, **kwargs)[source]#

Bind positional and keyword arguments to a callable’s signature.

Parameters:
  • func (Callable[[...], Any])

  • args (Any)

  • include_defaults (bool)

  • kwargs (Any)

Return type:

dict[str, Any]

cryoswath.provenance.coerce_input_reference(value)[source]#

Normalize a dynamic or static input reference.

Parameters:

value (InputReference | str | Path | dict[str, Any])

Return type:

InputReference

cryoswath.provenance.format_history_line(step, *, max_argument_length=220)[source]#

Format one CF-style history line.

Parameters:
Return type:

str

cryoswath.provenance.load_provenance_sidecar(store_path, *, filename='provenance.json')[source]#

Load provenance metadata from a Zarr-sidecar JSON file.

Parameters:
  • store_path (str | Path)

  • filename (str)

Return type:

dict[str, Any]

cryoswath.provenance.package_revision()[source]#

Return the package version and git revision if available.

Return type:

dict[str, str | None]

cryoswath.provenance.provenance_path(store_path, filename='provenance.json')[source]#

Return the companion metadata path for a Zarr store.

Parameters:
  • store_path (str | Path)

  • filename (str)

Return type:

Path

cryoswath.provenance.serialize_provenance(steps, *, metadata=None, created_utc=None)[source]#

Serialize provenance data to a JSON-compatible mapping.

Parameters:
Return type:

dict[str, Any]

cryoswath.provenance.write_provenance_sidecar(store_path, steps, *, metadata=None, filename='provenance.json')[source]#

Write provenance metadata as a Zarr-sidecar JSON file.

Parameters:
  • store_path (str | Path)

  • steps (Iterable[ProvenanceStep])

  • metadata (Mapping[str, Any] | None)

  • filename (str)

Return type:

Path