swh.alter.removable module#

This module implements the marking stage of the removal algorithm.

class swh.alter.removable.RemovableSubgraph(*args, **kwargs)[source]#

Bases: Subgraph

A class representing the subgraph of objects that can be safely removed from the archive

This subgraph should only be created from an InventorySubgraph using from_inventory_subgraph(). No new vertices or edges can be added at this point.

Getting the list of SWHID that can be removed is done by using py:meth:removable_swhids.

After marking happened, this subgraph will contain all candidates until delete_unremovable() is called.

classmethod from_inventory_subgraph(subgraph: InventorySubgraph)[source]#
delete_unremovable()[source]#

Delete all vertices for unremovable objects from this subgraph.

removable_swhids() List[ExtendedSWHID][source]#

Returns a list of SWHIDs that can safely be removed from the archive.

referenced_swhids() List[ExtendedSWHID][source]#

Returns a list of SWHIDs that are referenced by objects that can be safely removed from the archive.

swh.alter.removable.mark_removable(storage: StorageInterface, graph_client: RemoteGraphClient, inventory_subgraph: InventorySubgraph, known_missing: Set[ExtendedSWHID] | None = None, progressbar: ProgressBarInit | None = None) RemovableSubgraph[source]#

Find which candidates can be safely removed from the archive.

Using the previously populated inventory_subgraph, query the given storage and graph_client to assess inbound references for each candidate and see which one can be safely removed from the archive.