Skip to content

Commit

Permalink
chore: Renamed iql -> gensql in sci code
Browse files Browse the repository at this point in the history
  • Loading branch information
KingMob committed Apr 30, 2024
1 parent 2b74746 commit ba78553
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 107 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The command-line application currently supports GenSQL-strict and GenSQL-permiss
If you would like to use `GenSQL.query` to query SPPL models you will need to ensure that SPPL is on the classpath, and that [libpython-clj](https://github.com/clj-python/libpython-clj) can find a Python where SPPL is installed. The easiest way to accomplish this is to use [Nix](https://nixos.org/):

```shell
nix develop github:OpenGen/GenSQL.gpm.sppl -c clj -Sdeps '{:deps {io.github.OpenGen/GenSQL.gpm.sppl {:git/sha "52f8316e094b3644709dccde8f0a935f9b55f187"}}}' -M -m gensql.query.main --help
nix develop github:OpenGen/GenSQL.gpm.sppl -c clj -Sdeps '{:deps {io.github.OpenGen/GenSQL.gpm.sppl {:git/sha "718de40878766bb8d08acc2b429a76ed662a1352"}}}' -M -m gensql.query.main --help
```

### Clojure interface
Expand Down
4 changes: 2 additions & 2 deletions deps-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
{
"lib": "io.github.OpenGen/GenSQL.inference",
"url": "https://github.com/OpenGen/GenSQL.inference.git",
"rev": "c3cef474ba964a37fc2e5ff667055f5b77e12c45",
"rev": "689fe740dead93f3ba349a88efa52f2544aa138b",
"git-dir": "https/github.com/OpenGen/GenSQL.inference",
"hash": "sha256-gjVmfbcAEeb0uHJTOUrFasDhZY+c4wI8M5W+itJynz4="
"hash": "sha256-dQZHbTzf7Ee0rKNrn61tlBSPT7MXVVsPHO05DFN6Zvw="
},
{
"lib": "io.github.clojure/tools.build",
Expand Down
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
metosin/muuntaja {:mvn/version "0.6.8"}
net.cgrand/macrovich {:mvn/version "0.2.1"}
net.cgrand/xforms {:mvn/version "0.19.2"}
io.github.OpenGen/GenSQL.inference {:git/sha "c3cef474ba964a37fc2e5ff667055f5b77e12c45"}
io.github.OpenGen/GenSQL.inference {:git/sha "689fe740dead93f3ba349a88efa52f2544aa138b"}
org.babashka/sci {:mvn/version "0.3.32"}
org.clojure/clojure {:mvn/version "1.11.1"}
com.google.javascript/closure-compiler-unshaded {:mvn/version "v20230802"}
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
depsCache = pkgsWithCljNixOverlay.callPackage ./nix/depsCache {};
uber = pkgs.callPackage ./nix/uber {inherit depsCache;};

pname = "iql";
pname = "gensql";
bin = pkgs.callPackage ./nix/bin { inherit uber pname; };

basicToolsFn = pkgs: with pkgs; [
Expand Down
2 changes: 1 addition & 1 deletion src/gensql/query/base.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
str-rel (map stringify-keys rel)
str-attrs (map str (relation/attributes rel))]
(with-meta str-rel
{:iql/columns str-attrs}))))
{:gensql/columns str-attrs}))))
12 changes: 6 additions & 6 deletions src/gensql/query/db.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

(defn get-table
[db k]
(get-in db [:iql/tables k]))
(get-in db [:gensql/tables k]))

(defn safe-get-table
[db k]
Expand All @@ -36,7 +36,7 @@

(defn get-model
[db k]
(get-in db [:iql/models k]))
(get-in db [:gensql/models k]))

(defn safe-get-model
[db k]
Expand All @@ -49,17 +49,17 @@
"Adds a table with key `k` to the database. Turns k into a string."
[db k table]
(let [table-name (name k)] ; TODO: keep using `name`?
(assoc-in db [:iql/tables table-name] table)))
(assoc-in db [:gensql/tables table-name] table)))

(defn with-model
"Adds a model with key `k` to the database. Turns k into a string."
[db k model]
(let [model-name (name k)] ; TODO: keep using `name`?
(assoc-in db [:iql/models model-name] model)))
(assoc-in db [:gensql/models model-name] model)))

