Python client for the https://provenance.ecs.soton.ac.uk/store/ API
Python Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
doc
provstore
.coveragerc
.gitignore
.travis.yml
LICENSE
README.md
requirements.txt
setup.cfg
setup.py

README.md

provstore-api PyPI version Build Status Coverage Status

Client for the ProvStore's API.

Installation

pip install provstore-api

You can view provstore-api on PyPi's package index

Usage

To use the client import the API and configure your access credentials:

from provstore.api import Api

# API key can be found at https://provenance.ecs.soton.ac.uk/store/account/developer/
api = Api(userame="your_provstore_username", api_key="your_api_key")

Note: credentials can also be set via the PROVSTORE_USERNAME and PROVSTORE_API_KEY environment variables and omitted from the initialization.

For demonstrations purposes we will use the ProvDocuments given in the examples module, but you would use your documents instead.

import provstore.tests.examples as examples

Storing documents

prov_document = examples.flat_document()
prov_bundle = examples.flat_document()

# Store the document to ProvStore:
#   - the public parameter is optional and defaults to False
stored_document = api.document.create(prov_document,
                                      name="name",
                                      public=False)

# => This will store the document and return a ProvStore Document object

Retrieving documents

# Get a document with ID 148 from ProvStore:
stored_document = api.document.get(148)
# The document's provenance is available like so:
stored_document.prov

# => This will fetch the document and return a ProvStore Document object

Deleting documents

# Delete the document with ID 148 from the store:
api.document.get(148).delete()

Adding bundles

# Get document with this ID's bundles
api.document.get(148).add_bundle(prov_bundle, 'ex:bundle-1')
# or the shorthand:
api.document.get(148).bundles['ex:bundle-1'] = prov_bundle

Fetching bundle

# Get document's bundle with matching identifier
api.document.get(148).bundles['ex:bundle-1']

Iterating over bundles

# Get document with this ID's bundles
# WARNING: This is expensive, consider using api.document.get(148).prov.bundles instead
for bundle in api.document.get(148).bundles:
    # print the bundle's identifier
    print bundle.identifier
    # the bundle's provenance is at:
    bundle.prov

Contribute

Documentation

API

License

This project is licensed under the MIT license.

Contributors

Sam Millar <http://millar.io>