prov.model¶
prov.model is the core of the library: the in-memory object model for
PROV-DM documents. A ProvDocument
contains ProvBundle\ s of records — elements (entities, activities,
agents) and relations between them — plus the namespace machinery used to build and resolve
their identifiers. See the Getting started for a walk-through of building
a document with this API, and the
PROV-DM Primer for the concepts behind the classes
below.
Documents and bundles¶
- class prov.model.ProvDocument(records: Iterable[ProvRecord] | None = None, namespaces: dict[str, str] | Iterable[Namespace] | None = None)[source]¶
Bases:
ProvBundleProvenance Document.
- property bundles: Iterable[ProvBundle]¶
The bundles contained in this document.
- flattened() ProvDocument[source]¶
Return a new document with all bundle records lifted to the top level.
Every record from every bundle is moved up alongside the document’s own records and the bundle structure is discarded; this is purely structural (nothing is merged or deduplicated). If the document has no bundles, it is returned unchanged. The original document is left untouched.
- Returns:
The (new) flattened
ProvDocument, or this document itself if it has no bundles.
- unified() ProvDocument[source]¶
Return a new document with records sharing an identifier merged.
The identifier-keyed attribute union (see
ProvBundle.unified()) is applied to the document’s top-level records and, recursively, to each contained bundle, preserving the bundle structure. The original document is left untouched.- Returns:
The new, unified
ProvDocument.
- update(other: ProvBundle) None[source]¶
Append all records of another document or bundle into this document.
Any bundles of
otherare also merged in: a bundle whose identifier already exists in this document is updated in place, otherwise a new bundle is created.- Parameters:
other – The
ProvDocumentorProvBundlewhose records are appended.- Raises:
ProvException – If
otheris not aProvBundle(or subclass).
- add_bundle(bundle: ProvBundle, identifier: QualifiedName | None = None) None[source]¶
Add a bundle to this document.
If a document (with no nested bundles) is passed, its records are copied into a fresh bundle. The bundle’s identifier is normalised against this document’s namespaces.
- Parameters:
bundle – The
ProvBundleto add.identifier – Optional identifier to use for the bundle; if not given, the bundle’s own identifier is used (default:
None).
- Raises:
ProvException – If
bundleis not aProvBundle, is a document with nested bundles, has no usable identifier, or an identifier collides with an existing bundle.
- bundle(identifier: QualifiedName | str | Identifier) ProvBundle[source]¶
Create a new, empty named bundle in this document.
- Parameters:
identifier – The identifier to use for the bundle.
- Returns:
The newly created
ProvBundle.- Raises:
ProvException – If
identifierisNoneor invalid, or a bundle with that identifier already exists.
- serialize(destination: IOBase | str | bytes | PathLike[str] | None = None, format: str = 'json', **args: Any) str | None[source]¶
Serialize this document to a destination or return it as a string.
The available serialization formats are
"json","rdf","xml"and"provn"(seeprov.serializers.get()).- Parameters:
destination – A writable stream or a local file path to write to. If
None, the serialization is returned as a string (default:None). A non-local (network) location is not written and yieldsNone.format – The serialization format (default:
"json", i.e. PROV-JSON).**args – Extra keyword arguments passed to the underlying serializer.
- Returns:
The serialization as a string if no
destinationwas given, otherwiseNone.
- static deserialize(source: IOBase | str | bytes | PathLike[str] | None = None, content: str | bytes | None = None, format: str = 'json', **args: Any) ProvDocument[source]¶
Deserialize a document from a source stream/file or a string.
Exactly one of
sourceorcontentshould be given;contenttakes precedence if both are. Note that not all formats support deserialization (PROV-N is write-only).- Parameters:
source – A readable stream or a file path to read from (default:
None).content – The document as a
strorbytesto read from (default:None).format – The serialization format (default:
"json", i.e. PROV-JSON).**args – Extra keyword arguments passed to the underlying deserializer.
- Returns:
The deserialized
ProvDocument.- Raises:
TypeError – If neither
sourcenorcontentis provided.
- class prov.model.ProvBundle(records: Iterable[ProvRecord] | None = None, identifier: QualifiedName | None = None, namespaces: dict[str, str] | Iterable[Namespace] | None = None, document: ProvDocument | None = None)[source]¶
Bases:
objectPROV Bundle
- property document: ProvDocument | None¶
The parent document of this bundle, or
Noneif it has none.
- property identifier: QualifiedName | None¶
The bundle’s identifier, or
Noneif it has none.
- set_default_namespace(uri: str) None[source]¶
Set the bundle’s default namespace to one with the given URI.
- Parameters:
uri – The URI of the default namespace.
- get_default_namespace() Namespace | None[source]¶
Return the default namespace, or
Noneif none is set.
- add_namespace(namespace_or_prefix: Namespace | str, uri: str | None = None) Namespace[source]¶
Add a namespace to the bundle, unless an equivalent one exists.
- Parameters:
namespace_or_prefix – A
Namespaceto add, or a prefix string (in which caseuriis required).uri – The namespace URI; required when
namespace_or_prefixis a prefix string (default:None).
- Returns:
The registered namespace (which may be an existing or renamed one).
- Raises:
ProvException – If a prefix string is given without a
uri.
- get_registered_namespaces() Iterable[Namespace][source]¶
Return all namespaces registered on the bundle.
- Returns:
An iterable of
Namespace.
- valid_qualified_name(identifier: QualifiedName | str | Identifier) QualifiedName | None[source]¶
Resolve an identifier to a qualified name using this bundle.
- Parameters:
identifier – The candidate to resolve.
- Returns:
The resolved
QualifiedName, orNoneif it could not be resolved.
- mandatory_valid_qname(identifier: QualifiedName | str | Identifier) QualifiedName[source]¶
Resolve an identifier to a qualified name, requiring success.
- Parameters:
identifier – The candidate to resolve.
- Returns:
The resolved
QualifiedName.- Raises:
ProvExceptionInvalidQualifiedName – If the identifier cannot be resolved to a valid qualified name.
- get_records(class_or_type_or_tuple: type | tuple[type] | None = None) Iterable[ProvRecord][source]¶
Return the bundle’s records, optionally filtered by type.
- Parameters:
class_or_type_or_tuple – An optional class or tuple of classes; only records passing
isinstance()against it are returned (default:None, meaning all records).- Returns:
The matching
ProvRecordobjects (a list when unfiltered, otherwise a filter iterator).
- get_record(identifier: QualifiedName | str | Identifier) list[ProvRecord][source]¶
Return all records matching a given identifier.
- Parameters:
identifier – The record identifier to look up.
- Returns:
The matching
ProvRecordobjects, or an empty list if the identifier is invalid or unknown.
- property bundles: Iterable[ProvBundle]¶
The bundles contained in this object.
- Raises:
ProvException – Always, since a plain bundle cannot contain sub-bundles. Only
ProvDocumentoverrides this.
- unified() ProvBundle[source]¶
Return a new bundle with records sharing an identifier merged.
For each identifier carried by more than one record, a single merged record is produced by unioning the attributes of all records with that identifier onto a copy of the first. Records with a unique identifier, or no identifier, pass through unchanged. This is a simple identifier-keyed attribute union, not the full PROV-CONSTRAINTS unification: no type/attribute conflicts are detected and no inference is performed. The original bundle is left untouched.
- Returns:
The new, unified
ProvBundle.
- update(other: ProvBundle) None[source]¶
Append all records of another bundle into this bundle.
- Parameters:
other – The
ProvBundlewhose records are appended.- Raises:
ProvException – If
otheris not aProvBundle, or is a document that itself contains sub-bundles.
- new_record(record_type: QualifiedName, identifier: QualifiedName | str | Identifier | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvRecord[source]¶
Create a new record, add it to the bundle, and return it.
- Parameters:
record_type – The record type, one of the keys of
PROV_REC_CLS.identifier – The identifier for the new record (may be
Nonefor relations).attributes – Formal attributes of the record, as a dict or an iterable of
(name, value)pairs (default:None).other_attributes – Additional (non-formal) attributes, in the same forms (default:
None).
- Returns:
The newly created and added
ProvRecord.
- add_record(record: ProvRecord) ProvRecord[source]¶
Add a copy of a record to this bundle.
The record is re-created within this bundle (resolving its identifier and attributes against this bundle’s namespaces), so the returned record is a new object, not
recorditself.- Parameters:
record – The
ProvRecordto copy into the bundle.- Returns:
The newly created
ProvRecordbelonging to this bundle.
- entity(identifier: QualifiedName | str | Identifier, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvEntity[source]¶
Create a new entity and add it to the bundle.
- Parameters:
identifier – The identifier for the new entity.
other_attributes – Optional attributes for the entity, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvEntity.
- activity(identifier: QualifiedName | str | Identifier, startTime: datetime | str | None = None, endTime: datetime | str | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvActivity[source]¶
Create a new activity and add it to the bundle.
- Parameters:
identifier – The identifier for the new activity.
startTime – Optional start time, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).endTime – Optional end time, in the same forms (default:
None).other_attributes – Optional attributes for the activity, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvActivity.
- generation(entity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvRecord[source]¶
Create a new generation record for an entity.
- Parameters:
entity – The generated entity (or its string identifier).
activity – The activity (or its string identifier) involved in the generation (default:
None).time – Optional time of the generation, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).identifier – Optional identifier for the generation record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new generation record.
- usage(activity: ProvActivity | QualifiedName | str | Identifier, entity: ProvEntity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvUsage[source]¶
Create a new usage record for an activity.
- Parameters:
activity – The using activity (or its string identifier).
entity – The entity (or its string identifier) involved in the usage relationship (default:
None).time – Optional time of the usage, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).identifier – Optional identifier for the usage record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvUsagerecord.
- start(activity: ProvActivity | QualifiedName | str | Identifier, trigger: ProvEntity | QualifiedName | str | Identifier | None = None, starter: ProvActivity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvStart[source]¶
Create a new start record for an activity.
- Parameters:
activity – The started activity (or its string identifier).
trigger – The entity (or its string identifier) triggering the start (default:
None).starter – Optional activity qualifying the start, through which the trigger entity is generated (default:
None).time – Optional time of the start, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).identifier – Optional identifier for the start record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvStartrecord.
- end(activity: ProvActivity | QualifiedName | str | Identifier, trigger: ProvEntity | QualifiedName | str | Identifier | None = None, ender: ProvActivity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvEnd[source]¶
Create a new end record for an activity.
- Parameters:
activity – The ended activity (or its string identifier).
trigger – The entity (or its string identifier) triggering the end (default:
None).ender – Optional activity qualifying the end, through which the trigger entity is generated (default:
None).time – Optional time of the end, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).identifier – Optional identifier for the end record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvEndrecord.
- invalidation(entity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvInvalidation[source]¶
Create a new invalidation record for an entity.
- Parameters:
entity – The invalidated entity (or its string identifier).
activity – The activity (or its string identifier) involved in the invalidation (default:
None).time – Optional time of the invalidation, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).identifier – Optional identifier for the invalidation record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvInvalidationrecord.
- communication(informed: ProvActivity | QualifiedName | str | Identifier, informant: ProvActivity | QualifiedName | str | Identifier, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvCommunication[source]¶
Create a new communication record between two activities.
- Parameters:
informed – The informed activity (relationship destination).
informant – The informing activity (relationship source).
identifier – Optional identifier for the communication record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvCommunicationrecord.
- agent(identifier: QualifiedName | str | Identifier, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvAgent[source]¶
Create a new agent and add it to the bundle.
- Parameters:
identifier – The identifier for the new agent.
other_attributes – Optional attributes for the agent, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvAgent.
- attribution(entity: ProvEntity | QualifiedName | str | Identifier, agent: ProvAgent | ProvEntity | ProvActivity | QualifiedName | str | Identifier, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvAttribution[source]¶
Create a new attribution record between an entity and an agent.
- Parameters:
entity – The entity (or its string identifier) being attributed (relationship source).
agent – The agent (or its string identifier) the entity is attributed to (relationship destination).
identifier – Optional identifier for the attribution record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvAttributionrecord.
- association(activity: ProvActivity | QualifiedName | str | Identifier, agent: ProvAgent | ProvEntity | ProvActivity | QualifiedName | str | Identifier | None = None, plan: ProvEntity | QualifiedName | str | Identifier | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvAssociation[source]¶
Create a new association record for an activity.
- Parameters:
activity – The activity (or its string identifier).
agent – The agent (or its string identifier) associated with the activity (default:
None).plan – Optional entity qualifying the association through an internal plan (default:
None).identifier – Optional identifier for the association record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvAssociationrecord.
- delegation(delegate: ProvAgent | ProvEntity | ProvActivity | QualifiedName | str | Identifier, responsible: ProvAgent | ProvEntity | ProvActivity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvDelegation[source]¶
Create a new delegation record between two agents.
- Parameters:
delegate – The agent (or its string identifier) delegating the responsibility (relationship source).
responsible – The agent (or its string identifier) the responsibility is delegated to (relationship destination).
activity – Optional activity qualifying the delegation (default:
None).identifier – Optional identifier for the delegation record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvDelegationrecord.
- influence(influencee: ProvEntity | QualifiedName | str | Identifier | ProvActivity | ProvAgent, influencer: ProvEntity | QualifiedName | str | Identifier | ProvActivity | ProvAgent, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvInfluence[source]¶
Create a new influence record between two entities, activities or agents.
- Parameters:
influencee – The influenced entity, activity or agent (relationship source).
influencer – The influencing entity, activity or agent (relationship destination).
identifier – Optional identifier for the influence record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvInfluencerecord.
- derivation(generatedEntity: ProvEntity | QualifiedName | str | Identifier, usedEntity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, generation: ProvGeneration | QualifiedName | str | Identifier | None = None, usage: ProvUsage | QualifiedName | str | Identifier | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvDerivation[source]¶
Create a new derivation record for a generated entity from a used entity.
- Parameters:
generatedEntity – The generated entity (or its string identifier), the relationship source.
usedEntity – The used entity (or its string identifier), the relationship destination.
activity – The activity (or its string identifier) involved in the derivation (default:
None).generation – Optional generation record qualifying the derivation through the activity’s generation of the generated entity (default:
None).usage – Optional usage record qualifying the derivation through the activity’s use of the used entity (default:
None).identifier – Optional identifier for the derivation record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvDerivationrecord.
- revision(generatedEntity: ProvEntity | QualifiedName | str | Identifier, usedEntity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, generation: ProvGeneration | QualifiedName | str | Identifier | None = None, usage: ProvUsage | QualifiedName | str | Identifier | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvDerivation[source]¶
Create a new revision record for a generated entity from a used entity.
A revision is a derivation with an additional
prov:Revisiontype.- Parameters:
generatedEntity – The generated (revised) entity (or its string identifier), the relationship source.
usedEntity – The used (original) entity (or its string identifier), the relationship destination.
activity – The activity (or its string identifier) involved in the revision (default:
None).generation – Optional generation record qualifying the derivation (default:
None).usage – Optional usage record qualifying the derivation (default:
None).identifier – Optional identifier for the revision record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvDerivationrecord, typed as a revision.
- quotation(generatedEntity: ProvEntity | QualifiedName | str | Identifier, usedEntity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, generation: ProvGeneration | QualifiedName | str | Identifier | None = None, usage: ProvUsage | QualifiedName | str | Identifier | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvDerivation[source]¶
Create a new quotation record for a generated entity from a used entity.
A quotation is a derivation with an additional
prov:Quotationtype.- Parameters:
generatedEntity – The quoting entity (or its string identifier), the relationship source.
usedEntity – The quoted entity (or its string identifier), the relationship destination.
activity – The activity (or its string identifier) involved in the quotation (default:
None).generation – Optional generation record qualifying the derivation (default:
None).usage – Optional usage record qualifying the derivation (default:
None).identifier – Optional identifier for the quotation record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvDerivationrecord, typed as a quotation.
- primary_source(generatedEntity: ProvEntity | QualifiedName | str | Identifier, usedEntity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, generation: ProvGeneration | QualifiedName | str | Identifier | None = None, usage: ProvUsage | QualifiedName | str | Identifier | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvDerivation[source]¶
Create a new primary-source record for a generated entity from a used entity.
A primary source is a derivation with an additional
prov:PrimarySourcetype.- Parameters:
generatedEntity – The derived entity (or its string identifier), the relationship source.
usedEntity – The primary-source entity (or its string identifier), the relationship destination.
activity – The activity (or its string identifier) involved (default:
None).generation – Optional generation record qualifying the derivation (default:
None).usage – Optional usage record qualifying the derivation (default:
None).identifier – Optional identifier for the primary-source record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvDerivationrecord, typed as a primary source.
- specialization(specificEntity: ProvEntity | QualifiedName | str | Identifier, generalEntity: ProvEntity | QualifiedName | str | Identifier) ProvSpecialization[source]¶
Create a new specialisation record from a general entity.
- Parameters:
specificEntity – The specific entity (or its string identifier), the relationship source.
generalEntity – The general entity (or its string identifier), the relationship destination.
- Returns:
The new
ProvSpecializationrecord.
- alternate(alternate1: ProvEntity | QualifiedName | str | Identifier, alternate2: ProvEntity | QualifiedName | str | Identifier) ProvAlternate[source]¶
Create a new alternate record between two entities.
- Parameters:
alternate1 – The first entity (or its string identifier), the relationship source.
alternate2 – The second entity (or its string identifier), the relationship destination.
- Returns:
The new
ProvAlternaterecord.
- mention(specificEntity: ProvEntity | QualifiedName | str | Identifier, generalEntity: ProvEntity | QualifiedName | str | Identifier, bundle: ProvEntity | QualifiedName | str | Identifier) ProvMention[source]¶
Create a new mention record from a general entity in a bundle.
- Parameters:
specificEntity – The specific entity (or its string identifier), the relationship source.
generalEntity – The general entity (or its string identifier), the relationship destination.
bundle – The bundle (or its string identifier) that the general entity is described in.
- Returns:
The new
ProvMentionrecord.
- collection(identifier: QualifiedName | str | Identifier, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvEntity[source]¶
Create a new collection entity and add it to the bundle.
A collection is an entity with an additional
prov:Collectiontype.- Parameters:
identifier – The identifier for the new collection.
other_attributes – Optional attributes for the collection, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvEntity, typed as a collection.
- membership(collection: ProvEntity | QualifiedName | str | Identifier, entity: ProvEntity | QualifiedName | str | Identifier) ProvMembership[source]¶
Create a new membership record adding an entity to a collection.
- Parameters:
collection – The collection (or its string identifier) the entity is added to.
entity – The entity (or its string identifier) added to the collection.
- Returns:
The new
ProvMembershiprecord.
- plot(filename: str | bytes | PathLike[str] | None = None, show_nary: bool = True, use_labels: bool = False, show_element_attributes: bool = True, show_relation_attributes: bool = True) None[source]¶
Plot the bundle as a graph, saving to a file or displaying it.
- Parameters:
filename – The path to save the plot to; the image format is derived from its extension. If not given, the plot is shown in an interactive matplotlib window (default:
None).show_nary – Whether to show all elements in n-ary relations (default:
True).use_labels – Whether to label elements by their
prov:labelproperty instead of their identifier (default:False).show_element_attributes – Whether to show element attributes (default:
True).show_relation_attributes – Whether to show relation attributes (default:
True).
- Raises:
ValueError – If the format implied by
filenamecannot be saved.ImportError – If no
filenameis given but matplotlib is not installed.
- wasGeneratedBy(entity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvRecord¶
Create a new generation record for an entity.
- Parameters:
entity – The generated entity (or its string identifier).
activity – The activity (or its string identifier) involved in the generation (default:
None).time – Optional time of the generation, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).identifier – Optional identifier for the generation record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new generation record.
- used(activity: ProvActivity | QualifiedName | str | Identifier, entity: ProvEntity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvUsage¶
Create a new usage record for an activity.
- Parameters:
activity – The using activity (or its string identifier).
entity – The entity (or its string identifier) involved in the usage relationship (default:
None).time – Optional time of the usage, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).identifier – Optional identifier for the usage record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvUsagerecord.
- wasStartedBy(activity: ProvActivity | QualifiedName | str | Identifier, trigger: ProvEntity | QualifiedName | str | Identifier | None = None, starter: ProvActivity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvStart¶
Create a new start record for an activity.
- Parameters:
activity – The started activity (or its string identifier).
trigger – The entity (or its string identifier) triggering the start (default:
None).starter – Optional activity qualifying the start, through which the trigger entity is generated (default:
None).time – Optional time of the start, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).identifier – Optional identifier for the start record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvStartrecord.
- wasEndedBy(activity: ProvActivity | QualifiedName | str | Identifier, trigger: ProvEntity | QualifiedName | str | Identifier | None = None, ender: ProvActivity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvEnd¶
Create a new end record for an activity.
- Parameters:
activity – The ended activity (or its string identifier).
trigger – The entity (or its string identifier) triggering the end (default:
None).ender – Optional activity qualifying the end, through which the trigger entity is generated (default:
None).time – Optional time of the end, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).identifier – Optional identifier for the end record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvEndrecord.
- wasInvalidatedBy(entity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvInvalidation¶
Create a new invalidation record for an entity.
- Parameters:
entity – The invalidated entity (or its string identifier).
activity – The activity (or its string identifier) involved in the invalidation (default:
None).time – Optional time of the invalidation, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).identifier – Optional identifier for the invalidation record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvInvalidationrecord.
- wasInformedBy(informed: ProvActivity | QualifiedName | str | Identifier, informant: ProvActivity | QualifiedName | str | Identifier, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvCommunication¶
Create a new communication record between two activities.
- Parameters:
informed – The informed activity (relationship destination).
informant – The informing activity (relationship source).
identifier – Optional identifier for the communication record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvCommunicationrecord.
- wasAttributedTo(entity: ProvEntity | QualifiedName | str | Identifier, agent: ProvAgent | ProvEntity | ProvActivity | QualifiedName | str | Identifier, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvAttribution¶
Create a new attribution record between an entity and an agent.
- Parameters:
entity – The entity (or its string identifier) being attributed (relationship source).
agent – The agent (or its string identifier) the entity is attributed to (relationship destination).
identifier – Optional identifier for the attribution record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvAttributionrecord.
- wasAssociatedWith(activity: ProvActivity | QualifiedName | str | Identifier, agent: ProvAgent | ProvEntity | ProvActivity | QualifiedName | str | Identifier | None = None, plan: ProvEntity | QualifiedName | str | Identifier | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvAssociation¶
Create a new association record for an activity.
- Parameters:
activity – The activity (or its string identifier).
agent – The agent (or its string identifier) associated with the activity (default:
None).plan – Optional entity qualifying the association through an internal plan (default:
None).identifier – Optional identifier for the association record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvAssociationrecord.
- actedOnBehalfOf(delegate: ProvAgent | ProvEntity | ProvActivity | QualifiedName | str | Identifier, responsible: ProvAgent | ProvEntity | ProvActivity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvDelegation¶
Create a new delegation record between two agents.
- Parameters:
delegate – The agent (or its string identifier) delegating the responsibility (relationship source).
responsible – The agent (or its string identifier) the responsibility is delegated to (relationship destination).
activity – Optional activity qualifying the delegation (default:
None).identifier – Optional identifier for the delegation record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvDelegationrecord.
- wasInfluencedBy(influencee: ProvEntity | QualifiedName | str | Identifier | ProvActivity | ProvAgent, influencer: ProvEntity | QualifiedName | str | Identifier | ProvActivity | ProvAgent, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvInfluence¶
Create a new influence record between two entities, activities or agents.
- Parameters:
influencee – The influenced entity, activity or agent (relationship source).
influencer – The influencing entity, activity or agent (relationship destination).
identifier – Optional identifier for the influence record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvInfluencerecord.
- wasDerivedFrom(generatedEntity: ProvEntity | QualifiedName | str | Identifier, usedEntity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, generation: ProvGeneration | QualifiedName | str | Identifier | None = None, usage: ProvUsage | QualifiedName | str | Identifier | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvDerivation¶
Create a new derivation record for a generated entity from a used entity.
- Parameters:
generatedEntity – The generated entity (or its string identifier), the relationship source.
usedEntity – The used entity (or its string identifier), the relationship destination.
activity – The activity (or its string identifier) involved in the derivation (default:
None).generation – Optional generation record qualifying the derivation through the activity’s generation of the generated entity (default:
None).usage – Optional usage record qualifying the derivation through the activity’s use of the used entity (default:
None).identifier – Optional identifier for the derivation record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvDerivationrecord.
- wasRevisionOf(generatedEntity: ProvEntity | QualifiedName | str | Identifier, usedEntity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, generation: ProvGeneration | QualifiedName | str | Identifier | None = None, usage: ProvUsage | QualifiedName | str | Identifier | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvDerivation¶
Create a new revision record for a generated entity from a used entity.
A revision is a derivation with an additional
prov:Revisiontype.- Parameters:
generatedEntity – The generated (revised) entity (or its string identifier), the relationship source.
usedEntity – The used (original) entity (or its string identifier), the relationship destination.
activity – The activity (or its string identifier) involved in the revision (default:
None).generation – Optional generation record qualifying the derivation (default:
None).usage – Optional usage record qualifying the derivation (default:
None).identifier – Optional identifier for the revision record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvDerivationrecord, typed as a revision.
- wasQuotedFrom(generatedEntity: ProvEntity | QualifiedName | str | Identifier, usedEntity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, generation: ProvGeneration | QualifiedName | str | Identifier | None = None, usage: ProvUsage | QualifiedName | str | Identifier | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvDerivation¶
Create a new quotation record for a generated entity from a used entity.
A quotation is a derivation with an additional
prov:Quotationtype.- Parameters:
generatedEntity – The quoting entity (or its string identifier), the relationship source.
usedEntity – The quoted entity (or its string identifier), the relationship destination.
activity – The activity (or its string identifier) involved in the quotation (default:
None).generation – Optional generation record qualifying the derivation (default:
None).usage – Optional usage record qualifying the derivation (default:
None).identifier – Optional identifier for the quotation record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvDerivationrecord, typed as a quotation.
- hadPrimarySource(generatedEntity: ProvEntity | QualifiedName | str | Identifier, usedEntity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, generation: ProvGeneration | QualifiedName | str | Identifier | None = None, usage: ProvUsage | QualifiedName | str | Identifier | None = None, identifier: QualifiedName | str | Identifier | None = None, other_attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvDerivation¶
Create a new primary-source record for a generated entity from a used entity.
A primary source is a derivation with an additional
prov:PrimarySourcetype.- Parameters:
generatedEntity – The derived entity (or its string identifier), the relationship source.
usedEntity – The primary-source entity (or its string identifier), the relationship destination.
activity – The activity (or its string identifier) involved (default:
None).generation – Optional generation record qualifying the derivation (default:
None).usage – Optional usage record qualifying the derivation (default:
None).identifier – Optional identifier for the primary-source record (default:
None).other_attributes – Optional extra attributes, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
The new
ProvDerivationrecord, typed as a primary source.
- alternateOf(alternate1: ProvEntity | QualifiedName | str | Identifier, alternate2: ProvEntity | QualifiedName | str | Identifier) ProvAlternate¶
Create a new alternate record between two entities.
- Parameters:
alternate1 – The first entity (or its string identifier), the relationship source.
alternate2 – The second entity (or its string identifier), the relationship destination.
- Returns:
The new
ProvAlternaterecord.
- specializationOf(specificEntity: ProvEntity | QualifiedName | str | Identifier, generalEntity: ProvEntity | QualifiedName | str | Identifier) ProvSpecialization¶
Create a new specialisation record from a general entity.
- Parameters:
specificEntity – The specific entity (or its string identifier), the relationship source.
generalEntity – The general entity (or its string identifier), the relationship destination.
- Returns:
The new
ProvSpecializationrecord.
- mentionOf(specificEntity: ProvEntity | QualifiedName | str | Identifier, generalEntity: ProvEntity | QualifiedName | str | Identifier, bundle: ProvEntity | QualifiedName | str | Identifier) ProvMention¶
Create a new mention record from a general entity in a bundle.
- Parameters:
specificEntity – The specific entity (or its string identifier), the relationship source.
generalEntity – The general entity (or its string identifier), the relationship destination.
bundle – The bundle (or its string identifier) that the general entity is described in.
- Returns:
The new
ProvMentionrecord.
- hadMember(collection: ProvEntity | QualifiedName | str | Identifier, entity: ProvEntity | QualifiedName | str | Identifier) ProvMembership¶
Create a new membership record adding an entity to a collection.
- Parameters:
collection – The collection (or its string identifier) the entity is added to.
entity – The entity (or its string identifier) added to the collection.
- Returns:
The new
ProvMembershiprecord.
Elements¶
- class prov.model.ProvEntity(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvElementProvenance Entity element
- wasGeneratedBy(activity: ProvActivity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvEntity[source]¶
Create a new generation record to this entity.
- Parameters:
activity – The activity (or its string identifier) involved in the generation (default:
None).time – Optional time of the generation, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).attributes – Optional extra attributes for the record, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
This entity (to allow chaining).
- wasInvalidatedBy(activity: ProvActivity | QualifiedName | str | Identifier | None, time: datetime | str | None = None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvEntity[source]¶
Create a new invalidation record for this entity.
- Parameters:
activity – The activity (or its string identifier) involved in the invalidation; may be
None.time – Optional time of the invalidation, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).attributes – Optional extra attributes for the record, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
This entity (to allow chaining).
- wasDerivedFrom(usedEntity: ProvEntity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, generation: ProvGeneration | QualifiedName | str | Identifier | None = None, usage: ProvUsage | QualifiedName | str | Identifier | None = None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvEntity[source]¶
Create a new derivation record for this entity from a used entity.
- Parameters:
usedEntity – The used entity (or its string identifier).
activity – The activity (or its string identifier) involved in the derivation (default:
None).generation – Optional generation record qualifying the derivation through an internal generation (default:
None).usage – Optional usage record qualifying the derivation through an internal usage (default:
None).attributes – Optional extra attributes for the record, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
This entity (to allow chaining).
- wasAttributedTo(agent: ProvAgent | ProvEntity | ProvActivity | QualifiedName | str | Identifier, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvEntity[source]¶
Create a new attribution record between this entity and an agent.
- Parameters:
agent – The agent (or its string identifier) involved in the attribution.
attributes – Optional extra attributes for the record, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
This entity (to allow chaining).
- alternateOf(alternate2: ProvEntity | QualifiedName | str | Identifier) ProvEntity[source]¶
Create a new alternate record between this and another entity.
- Parameters:
alternate2 – The other entity (or its string identifier).
- Returns:
This entity (to allow chaining).
- specializationOf(generalEntity: ProvEntity | QualifiedName | str | Identifier) ProvEntity[source]¶
Create a new specialisation record for this from a general entity.
- Parameters:
generalEntity – The general entity (or its string identifier).
- Returns:
This entity (to allow chaining).
- hadMember(entity: ProvEntity | QualifiedName | str | Identifier) ProvEntity[source]¶
Create a new membership record adding an entity to this collection.
- Parameters:
entity – The entity (or its string identifier) to add to the collection.
- Returns:
This entity (to allow chaining).
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = ()¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvActivity(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvElementProvenance Activity element.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:startTime>, <QualifiedName: prov:endTime>)¶
Formal attributes names of this record type, in the expected order.
- set_time(startTime: datetime | None = None, endTime: datetime | None = None) None[source]¶
Set the start and/or end time of this activity.
Only non-
Nonearguments are applied; the values are stored as given (no string parsing is performed here).- Parameters:
startTime – The start time as a
datetime.datetime(default:None).endTime – The end time as a
datetime.datetime(default:None).
- used(entity: ProvEntity | QualifiedName | str | Identifier, time: datetime | str | None = None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvActivity[source]¶
Create a new usage record for this activity.
- Parameters:
entity – The entity (or its string identifier) involved in the usage relationship.
time – Optional time of the usage, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).attributes – Optional extra attributes for the record, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
This activity (to allow chaining).
- wasInformedBy(informant: ProvActivity | QualifiedName | str | Identifier, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvActivity[source]¶
Create a new communication record for this activity.
- Parameters:
informant – The informing activity (relationship source).
attributes – Optional extra attributes for the record, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
This activity (to allow chaining).
- wasStartedBy(trigger: ProvEntity | QualifiedName | str | Identifier | None, starter: ProvActivity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvActivity[source]¶
Create a new start record for this activity.
The activity did not exist before being started by the trigger.
- Parameters:
trigger – The entity triggering the start of this activity; may be
None.starter – Optional activity qualifying the start, through which the trigger entity is generated (default:
None).time – Optional time of the start, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).attributes – Optional extra attributes for the record, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
This activity (to allow chaining).
- wasEndedBy(trigger: ProvEntity | QualifiedName | str | Identifier | None, ender: ProvActivity | QualifiedName | str | Identifier | None = None, time: datetime | str | None = None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvActivity[source]¶
Create a new end record for this activity.
- Parameters:
trigger – The entity triggering the end of this activity; may be
None.ender – Optional activity qualifying the end, through which the trigger entity is generated (default:
None).time – Optional time of the end, as a
datetime.datetimeor a string parseable bydateutil.parser.parse()(default:None).attributes – Optional extra attributes for the record, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
This activity (to allow chaining).
- wasAssociatedWith(agent: ProvAgent | ProvEntity | ProvActivity | QualifiedName | str | Identifier, plan: ProvEntity | QualifiedName | str | Identifier | None = None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvActivity[source]¶
Create a new association record for this activity.
- Parameters:
agent – The agent (or its string identifier) involved in the association.
plan – Optional entity qualifying the association through an internal plan (default:
None).attributes – Optional extra attributes for the record, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
This activity (to allow chaining).
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvAgent(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvElementProvenance Agent element.
- actedOnBehalfOf(responsible: ProvAgent | ProvEntity | ProvActivity | QualifiedName | str | Identifier, activity: ProvActivity | QualifiedName | str | Identifier | None = None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None) ProvAgent[source]¶
Create a new delegation record on behalf of this agent.
- Parameters:
responsible – The agent (or its string identifier) that the responsibility is delegated to.
activity – Optional activity qualifying the delegation (default:
None).attributes – Optional extra attributes for the record, as a dict or an iterable of
(name, value)pairs (default:None).
- Returns:
This agent (to allow chaining).
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = ()¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
Relations¶
- class prov.model.ProvGeneration(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Generation relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:entity>, <QualifiedName: prov:activity>, <QualifiedName: prov:time>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvUsage(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Usage relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:activity>, <QualifiedName: prov:entity>, <QualifiedName: prov:time>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvCommunication(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Communication relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:informed>, <QualifiedName: prov:informant>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvStart(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Start relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:activity>, <QualifiedName: prov:trigger>, <QualifiedName: prov:starter>, <QualifiedName: prov:time>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvEnd(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance End relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:activity>, <QualifiedName: prov:trigger>, <QualifiedName: prov:ender>, <QualifiedName: prov:time>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvInvalidation(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Invalidation relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:entity>, <QualifiedName: prov:activity>, <QualifiedName: prov:time>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvDerivation(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Derivation relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:generatedEntity>, <QualifiedName: prov:usedEntity>, <QualifiedName: prov:activity>, <QualifiedName: prov:generation>, <QualifiedName: prov:usage>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvAttribution(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Attribution relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:entity>, <QualifiedName: prov:agent>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvAssociation(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Association relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:activity>, <QualifiedName: prov:agent>, <QualifiedName: prov:plan>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvDelegation(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Delegation relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:delegate>, <QualifiedName: prov:responsible>, <QualifiedName: prov:activity>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvInfluence(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Influence relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:influencee>, <QualifiedName: prov:influencer>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvSpecialization(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Specialization relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:specificEntity>, <QualifiedName: prov:generalEntity>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvAlternate(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Alternate relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:alternate1>, <QualifiedName: prov:alternate2>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvMention(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvSpecializationProvenance Mention relationship (specific Specialization).
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:specificEntity>, <QualifiedName: prov:generalEntity>, <QualifiedName: prov:bundle>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
- class prov.model.ProvMembership(bundle: ProvBundle, identifier: QualifiedName | None, attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]] | None = None)[source]¶
Bases:
ProvRelationProvenance Membership relationship.
- FORMAL_ATTRIBUTES: tuple[QualifiedName, ...] = (<QualifiedName: prov:collection>, <QualifiedName: prov:entity>)¶
Formal attributes names of this record type, in the expected order.
- add_asserted_type(type_identifier: QualifiedName) None¶
Add a PROV type assertion to the record.
- Parameters:
type_identifier – The qualified name of the type to assert.
- add_attributes(attributes: dict[QualifiedName | str | Identifier, Any] | Iterable[tuple[QualifiedName | str | Identifier, Any]]) None¶
Add attributes to the record.
Attribute names are resolved to qualified names, and values are normalised to the datatype expected for the attribute.
Nonevalues are skipped.- Parameters:
attributes – The attributes to add, either as a dict keyed by qualified-name identifiers or an iterable of
(name, value)pairs whose names satisfy the same condition.- Raises:
ProvExceptionInvalidQualifiedName – If an attribute name cannot be resolved to a valid qualified name.
ProvException – If a value is invalid for its attribute, or a second, different value is supplied for a single-valued (non-collection) attribute.
- property args: tuple[Any, ...]¶
The values of the record’s formal attributes, in declaration order.
Missing formal attributes are represented by
None.
- property attributes: list[tuple[QualifiedName, Any]]¶
All of the record’s attributes as a list of
(name, value)pairs.Attributes with multiple values appear once per value, so the same name may occur more than once.
- property bundle: ProvBundle¶
The bundle that owns this record.
- copy() ProvRecord¶
Return an exact copy of this record.
- property extra_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s non-formal attributes as
(name, value)pairs.
- property formal_attributes: tuple[tuple[QualifiedName, Any], ...]¶
The record’s formal attributes as
(name, value)pairs.Pairs are in declaration order; a missing attribute has a value of
None.
- get_asserted_types() set[QualifiedName]¶
Return the set of all asserted PROV types of this record.
- get_attribute(attr_name: QualifiedName | str | Identifier) set[Any]¶
Return the values (if any) for the named attribute.
- Parameters:
attr_name – The name of the attribute.
- Returns:
The set of values held for the attribute (empty if none).
- Raises:
ProvExceptionInvalidQualifiedName – If
attr_namecannot be resolved to a valid qualified name.
- get_type() QualifiedName¶
Return the PROV type of the record.
- Raises:
NotImplementedError – If the record type is undefined (i.e. on the abstract base classes).
- property identifier: QualifiedName | None¶
The record’s identifier, or
Noneif it has none.
Namespaces and literals¶
- class prov.model.NamespaceManager(namespaces: dict[str, str] | Iterable[Namespace] | None = None, default: str | None = None, parent: NamespaceManager | None = None)[source]¶
-
Manages namespaces for PROV documents and bundles.
- parent: NamespaceManager | None = None¶
Parent
NamespaceManagerthis manager is a child of, if any.
- get_namespace(uri: str) Namespace | None[source]¶
Return the known namespace with the given URI.
- Parameters:
uri – The namespace URI to look up.
- Returns:
The matching
Namespace, orNoneif no known namespace has that URI.
- get_registered_namespaces() Iterable[Namespace][source]¶
Return all explicitly registered namespaces.
- Returns:
An iterable of
Namespace. This excludes the default namespaces (prov,xsd,xsi).
- set_default_namespace(uri: str) None[source]¶
Set the default namespace to one with the given URI.
- Parameters:
uri – The URI of the default namespace.
- get_default_namespace() Namespace | None[source]¶
Return the default namespace, or
Noneif none is set.
- add_namespace(namespace: Namespace) Namespace[source]¶
Add a namespace, unless an equivalent one is already registered.
If a namespace with the same URI already exists, that existing namespace is returned. If the prefix conflicts with a different namespace, the added namespace is renamed to an unused prefix.
- Parameters:
namespace – The
Namespaceto add.- Returns:
The registered namespace, which may be the existing or renamed one rather than the argument.
- add_namespaces(namespaces: dict[str, str] | Iterable[Namespace]) None[source]¶
Add multiple namespaces into this manager.
- Parameters:
namespaces – The namespaces to add, as a
{prefix: uri}dict or an iterable ofNamespace.
- valid_qualified_name(qname: QualifiedName | str | Identifier) QualifiedName | None[source]¶
Resolve an identifier to a valid qualified name.
Registers the namespace of the resolved name if it was not registered already. Where the identifier is a string or
Identifier, an attempt is made to expand a known prefix or compact a known namespace URI, delegating to the parent manager if all local attempts fail.- Parameters:
qname – The candidate to resolve, as a
QualifiedName,Identifier, or string.- Returns:
The resolved
QualifiedName, orNoneif it could not be resolved.
- get_anonymous_identifier(local_prefix: str = 'id') Identifier[source]¶
Return a fresh anonymous (blank-node) identifier.
Each call increments an internal counter, so successive calls return distinct identifiers.
- Parameters:
local_prefix – Prefix for the local part of the identifier (default:
"id").- Returns:
A new
Identifierof the form_:<local_prefix><n>.
- class prov.model.Literal(value: Any, datatype: QualifiedName | None = None, langtag: str | None = None)[source]¶
Bases:
objectA typed (and optionally language-tagged) PROV literal value.
A literal pairs a string value with an optional datatype and an optional language tag. Supplying a language tag forces the datatype to
prov:InternationalizedString: if no datatype was given one is assumed, and any other datatype is overridden (with a warning) to comply with the PROV-JSON/PROV-XML rules for language-tagged strings.- property datatype: QualifiedName | None¶
The literal’s datatype, or
Noneif it has none.
Exceptions¶
- class prov.model.ProvExceptionInvalidQualifiedName(qname: Any)[source]¶
Bases:
ProvExceptionException for an invalid qualified identifier name.
- qname = None¶
The invalid qualified name that triggered the exception.
- class prov.model.ProvElementIdentifierRequired[source]¶
Bases:
ProvExceptionException for a missing element identifier.