(defn env
"A map used for SCI lookup of models/relations."
;; FIXME: Check for, or handle, name collisions between models and tables.
[db]
(merge (:iql/tables db)
(:iql/models db)))
(merge (:gensql/tables db)
(:gensql/models db)))
2 changes: 1 addition & 1 deletion src/gensql/query/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
(if (instance? Exception result)
(print-exception result)
(let [columns (get (meta result)
:iql/columns
:gensql/columns
(into #{} (mapcat keys) result))
header-row (map name columns)
cells (map (apply juxt columns) result)
Expand Down
26 changes: 13 additions & 13 deletions src/gensql/query/scalar.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
[node]
(match/match node
[:conditioned-by-expr model _conditioned _by [:star _]]
`(~'iql/condition-all ~(plan model))
`(~'gensql/condition-all ~(plan model))
[:conditioned-by-expr model _conditioned _by [:star _] [:conditioned-by-except-clause & except-children]]
`(~'iql/condition-all-except ~(plan model) ~(plan (into [:conditioned-by-except-clause] except-children)))
`(~'gensql/condition-all-except ~(plan model) ~(plan (into [:conditioned-by-except-clause] except-children)))
[:conditioned-by-expr model _conditioned _by child]
`(~'iql/condition ~(plan model) ~(plan child))
`(~'gensql/condition ~(plan model) ~(plan child))
[:conditioned-by-except-clause _except model-var-list]
(plan model-var-list)))

Expand Down Expand Up @@ -86,24 +86,24 @@

[:density-event-group "(" child ")"] (plan child)

[:probability-expr _prob _of event _under model] `(~'iql/prob ~(plan model) ~(plan event))
[:density-expr _prob _density _of event _under model] `(~'iql/pdf ~(plan model) ~(plan event))
[:probability-expr _prob _of event _under model] `(~'gensql/prob ~(plan model) ~(plan event))
[:density-expr _prob _density _of event _under model] `(~'gensql/pdf ~(plan model) ~(plan event))

[:mutual-info-expr _m _i _of lhs _with rhs _under model] `(~'iql/mutual-info ~(plan model) ~(vec (plan lhs)) ~(vec (plan rhs)))
[:approx-mutual-info-expr _a _m _i _of lhs _with rhs _under model] `(~'iql/approx-mutual-info ~(plan model) ~(vec (plan lhs)) ~(vec (plan rhs)))
[:mutual-info-expr _m _i _of lhs _with rhs _under model] `(~'gensql/mutual-info ~(plan model) ~(vec (plan lhs)) ~(vec (plan rhs)))
[:approx-mutual-info-expr _a _m _i _of lhs _with rhs _under model] `(~'gensql/approx-mutual-info ~(plan model) ~(vec (plan lhs)) ~(vec (plan rhs)))

[:model-expr child] (plan child)
[:model-expr "(" child ")"] (plan child)

#?@(:clj [[:generative-table-expr _generative _table relation]
(let [query-plan (requiring-resolve 'gensql.query.plan/plan)]
`(~'iql/eval-relation-plan (~'quote ~(query-plan relation))))])
`(~'gensql/eval-relation-plan (~'quote ~(query-plan relation))))])

Check warning on line 100 in src/gensql/query/scalar.cljc

View check run for this annotation

Codecov / codecov/patch

src/gensql/query/scalar.cljc#L99-L100

Added lines #L99 - L100 were not covered by tests

;; Matches either :conditioned-by-expr or :conditioned-by-except-clause
;; and defers to conditioned-by-plan* to avoid https://clojure.atlassian.net/browse/CLJ-1852
[(:or :conditioned-by-expr :conditioned-by-except-clause) & _] (conditioned-by-plan* ws-free-node)

[:constrained-by-expr model _constrained _by event] `(~'iql/constrain ~(plan model) ~(plan event))
[:constrained-by-expr model _constrained _by event] `(~'gensql/constrain ~(plan model) ~(plan event))


[:value child] (literal/read child)
Expand All @@ -112,8 +112,8 @@
[:variable-list & variables] (into [] (comp (filter tree/branch?) (map plan)) variables) ; remove commas

[:identifier child] (plan child)
[:delimited-symbol s] (list 'iql/safe-get 'iql-bindings s)
[:simple-symbol s] (list 'iql/safe-get 'iql-bindings s))))
[:delimited-symbol s] (list 'gensql/safe-get 'gensql-bindings s)
[:simple-symbol s] (list 'gensql/safe-get 'gensql-bindings s))))

(defn inference-event
[event]
Expand Down Expand Up @@ -300,7 +300,7 @@
'* (nil-safe (auto-unbox *))
'/ (nil-safe (auto-unbox /))
'log (nil-safe (auto-unbox math/log))}
'iql {'safe-get safe-get
'gensql {'safe-get safe-get
'prob prob
'pdf pdf
#?@(:clj ['eval-relation-plan
Expand Down Expand Up @@ -348,7 +348,7 @@
opts {:namespaces #?(:clj (namespaces env' sci-bindings)
:cljs (namespaces))
:bindings (merge sci-bindings
{'iql-bindings sci-bindings})}]
{'gensql-bindings sci-bindings})}]
;; ensure pr-str doesn't truncate by setting print-length to nil
(binding [*print-length* nil]
(try (let [sci-result (sci/eval-string (pr-str sexpr) opts)]
Expand Down
8 changes: 4 additions & 4 deletions src/gensql/query/statement.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@
[db id]
(if-not (db/get-table db id)
db
(update db :iql/tables dissoc id)))
(update db :gensql/tables dissoc id)))

(defn safe-drop-table
[db id]
(when (db/safe-get-table db id)
(update db :iql/tables dissoc id)))
(update db :gensql/tables dissoc id)))

(defn drop-model
[db id]
(if-not (db/get-model db id)
db
(update db :iql/models dissoc id)))
(update db :gensql/models dissoc id)))

(defn safe-drop-model
[db id]
(when (db/safe-get-model db id)
(update db :iql/models dissoc id)))
(update db :gensql/models dissoc id)))

(defn execute
[node db]
Expand Down
Loading

0 comments on commit ba78553

Please sign in to comment.