Interface functions

These functions allow you to activate/deactivate provenance tracking, and view the raw history, and serialize the information to a file.

alpaca.activate(clear=False)[source]

Activates provenance tracking within the script.

Parameters:
clearbool, optional

If True, the history is cleared and execution counter is reset to zero. Default: False

alpaca.deactivate()[source]

Deactivates provenance tracking within Elephant.

alpaca.print_history()[source]

Print all executions in the provenance track history.

alpaca.save_provenance(file_name=None, file_format='ttl', show_progress=False)[source]

Serialize provenance information to RDF according to the Alpaca ontology based on the W3C PROV Ontology (PROV-O).

Parameters:
file_namestr or Path-like, optional

Destination file to serialize the provenance information. If None, the function will return a string containing the provenance information in the specified format. Default: None

file_format{‘json-ld’, ‘n3’, ‘nt’, ‘hext’, ‘pretty-xml’, ‘trig’, ‘turtle’, ‘longturtle’, ‘xml’, ‘ttl’, ‘rdf’, ‘json’}

Format into which the provenance data is serialized. The formats are the ones accepted by RDFLib. Some shortucts are defined for common file extensions:

  • ‘ttl’: Turtle

  • ‘rdf’: RDF/XML

  • ‘json’: JSON-LD

Default: ‘ttl’

show_progressbool, optional

If True, show a bar with the progress of the serialization to RDF. Default: False

Returns:
str or None

If file_name is None, the function returns the PROV information as a string. If a file destination was informed, the return is None.