Skip to content

Hdf5 persistence

Wout De Nolf requested to merge hdf5_persistency into main

Variables have a "dtype":

from ewokscore.variable import Variable

varinfo = {"root_uri": "/tmp/mydata", "dtype": "nexus"}

var1 = Variable(varinfo=varinfo)
var1.value = [1, 2, 3]
var1.dump()

var2 = Variable(uhash=var1.uhash, varinfo=varinfo)
assert var2.value.tolist() == var1.value

The "dtype" of task outputs can be specified for all tasks or for each task individually:

from ewokscore import load_graph


def add(*args):
    return sum(args)


nodes = [
    {
        "id": f"task{i}",
        "method": "__main__.add",
        "inputs": {0: 1},
        "varinfo": {"dtype": "nexus"},
    }
    for i in range(4)
]
links = [
    {"source": f"task{i}", "target": f"task{i+1}", "arguments": {1: "return_value"}}
    for i in range(3)
]

graph = load_graph({"nodes": nodes, "links": links})
varinfo = {"root_uri": "dataset.nx::/scan", "dtype": "json"}
graph.execute(varinfo=varinfo)
Edited by Wout De Nolf

Merge request reports