from pprint import pprint import extensible_provn.view.prov_dictionary import annotations as prov HIDE = prov.HIDE SPECIFIC = prov.SPECIFIC prov.reset_prov("../generated/prov_dictionary/") prov.STATS_VIEW = 1 EMPTY = prov.entity("empty", "[]", "EmptyDictionary", None, None, attrs=SPECIFIC) def empty(name): return EMPTY def cond(ents): return ents # Line 1 m = 10000 # max value with prov.desc("L1 - assign", line=1) as line: e_n10000 = prov.entity("10000", "10000", prov.SCRIPT + "literal", None, line, attrs=HIDE) e_m = prov.entity("m", "10000", prov.SCRIPT + "name", "10000", line, attrs=HIDE) prov.activity("assign", [(e_m, e_n10000)], attrs=HIDE) # Line 2 result = dist = [ [0, 1, 4], [m, 0, 2],
**extra)) def generate(ents, extra={}, checkpoint=None): checkpoint = checkpoint or time() return prov.Generation( *ents, attrs=dict(**{prov.NAMESPACE + "checkpoint": checkpoint}, **extra)) # Line 1 m = 10000 # max value with prov.desc("L1 - assign", line=1) as line: e_n10000 = prov.entity("10000", "10000", prov.SCRIPT + "literal", None, line, attrs=HIDE) e_m = prov.entity("m", "10000", prov.SCRIPT + "name", "m", line) prov.activity("assign", [prov.RefDerivation(time(), e_m, e_n10000, attrs=HIDE)], attrs=HIDE) # Line 2 result = dist = [[0, 1, 4], [m, 0, 2], [2, m, 0]] with prov.desc("L2 - list definition / assign", line=2) as line: with prov.desc("L2 - list definition"): e_n0 = prov.entity("0", "0", prov.SCRIPT + "literal", None, line + 1) e_n1 = prov.entity("1", "1", prov.SCRIPT + "literal", None, line + 1) e_n4 = prov.entity("4", "4", prov.SCRIPT + "literal", None, line + 1)
def time(): return datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f") def cond(ents): return ents # Line 1 m = 10000 # max value with prov.desc("L1 - assign", line=1) as line: e_n10000 = prov.entity("10000", None, prov.SCRIPT + "literal", "10000", line, attrs=HIDE) v_10000 = prov.value("v10000", "10000", attrs=SPECIFIC) prov.defined(e_n10000, v_10000, time(), attrs=SPECIFIC) e_m = prov.entity("m", None, prov.SCRIPT + "name", "m", line, attrs=HIDE) prov.activity("assign", [(e_m, e_n10000)], attrs=HIDE) prov.accessed(e_m, v_10000, time(), attrs=SPECIFIC) # Line 2 result = dist = [[0, 1, 4], [m, 0, 2], [2, m, 0]] with prov.desc("L2 - list definition / assign", line=2) as line: with prov.desc("L2 - list definition"): e_n0 = prov.entity("0", None,