.. _swh-graph-example-dataset: Example dataset =============== :mod:`swh.graph.example_dataset` contains a synthetic dataset made of only a very tiny number of objects. Any real-world input for the Software Heritage software stack is likely to be orders of magnitude bigger. However, it is small enough to be easily comprehensive for human beings. This makes it useful for exploring the behavior of ``swh.graph`` or writing tests. .. warning:: Except for origins, :ref:`SWHIDs` for these objects are synthetic and incorrect: they are arbitrary instead of having been computed from the content of the objects. While these are easier to comprehend for human brains, this quirk might introduce discrepancies or assertion errors whenever the value of the object :ref:`SWHIDs` is checked against their data. Using the dataset ----------------- Running a local server using this dataset can be done with: .. code:: console $ swh graph rpc-serve -g swh/graph/example_dataset/compressed/example & $ curl http://localhost:5009/graph/leaves/swh:1:dir:0000000000000000000000000000000000000002 swh:1:cnt:0000000000000000000000000000000000000001 .. _regenerate_swh-graph_example_dataset: Regenerating the dataset ------------------------ The package already contains files suitable for consumption by ``swh.graph`` made from this dataset. If needed, they can be regenerated by running: .. code:: console $ python -m swh.graph.example_dataset.generate_dataset \\ --compress \\ swh/graph/example_dataset The ``--compress`` optionally performs a graph compression step. .. warning:: While semantically equivalent, the graph compression output is not reproducible from a run to the next. Creating a new compressed graph would require to update many constants in the ``swh.graph`` test suite given the current implementation. Note that regenerating the compressed graph breaks many tests in swh-graph and dependent packages, which depend on the exact set or nodes, or their order. See :ref:`swh-graph-testing` for alternatives if you need a graph to test specific edge cases. Content ------- The example dataset mostly mimics the development of a tiny project. It has been released once, and then its development has been picked up in a fork. .. figure:: images/example-dataset.svg :alt: A representation of the example dataset directed graph with nodes for origins, snapshots, releases, revisions, directories and contents. Dataset visualization The :mod:`swh.model` objects that this dataset is comprised of are available in :mod:`swh.graph.example_dataset`.