makeprov.prov
Functions
|
Add dunder methods based on the fields defined in the class. |
|
Deep copy operation on arbitrary Python objects. |
|
Return an object to identify dataclass fields. |
|
Normalize a package name according to PEP 503 rules. |
|
Extract package metadata for provenance enrichment. |
Classes
|
|
|
|
|
Special type indicating an unconstrained type. |
|
|
|
|
|
|
|
|
|
|
|
PurePath subclass that can make system calls. |
|
|
|
|
|
Provide JSON-LD serialization helpers for dataclasses. |
|
The year, month and day arguments are required. |
|
Fixed offset from UTC implementation of tzinfo. |
- class makeprov.prov.ActivityNode(id, type, startedAtTime=None, endedAtTime=None, wasAssociatedWith=None, used=None, comment=None)
Bases:
BaseNode
- class makeprov.prov.EnvNode(id, type, label='Python environment', title=None, hasVersion=None, requires=None)
Bases:
BaseNode
- class makeprov.prov.FileEntity(id, type, format=None, extent=None, modified=None, identifier=None, wasGeneratedBy=None)
Bases:
BaseNode
- class makeprov.prov.GraphEntity(id, type, wasGeneratedBy=None, wasAttributedTo=None, generatedAtTime=None)
Bases:
BaseNode
- class makeprov.prov.Prov(base_iri, name, provenance, results, context=<factory>)
Bases:
object- classmethod create(base_iri, name, run_id, t0, t1, inputs, outputs, results, success=True)
Assemble a provenance graph from rule execution details.
- Parameters:
name (
str) – Logical rule name.run_id (
str) – Unique identifier for this run, typically timestamp-based.t0 (
datetime) – Start time of the rule execution.t1 (
datetime) – End time of the rule execution.results (
list[RDFMixin]) – Optional result graphs to embed alongside provenance records.success (
bool) – Whether the rule completed successfully.
- Returns:
A populated
Provinstance ready for serialization.- Return type:
Examples
prov = Prov.create( base_iri=None, name="uppercase", run_id="20240101T120000", t0=start, t1=end, inputs=[Path("input.txt")], outputs=[Path("output.txt")], results=[], )
- classmethod merge(provs)
Combine multiple provenance documents into one.
- Parameters:
- Returns:
A new object containing combined provenance and results from all inputs.
- Return type:
Examples
merged = Prov.merge([prov_a, prov_b])
- results: tuple[GraphEntity, list[RDFMixin]]
- to_graph(frame='provenance')
- write(prov_path, fmt='json', frame='provenance', context=False, context_url=None)
Serialize provenance to disk.
- Parameters:
prov_path (
str|Path) – Output path (without extension) where the provenance document should be written.fmt (str) – Output format,
"json"for JSON-LD or"trig"for RDF TriG.frame (str) – Which structure to make primary subject of jsonld or trig named graph. Options: “provenance” or “results”.
context (bool) – Whether to include the JSON-LD context inline when writing JSON.
- Returns:
The path to the written provenance document with extension.
- Return type:
- Raises:
Exception – If the requested format is unsupported.
Examples
output = prov.write("prov/uppercase", fmt="json", context=True)
- makeprov.prov.pep503_normalize(name)
Normalize a package name according to PEP 503 rules.
- makeprov.prov.project_metadata(dist_name=None)
Extract package metadata for provenance enrichment.
- Parameters:
dist_name (
str|None) – Distribution name; whenNonethe caller’s package name is inferred from the module context.- Returns:
Distribution name, version, and dependency specifications. Empty values are returned when metadata cannot be found.
- Return type:
Examples
name, version, requires = project_metadata("makeprov")