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: ProvBundle

Provenance Document.

is_document() bool[source]

Return True if this is a document, False otherwise.

is_bundle() bool[source]

Return True if this is a (named) bundle, False otherwise.

has_bundles() bool[source]

Return True if the document contains bundles, False otherwise.

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 other are 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 ProvDocument or ProvBundle whose records are appended.

Raises:

ProvException – If other is not a ProvBundle (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 ProvBundle to add.

  • identifier – Optional identifier to use for the bundle; if not given, the bundle’s own identifier is used (default: None).

Raises:

ProvException – If bundle is not a ProvBundle, 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 identifier is None or 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" (see prov.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 yields None.

  • 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 destination was given, otherwise None.

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 source or content should be given; content takes 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 str or bytes to 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 source nor content is 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: object

PROV Bundle

property namespaces: set[Namespace]

The set of the bundle’s registered namespaces.

property default_ns_uri: str | None

The bundle’s default namespace URI, or None if none is set.

property document: ProvDocument | None

The parent document of this bundle, or None if it has none.

property identifier: QualifiedName | None

The bundle’s identifier, or None if it has none.

property records: list[ProvRecord]

A copy of the list of all records in this bundle.

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 None if 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 Namespace to add, or a prefix string (in which case uri is required).

  • uri – The namespace URI; required when namespace_or_prefix is 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, or None if 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 ProvRecord objects (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 ProvRecord objects, or an empty list if the identifier is invalid or unknown.

is_document() bool[source]

Return True if this is a document, False otherwise.

is_bundle() bool[source]

Return True if this is a (named) bundle, False otherwise.

has_bundles() bool[source]

Return True if this object contains bundles, False otherwise.

property bundles: Iterable[ProvBundle]

The bundles contained in this object.

Raises:

ProvException – Always, since a plain bundle cannot contain sub-bundles. Only ProvDocument overrides this.

get_provn(_indent_level: int = 0) str[source]

Return the PROV-N representation of the bundle.

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 ProvBundle whose records are appended.

Raises:

ProvException – If other is not a ProvBundle, 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 None for 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 record itself.

Parameters:

record – The ProvRecord to copy into the bundle.

Returns:

The newly created ProvRecord belonging 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.datetime or a string parseable by dateutil.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.datetime or a string parseable by dateutil.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.datetime or a string parseable by dateutil.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 ProvUsage record.

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.datetime or a string parseable by dateutil.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 ProvStart record.

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.datetime or a string parseable by dateutil.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 ProvEnd record.

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.datetime or a string parseable by dateutil.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 ProvInvalidation record.

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 ProvCommunication record.

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 ProvAttribution record.

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 ProvAssociation record.

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 ProvDelegation record.

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 ProvInfluence record.

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 ProvDerivation record.

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:Revision type.

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 ProvDerivation record, 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:Quotation type.

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 ProvDerivation record, 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:PrimarySource type.

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 ProvDerivation record, 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 ProvSpecialization record.

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 ProvAlternate record.

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 ProvMention record.

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:Collection type.

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 ProvMembership record.

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:label property 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 filename cannot be saved.

  • ImportError – If no filename is 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.datetime or a string parseable by dateutil.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.datetime or a string parseable by dateutil.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 ProvUsage record.

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.datetime or a string parseable by dateutil.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 ProvStart record.

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.datetime or a string parseable by dateutil.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 ProvEnd record.

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.datetime or a string parseable by dateutil.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 ProvInvalidation record.

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 ProvCommunication record.

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 ProvAttribution record.

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 ProvAssociation record.

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 ProvDelegation record.

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 ProvInfluence record.

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 ProvDerivation record.

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:Revision type.

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 ProvDerivation record, 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:Quotation type.

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 ProvDerivation record, 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:PrimarySource type.

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 ProvDerivation record, 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 ProvAlternate record.

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 ProvSpecialization record.

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 ProvMention record.

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 ProvMembership record.

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: ProvElement

Provenance 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.datetime or a string parseable by dateutil.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.datetime or a string parseable by dateutil.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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvElement

Provenance 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-None arguments are applied; the values are stored as given (no string parsing is performed here).

Parameters:
get_startTime() datetime | None[source]

Return the activity’s start time, or None if unset.

get_endTime() datetime | None[source]

Return the activity’s end time, or None if unset.

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.datetime or a string parseable by dateutil.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.datetime or a string parseable by dateutil.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.datetime or a string parseable by dateutil.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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvElement

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvSpecialization

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

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: ProvRelation

Provenance 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. None values 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_name cannot be resolved to a valid qualified name.

get_provn() str

Return the PROV-N representation of the record.

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 None if it has none.

is_element() bool

Return True if the record is an element, False otherwise.

is_relation() bool

Return True if the record is a relation, False otherwise.

property label: str

The record’s identifying label.

This is the record’s prov:label attribute if set, otherwise its identifier.

property value: Any

The set of the record’s prov:value attribute values.

Namespaces and literals

class prov.model.NamespaceManager(namespaces: dict[str, str] | Iterable[Namespace] | None = None, default: str | None = None, parent: NamespaceManager | None = None)[source]

Bases: dict[str, Namespace]

Manages namespaces for PROV documents and bundles.

parent: NamespaceManager | None = None

Parent NamespaceManager this 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, or None if 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 None if 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 Namespace to 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 of Namespace.

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, or None if 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 Identifier of the form _:<local_prefix><n>.

class prov.model.Literal(value: Any, datatype: QualifiedName | None = None, langtag: str | None = None)[source]

Bases: object

A 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 value: str

The literal’s value as a string.

property datatype: QualifiedName | None

The literal’s datatype, or None if it has none.

property langtag: str | None

The literal’s language tag, or None if it has none.

has_no_langtag() bool[source]

Return True if the literal has no language tag.

provn_representation() str[source]

Return the PROV-N representation of the literal.

Exceptions

class prov.Error[source]

Bases: Exception

Base class for all errors in this package.

class prov.model.ProvException[source]

Bases: Error

Base class for PROV model exceptions.

class prov.model.ProvWarning[source]

Bases: Warning

Base class for PROV model warnings.

class prov.model.ProvExceptionInvalidQualifiedName(qname: Any)[source]

Bases: ProvException

Exception for an invalid qualified identifier name.

qname = None

The invalid qualified name that triggered the exception.

class prov.model.ProvElementIdentifierRequired[source]

Bases: ProvException

Exception for a missing element identifier.