def test_basic_easy(self): flow.Workspace.clear_supported_filter_types() flow.Workspace.register_filter_type(flow.wrap_function(src)) flow.Workspace.register_filter_type(flow.wrap_function(inc)) flow.Workspace.register_filter_type(flow.wrap_function(add)) flow.Workspace.register_filter_type(flow.wrap_function(prnt)) w = flow.Workspace() print(w.registry()) # add our filters w.graph().add_filter("src", "s") w.graph().add_filter("inc", "a") w.graph().add_filter("inc", "b") w.graph().add_filter("inc", "c") # connect everything up w.graph().connect("s", "a", "i") w.graph().connect("a", "b", "i") w.graph().connect("b", "c", "i") print(w) w.execute() print("Reg from Py") print(w.registry()) v = w.registry().fetch("c") self.assertEqual(v, 4)
def test_inception(self): flow.Workspace.clear_supported_filter_types() flow.Workspace.register_builtin_filter_types() flow.Workspace.register_filter_type(flow.wrap_function(src)) w = flow.Workspace() w.graph().add_filter("src", "s") # py_params = conduit.Node() py_params["source"] = py_script w.graph().add_filter("python_script", "py", py_params) w.graph().connect("s", "py", "in") print(w) w.execute() print("Reg from Py") print(w.registry()) v = w.registry().fetch("py") self.assertEqual(v, 42)
def test_render_flow_inspect(self): # if we don't have ascent, simply return info = ascent.about() if info["runtimes/ascent/status"] != "enabled": return flow.Workspace.register_builtin_filter_types() flow.Workspace.register_filter_type(flow.wrap_function(inspect)); # create example mesh n_mesh = conduit.Node() conduit.blueprint.mesh.examples.braid("quads", 10, 10, 0, n_mesh) # open ascent a = ascent.Ascent() open_opts = conduit.Node() open_opts["runtime/type"].set("flow") a.open(open_opts) a.publish(n_mesh) actions = conduit.Node() add_py = actions.append() add_py["action"] = "add_filter"; add_py["type_name"] = "ensure_python"; add_py["name"] = "py"; add_ins = actions.append() add_ins["action"] = "add_filter"; add_ins["type_name"] = "inspect"; add_ins["name"] = "my_inspect"; conn_py = actions.append() conn_py["action"] = "connect"; conn_py["src"] = "source"; conn_py["dest"] = "py"; conn_ins = actions.append() conn_ins["action"] = "connect"; conn_ins["src"] = "py"; conn_ins["dest"] = "my_inspect"; print(actions) actions.append()["action"] = "execute" # this will fail for static libs case # b/c the py libs are still dynamic, and they each # link their own static copy of flow try: a.execute(actions) except RuntimeError as e: if not e.message.count("ensure_python") > 0: raise(e) a.close()