Note
This is a public alpha release, and therefore features and functionality may change and the software and documentation may contain technical bugs or other issues. If you discover any issues please consider registering a GitHub issue.
provenance.models module¶
This module provides models required for the creation, storage and manipulation of PROV documents.
These PROV documents describe actions made by users and applications, allowing usage patterns to be tracked.
For details on PROV see https://www.w3.org/TR/2013/NOTE-prov-overview-20130430/
-
class
provenance.models.
ProvAbleModel
[source]¶ Bases:
object
Mixin for models which are capable of having updates tracked by PROV records.
Creates a new PROV record every time the object is modified and saved.
-
class
provenance.models.
ProvActivity
[source]¶ Bases:
enum.Enum
Enum representing the types of activity to be tracked by PROV.
-
ACCESS
= 'piot:access'¶
-
UPDATE
= 'piot:update'¶
-
-
class
provenance.models.
ProvApplicationModel
(*args, **kwargs)[source]¶ Bases:
object
Dummy application model to fall back to when an action was performed via the PEDASI web interface.
Also to be used as parent class of
Application
to help with type hinting.
-
class
provenance.models.
ProvEntry
(*args, **values)[source]¶ Bases:
mongoengine.document.DynamicDocument
Stored PROV record for a single action.
e.g. Update a model’s metadata, use a model.
These will be referred to by a
ProvWrapper
document.-
exception
DoesNotExist
¶ Bases:
mongoengine.errors.DoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
mongoengine.errors.MultipleObjectsReturned
-
classmethod
create_prov
(instance: core.models.BaseAppDataModel, user_uri: str, application: Union[provenance.models.ProvApplicationModel, NoneType] = None, activity_type: Union[provenance.models.ProvActivity, NoneType] = <ProvActivity.UPDATE: 'piot:update'>) → provenance.models.ProvEntry[source]¶ Build a PROV document representing a particular activity within PEDASI.
Parameters: - instance – Application or DataSource which is the object of the activity
- user_uri – URI of user who performed the activity
- application – Application which the user used to perform the activity
- activity_type – Type of the activity - from
ProvActivity
Returns: PROV document in PROV-JSON form
-
classmethod
deserialize
(source=None, content: str = None, format: str = 'json', **kwargs)[source]¶ Create an instance of
ProvEntry
from another instance or a string document.Used to create a
ProvEntry
from a serialized PROV document.Provide one of ‘source’ or ‘content’.
Parameters: - source – Source from which to copy object
- content – Text from which to create object
- format – Format of text - e.g. JSON
Returns: New instance of
ProvEntry
-
id
¶ A field wrapper around MongoDB’s ObjectIds.
-
objects
¶
-
exception
-
class
provenance.models.
ProvWrapper
(*args, **values)[source]¶ Bases:
mongoengine.document.Document
Wrapper around a single PROV record (
ProvEntry
) which allows it to be easily linked to an instance of a Django model.This is managed using MongoEngine rather than as a Django model.
-
exception
DoesNotExist
¶ Bases:
mongoengine.errors.DoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
mongoengine.errors.MultipleObjectsReturned
-
app_label
¶ App from which the model comes
-
classmethod
create_prov
(instance: core.models.BaseAppDataModel, user_uri: str, application: Union[provenance.models.ProvApplicationModel, NoneType] = None, activity_type: Union[provenance.models.ProvActivity, NoneType] = <ProvActivity.UPDATE: 'piot:update'>) → provenance.models.ProvEntry[source]¶ Create a PROV record for a single action.
e.g. Update a model’s metadata, use a model.
These will create and return a
ProvEntry
document.
-
delete
(signal_kwargs=None, **write_concern)[source]¶ Delete this document and the
ProvEntry
to which it refers.
-
entry
¶ The actual PROV entry
-
classmethod
filter_model_instance
(instance: core.models.BaseAppDataModel) → django.db.models.query.QuerySet[source]¶ Get all
ProvEntry
documents related to a particular Django model instance.Parameters: instance – Model instance for which to get all ProvEntry
sReturns: List of ProvEntry
s
-
id
¶ A field wrapper around MongoDB’s ObjectIds.
-
instance
¶ Return the Django model instance to which this
ProvWrapper
refers.
-
model_name
¶ Name of the model
-
objects
¶
Primary key of the model instance
-
exception