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.

Tests

Python tests for this module include tests that cannot be run without a local Postgres database. You are not obliged to run those tests though:

  • make test: will run all tests
  • make test-nodb: will run only tests that do not need a local DB
  • make test-db: will run only tests that do need a local DB

If you do want to run DB-related tests, you should ensure you have access zith sufficient privileges to a Postgresql database.

Using your system database

You need to ensure that your user is authorized to create and drop DBs, and in particular DBs named "softwareheritage-test" and "softwareheritage-dev"

Note: the testdata repository (swh-storage-testdata) is not required any more.

Using pifpaf

pifpaf is a suite of fixtures and a command-line tool that allows to start and stop daemons for a quick throw-away usage.

It can be used to run tests that need a Postgres database without any other configuration reauired nor the need to have special access to a running database:

$ pifpaf run postgresql make test-db
[snip]
----------------------------------------------------------------------
Ran 124 tests in 56.203s

OK

Note that pifpaf is not yet available as a Debian package, so you may have to install it in a venv.

Development

A test server could locally be running for tests.

Sample configuration

In either /etc/softwareheritage/storage/storage.yml, ~/.config/swh/storage.yml or ~/.swh/storage.yml:

storage:
  cls: local
  args:
    db: "dbname=softwareheritage-dev user=<user>"
    objstorage:
      cls: pathslicing
      args:
        root: /home/storage/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 /home/storage/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.

Run server

Command:

python3 -m swh.storage.api.server ~/.config/swh/storage.yml

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

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.131.tar.gz (153.5 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.131-py3-none-any.whl (122.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: swh.storage-0.0.131.tar.gz
  • Upload date:
  • Size: 153.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.3

File hashes

Hashes for swh.storage-0.0.131.tar.gz
Algorithm Hash digest
SHA256 2f283aec674b5773333eee08157510e9c7dd712377f8fc84dd5494135d3cbbb1
MD5 89eaa3411dc127d5054ec7eb66ecedfa
BLAKE2b-256 2d5e422027e9395195761dd416804b3609a302e2215af6a59a3dc2f407abdcc6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swh.storage-0.0.131-py3-none-any.whl
  • Upload date:
  • Size: 122.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.3

File hashes

Hashes for swh.storage-0.0.131-py3-none-any.whl
Algorithm Hash digest
SHA256 519d0b4fc8da6fa62969559bee1630cd551640f857c9066bf763785d28e78cc8
MD5 d235c94b22619d1301958a214a4234f5
BLAKE2b-256 8490a5c798ee343547b0562dbf238deddc9980ee69779fd3384093822710feaa

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