swh.storage.algos.snapshot module

swh.storage.algos.snapshot.snapshot_get_all_branches(storage, snapshot_id)[source]

Get all the branches for a given snapshot

Parameters
Returns

a dict with two keys:
  • id: identifier of the snapshot

  • branches: a dict of branches contained in the snapshot whose keys are the branches’ names.

Return type

dict

swh.storage.algos.snapshot.snapshot_get_latest(storage, origin: str, allowed_statuses: Optional[Iterable[str]] = None, branches_count: Optional[int] = None) → Optional[swh.model.model.Snapshot][source]

Get the latest snapshot for the given origin, optionally only from visits that have one of the given allowed_statuses.

The branches of the snapshot are iterated in the lexicographical order of their names.

Parameters
  • storage – Storage instance

  • origin – the origin’s URL

  • allowed_statuses – list of visit statuses considered to find the latest snapshot for the visit. For instance, allowed_statuses=['full'] will only consider visits that have successfully run to completion.

  • branches_count – Optional parameter to retrieve snapshot with all branches (default behavior when None) or not. If set to positive number, the snapshot will be partial with only that number of branches.

Raises

ValueError if branches_count is not a positive value

Returns

The snapshot object if one is found matching the criteria or None.