swh.graph.webgraph module#

WebGraph driver

exception swh.graph.webgraph.CompressionSubprocessError(message: str, log_path: Path)[source]#

Bases: Exception

class swh.graph.webgraph.CompressionStep(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum

EXTRACT_NODES = -2#
MPH = -1#
CONVERT_MPH = 0#
BV = 1#
BV_OFFSETS = 2#
BV_EF = 3#
BFS = 4#
PERMUTE_AND_SIMPLIFY_BFS = 6#
BFS_OFFSETS = 7#
LLP = 8#
COMPOSE_ORDERS = 9#
PERMUTE_LLP = 10#
OBL = 11#
STATS = 12#
TRANSPOSE = 13#
TRANSPOSE_OBL = 14#
MAPS = 15#
EXTRACT_PERSONS = 16#
MPH_PERSONS = 17#
NODE_PROPERTIES = 18#
MPH_LABELS = 19#
FCL_LABELS = 20#
EDGE_LABELS = 21#
EDGE_LABELS_OBL = 22#
EDGE_LABELS_TRANSPOSE_OBL = 23#
CLEAN_TMP = 24#
swh.graph.webgraph.do_step(step, conf) List[RunResult][source]#
swh.graph.webgraph.compress(graph_name: str, in_dir: ~pathlib.Path, out_dir: ~pathlib.Path, steps: ~typing.Set[~swh.graph.webgraph.CompressionStep] = {CompressionStep.BFS, CompressionStep.BFS_OFFSETS, CompressionStep.BV, CompressionStep.BV_EF, CompressionStep.BV_OFFSETS, CompressionStep.CLEAN_TMP, CompressionStep.COMPOSE_ORDERS, CompressionStep.CONVERT_MPH, CompressionStep.EDGE_LABELS, CompressionStep.EDGE_LABELS_OBL, CompressionStep.EDGE_LABELS_TRANSPOSE_OBL, CompressionStep.EXTRACT_NODES, CompressionStep.EXTRACT_PERSONS, CompressionStep.FCL_LABELS, CompressionStep.LLP, CompressionStep.MAPS, CompressionStep.MPH, CompressionStep.MPH_LABELS, CompressionStep.MPH_PERSONS, CompressionStep.NODE_PROPERTIES, CompressionStep.OBL, CompressionStep.PERMUTE_AND_SIMPLIFY_BFS, CompressionStep.PERMUTE_LLP, CompressionStep.STATS, CompressionStep.TRANSPOSE, CompressionStep.TRANSPOSE_OBL}, conf: ~typing.Dict[str, str] = {}, progress_cb: ~typing.Callable[[int, ~swh.graph.webgraph.CompressionStep], None] = <function <lambda>>)[source]#

graph compression pipeline driver from nodes/edges files to compressed on-disk representation

Parameters:
  • graph_name – graph base name, relative to in_dir

  • in_dir – input directory, where the uncompressed graph can be found

  • out_dir – output directory, where the compressed graph will be stored

  • steps – compression steps to run (default: all steps)

  • conf

    compression configuration, supporting the following keys (all are optional, so an empty configuration is fine and is the default)

    • batch_size: batch size for WebGraph transformations; defaults to 1 billion

    • classpath: java classpath, defaults to swh-graph JAR only

    • java: command to run java VM, defaults to “java”

    • java_tool_options: value for JAVA_TOOL_OPTIONS environment variable; defaults to various settings for high memory machines

    • logback: path to a logback.xml configuration file; if not provided a temporary one will be created and used

    • max_ram: maximum RAM to use for compression; defaults to available virtual memory

    • tmp_dir: temporary directory, defaults to the “tmp” subdir of out_dir

    • object_types: comma-separated list of object types to extract (eg. ori,snp,rel,rev). Defaults to *.

  • progress_cb – a callable taking a percentage and step as argument, which is called every time a step starts.