prov package¶
Subpackages¶
Submodules¶
prov.constants module¶
prov.dot module¶
Graphical visualisation support for prov.model.
This module produces graphical visualisation for provenanve graphs. Requires pydotplus module and Graphviz.
References:
- pydotplus homepage: http://pydotplus.readthedocs.io/
- Graphviz: http://www.graphviz.org/
- DOT Language: http://www.graphviz.org/doc/info/lang.html
-
prov.dot.prov_to_dot(bundle, show_nary=True, use_labels=False, direction=u'BT', show_element_attributes=True, show_relation_attributes=True)[source]¶ Convert a provenance bundle/document into a DOT graphical representation.
Parameters: - bundle – The provenance bundle/document to be converted.
- show_nary (bool) – shows all elements in n-ary relations.
- use_labels (bool) – uses the prov:label property of an element as its name (instead of its identifier).
- direction – specifies the direction of the graph. Valid values are “BT” (default), “TB”, “LR”, “RL”.
- show_element_attributes (bool) – shows attributes of elements.
- show_relation_attributes (bool) – shows attributes of relations.
Returns: pydot.Dot– the Dot object.
prov.graph module¶
-
prov.graph.graph_to_prov(g)[source]¶ Convert a MultiDiGraph back to a
ProvDocument.Parameters: g – The graph instance to convert.
-
prov.graph.prov_to_graph(prov_document)[source]¶ Convert a
ProvDocumentto a MultiDiGraph instance of the NetworkX library.Parameters: prov_document – The ProvDocumentinstance to convert.
prov.identifier module¶
-
class
prov.identifier.Identifier(uri)[source]¶ Bases:
objectBase class for all identifiers and also represents xsd:anyURI
-
uri¶
-
prov.model module¶
Python implementation of the W3C Provenance Data Model (PROV-DM), including support for PROV-JSON import/export
References:
PROV-DM: http://www.w3.org/TR/prov-dm/ PROV-JSON: https://provenance.ecs.soton.ac.uk/prov-json/
-
class
prov.model.Literal(value, datatype=None, langtag=None)[source]¶ Bases:
object-
datatype¶
-
langtag¶
-
value¶
-
-
class
prov.model.NamespaceManager(namespaces=None, default=None, parent=None)[source]¶ Bases:
dict
-
class
prov.model.ProvActivity(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvElement-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:startTime>, <QualifiedName: prov:endTime>)¶
-
-
class
prov.model.ProvAgent(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvElement
-
class
prov.model.ProvAlternate(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:alternate1>, <QualifiedName: prov:alternate2>)¶
-
-
class
prov.model.ProvAssociation(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:activity>, <QualifiedName: prov:agent>, <QualifiedName: prov:plan>)¶
-
-
class
prov.model.ProvAttribution(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:entity>, <QualifiedName: prov:agent>)¶
-
-
class
prov.model.ProvBundle(records=None, identifier=None, namespaces=None, document=None)[source]¶ Bases:
object-
actedOnBehalfOf(delegate, responsible, activity=None, identifier=None, other_attributes=None)¶
-
alternateOf(alternate1, alternate2)¶
-
bundles¶
-
default_ns_uri¶ Returns the default namespace’s URI, if any
-
derivation(generatedEntity, usedEntity, activity=None, generation=None, usage=None, identifier=None, other_attributes=None)[source]¶
-
document¶ Returns the parent document, if any
-
hadMember(collection, entity)¶
-
hadPrimarySource(generatedEntity, usedEntity, activity=None, generation=None, usage=None, identifier=None, other_attributes=None)¶
-
identifier¶ Returns the bundle’s identifier
-
mentionOf(specificEntity, generalEntity, bundle)¶
-
namespaces¶ Returns the set of registered namespaces
-
plot(filename=None, show_nary=True, use_labels=False, show_element_attributes=True, show_relation_attributes=True)[source]¶ Convenience function to plot a prov document.
Parameters: - filename (string, optional) – The filename to save to. If not given, it will open an interactive matplotlib plot. The filetype is determined from the filename ending.
- show_nary (bool) – shows all elements in n-ary relations.
- use_labels – uses the prov:label property of an element as its
name (instead of its identifier). :type use_labels: bool :param show_element_attributes: shows attributes of elements. :type show_element_attributes: bool :param show_relation_attributes: shows attributes of relations. :type show_relation_attributes: bool
-
primary_source(generatedEntity, usedEntity, activity=None, generation=None, usage=None, identifier=None, other_attributes=None)[source]¶
-
quotation(generatedEntity, usedEntity, activity=None, generation=None, usage=None, identifier=None, other_attributes=None)[source]¶
-
records¶ Returns the list of all records in the current bundle
-
revision(generatedEntity, usedEntity, activity=None, generation=None, usage=None, identifier=None, other_attributes=None)[source]¶
-
specializationOf(specificEntity, generalEntity)¶
-
start(activity, trigger=None, starter=None, time=None, identifier=None, other_attributes=None)[source]¶
-
unified()[source]¶ Unifies all records in the bundle that haves same identifiers
Returns: ProvBundle– the new unified bundle.
-
update(other)[source]¶ Append all the records of the other ProvBundle into this bundle.
Parameters: other ( ProvBundle) – the other bundle whose records to be appended.Returns: None.
-
used(activity, entity=None, time=None, identifier=None, other_attributes=None)¶
-
wasAssociatedWith(activity, agent=None, plan=None, identifier=None, other_attributes=None)¶
-
wasAttributedTo(entity, agent, identifier=None, other_attributes=None)¶
-
wasDerivedFrom(generatedEntity, usedEntity, activity=None, generation=None, usage=None, identifier=None, other_attributes=None)¶
-
wasEndedBy(activity, trigger=None, ender=None, time=None, identifier=None, other_attributes=None)¶
-
wasGeneratedBy(entity, activity=None, time=None, identifier=None, other_attributes=None)¶
-
wasInfluencedBy(influencee, influencer, identifier=None, other_attributes=None)¶
-
wasInformedBy(informed, informant, identifier=None, other_attributes=None)¶
-
wasInvalidatedBy(entity, activity=None, time=None, identifier=None, other_attributes=None)¶
-
wasQuotedFrom(generatedEntity, usedEntity, activity=None, generation=None, usage=None, identifier=None, other_attributes=None)¶
-
wasRevisionOf(generatedEntity, usedEntity, activity=None, generation=None, usage=None, identifier=None, other_attributes=None)¶
-
wasStartedBy(activity, trigger=None, starter=None, time=None, identifier=None, other_attributes=None)¶
-
-
class
prov.model.ProvCommunication(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:informed>, <QualifiedName: prov:informant>)¶
-
-
class
prov.model.ProvDelegation(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:delegate>, <QualifiedName: prov:responsible>, <QualifiedName: prov:activity>)¶
-
-
class
prov.model.ProvDerivation(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:generatedEntity>, <QualifiedName: prov:usedEntity>, <QualifiedName: prov:activity>, <QualifiedName: prov:generation>, <QualifiedName: prov:usage>)¶
-
-
class
prov.model.ProvDocument(records=None, namespaces=None)[source]¶ Bases:
prov.model.ProvBundle-
bundles¶
-
static
deserialize(source=None, content=None, format=u'json', **args)[source]¶ Deserialize the
ProvDocumentfrom source (a stream or a filepath) or directly from a string contentFormat defaults to PROV-JSON.
-
flattened()[source]¶ Flattens the document by moving all the records in its bundles up to the document level.
Returns: ProvDocument– the (new) flattened document.
-
serialize(destination=None, format=u'json', **args)[source]¶ Serialize the
ProvDocumentto destinationIf destination is None serialize method returns the serialization as a string. Format defaults to PROV-JSON.
-
unified()[source]¶ Returns a new document containing all records having same identifiers unified (including those inside bundles)
-
update(other)[source]¶ Append all the records of the other document/bundle into this document. Bundles having same identifiers will be merged.
Parameters: other ( ProvDocumentorProvBundle) – the other document/bundle whose records to be appended.Returns: None.
-
-
class
prov.model.ProvElement(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRecord
-
exception
prov.model.ProvElementIdentifierRequired[source]¶ Bases:
prov.model.ProvException
-
class
prov.model.ProvEnd(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:activity>, <QualifiedName: prov:trigger>, <QualifiedName: prov:ender>, <QualifiedName: prov:time>)¶
-
-
class
prov.model.ProvEntity(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvElement
-
exception
prov.model.ProvException[source]¶ Bases:
prov.ErrorBase class for PROV model exceptions.
-
exception
prov.model.ProvExceptionInvalidQualifiedName(qname)[source]¶ Bases:
prov.model.ProvException
-
class
prov.model.ProvGeneration(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:entity>, <QualifiedName: prov:activity>, <QualifiedName: prov:time>)¶
-
-
class
prov.model.ProvInfluence(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:influencee>, <QualifiedName: prov:influencer>)¶
-
-
class
prov.model.ProvInvalidation(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:entity>, <QualifiedName: prov:activity>, <QualifiedName: prov:time>)¶
-
-
class
prov.model.ProvMembership(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:collection>, <QualifiedName: prov:entity>)¶
-
-
class
prov.model.ProvMention(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvSpecialization-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:specificEntity>, <QualifiedName: prov:generalEntity>, <QualifiedName: prov:bundle>)¶
-
-
class
prov.model.ProvRecord(bundle, identifier, attributes=None)[source]¶ Bases:
objectBase class for PROV records.
-
FORMAL_ATTRIBUTES= ()¶
-
args¶
-
attributes¶
-
bundle¶
-
extra_attributes¶
-
formal_attributes¶
-
identifier¶
-
label¶
-
value¶
-
-
class
prov.model.ProvRelation(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRecord
-
class
prov.model.ProvSpecialization(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:specificEntity>, <QualifiedName: prov:generalEntity>)¶
-
-
class
prov.model.ProvStart(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:activity>, <QualifiedName: prov:trigger>, <QualifiedName: prov:starter>, <QualifiedName: prov:time>)¶
-
-
class
prov.model.ProvUsage(bundle, identifier, attributes=None)[source]¶ Bases:
prov.model.ProvRelation-
FORMAL_ATTRIBUTES= (<QualifiedName: prov:activity>, <QualifiedName: prov:entity>, <QualifiedName: prov:time>)¶
-
Module contents¶
-
exception
prov.Error[source]¶ Bases:
exceptions.ExceptionBase class for all errors in this package.
-
prov.read(source, format=None)[source]¶ Convenience function returning a ProvDocument instance.
It does a lazy format detection by simply using try/except for all known formats. The deserializers should fail fairly early when data of the wrong type is passed to them thus the try/except is likely cheap. One could of course also do some more advanced format auto-detection but I am not sure that is necessary.
The downside is that no proper error messages will be produced, use the format parameter to get the actual traceback.