From a44b2182bd45b2fe6025a6b90cd49096a47e187b Mon Sep 17 00:00:00 2001 From: Oleg Date: Thu, 8 Feb 2024 14:55:41 +0300 Subject: [PATCH] dasgate now works with das-query-engine v0.4.1 --- python/hyperon/exts/das_gate/dasgate.py | 22 +++++++--------------- repl/Cargo.toml | 5 +---- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/python/hyperon/exts/das_gate/dasgate.py b/python/hyperon/exts/das_gate/dasgate.py index 62818db85..e8c64e176 100644 --- a/python/hyperon/exts/das_gate/dasgate.py +++ b/python/hyperon/exts/das_gate/dasgate.py @@ -110,27 +110,19 @@ def _handle2atom3(self, h): def query(self, query_atom): query = self._atom2dict_new(query_atom) - vars = [x for x in self._get_all_vars(query_atom)] - - query_params = { - "toplevel_only": False, - "return_type": QueryOutputFormat.ATOM_INFO, - 'query_scope': 'local_only' - } - answer = self.das.query(query, - query_params) + answer = [query_answer for query_answer in self.das.query(query)] new_bindings_set = BindingsSet.empty() + if not answer: return new_bindings_set + for a in answer: bindings = Bindings() - if isinstance(a, list): - b = a[0] - else: - b = a - var = vars[0]['name'][1:] - bindings.add_var_binding(V(var), self._handle2atom3(b)) + for var, val in a.assignment.mapping.items(): + # remove '$', because it is automatically added + bindings.add_var_binding(V(var[1:]), self._handle2atom(val)) new_bindings_set.push(bindings) + return new_bindings_set def query_old(self, query_atom): diff --git a/repl/Cargo.toml b/repl/Cargo.toml index 4f1591d8a..6e8394ba6 100644 --- a/repl/Cargo.toml +++ b/repl/Cargo.toml @@ -6,14 +6,11 @@ description = "A shell to execute MeTTa" [dependencies] anyhow = { version = "1.0.75", features = ["std"] } -<<<<<<< HEAD # rustyline = { version = "12.0.0", features = ["derive"] } # rustyline = {git = "https://github.com/luketpeterson/rustyline", version = "12.0.0", features = ["derive"] } # TODO: Yay, our fix landed in main. Still needs to publish however. One step closer -rustyline = {git = "https://github.com/kkawakam/rustyline", version = "12.0.0", features = ["derive"] } -======= +#rustyline = {git = "https://github.com/kkawakam/rustyline", version = "12.0.0", features = ["derive"] } rustyline = { version = "13.0.0", features = ["derive"] } ->>>>>>> 7b73a4f48478b9a91b111c2b50a0f979c0ad4772 clap = { version = "4.4.0", features = ["derive"] } signal-hook = "0.3.17" pyo3 = { version = "0.19.2", features = ["auto-initialize"], optional = true }