Skip to main content

Software Heritage storage manager

Project description

swh-storage

Abstraction layer over the archive, allowing to access all stored source code artifacts as well as their metadata.

See the documentation for more details.

Quick start

Dependencies

Python tests for this module include tests that cannot be run without a local Postgresql database, so you need the Postgresql server executable on your machine (no need to have a running Postgresql server). On a Debian-like host:

$ sudo apt install libpq-dev postgresql

Installation

It is strongly recommended to use a virtualenv. In the following, we consider you work in a virtualenv named swh. See the developer setup guide for a more details on how to setup a working environment.

You can install the package directly from pypi:

(swh) :~$ pip install swh.storage
[...]

Or from sources:

(swh) :~$ git clone https://forge.softwareheritage.org/source/swh-storage.git
[...]
(swh) :~$ cd swh-storage
(swh) :~/swh-storage$ pip install .
[...]

Then you can check it's properly installed:

(swh) :~$ swh storage --help
Usage: swh storage [OPTIONS] COMMAND [ARGS]...

  Software Heritage Storage tools.

Options:
  -h, --help  Show this message and exit.

Commands:
  rpc-serve  Software Heritage Storage RPC server.

Tests

The best way of running Python tests for this module is to use tox.

(swh) :~$ pip install tox

tox

From the sources directory, simply use tox:

(swh) :~/swh-storage$ tox
[...]
========= 315 passed, 6 skipped, 15 warnings in 40.86 seconds ==========
_______________________________ summary ________________________________
  flake8: commands succeeded
  py3: commands succeeded
  congratulations :)

Development

The storage server can be locally started. It requires a configuration file and a running Postgresql database.

Sample configuration

A typical configuration storage.yml file is:

storage:
  cls: local
  args:
    db: "dbname=softwareheritage-dev user=<user> password=<pwd>"
    objstorage:
      cls: pathslicing
      args:
        root: /tmp/swh-storage/
        slicing: 0:2/2:4/4:6

which means, this uses:

  • a local storage instance whose db connection is to softwareheritage-dev local instance,

  • the objstorage uses a local objstorage instance whose:

    • root path is /tmp/swh-storage,

    • slicing scheme is 0:2/2:4/4:6. This means that the identifier of the content (sha1) which will be stored on disk at first level with the first 2 hex characters, the second level with the next 2 hex characters and the third level with the next 2 hex characters. And finally the complete hash file holding the raw content. For example: 00062f8bd330715c4f819373653d97b3cd34394c will be stored at 00/06/2f/00062f8bd330715c4f819373653d97b3cd34394c

Note that the root path should exist on disk before starting the server.

Starting the storage server

If the python package has been properly installed (e.g. in a virtual env), you should be able to use the command:

(swh) :~/swh-storage$ swh storage rpc-serve storage.yml

This runs a local swh-storage api at 5002 port.

(swh) :~/swh-storage$ curl http://127.0.0.1:5002
<html>
<head><title>Software Heritage storage server</title></head>
<body>
<p>You have reached the
<a href="https://www.softwareheritage.org/">Software Heritage</a>
storage server.<br />
See its
<a href="https://docs.softwareheritage.org/devel/swh-storage/">documentation
and API</a> for more information</p>

And then what?

In your upper layer (loader-git, loader-svn, etc...), you can define a remote storage with this snippet of yaml configuration.

storage:
  cls: remote
  args:
    url: http://localhost:5002/

You could directly define a local storage with the following snippet:

storage:
  cls: local
  args:
    db: service=swh-dev
    objstorage:
      cls: pathslicing
      args:
        root: /home/storage/swh-storage/
        slicing: 0:2/2:4/4:6

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swh.storage-0.0.160.tar.gz (161.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swh.storage-0.0.160-py3-none-any.whl (133.1 kB view details)

Uploaded Python 3

File details

Details for the file swh.storage-0.0.160.tar.gz.

File metadata

  • Download URL: swh.storage-0.0.160.tar.gz
  • Upload date:
  • Size: 161.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.3

File hashes

Hashes for swh.storage-0.0.160.tar.gz
Algorithm Hash digest
SHA256 4d70c1df88f5bde5a0fff7d36bb0a2e3fb8d89908036519f12d41cce55055cdc
MD5 4ad2a5adee10707e1539f4089218dceb
BLAKE2b-256 c524fa8c318a79bc07c9c97563e1f420fd733c5044fcaaf5e2563a8b3cd9d249

See more details on using hashes here.

File details

Details for the file swh.storage-0.0.160-py3-none-any.whl.

File metadata

  • Download URL: swh.storage-0.0.160-py3-none-any.whl
  • Upload date:
  • Size: 133.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.3

File hashes

Hashes for swh.storage-0.0.160-py3-none-any.whl
Algorithm Hash digest
SHA256 61fe3b92eb6784a902c9515a07688667ef424d7665af26176d843af70b29b94d
MD5 4118aeb236bd28ca298f10173fcbda07
BLAKE2b-256 5ec2b5410d49bab737a4b42c24c1535bc00aa1a50d16f473b422cfa40984a7a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page