This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-07
Channels
- # adventofcode (3)
- # announcements (6)
- # babashka (20)
- # beginners (53)
- # calva (11)
- # clj-kondo (11)
- # clojure (50)
- # clojure-argentina (4)
- # clojure-dev (1)
- # clojure-europe (14)
- # clojure-houston (1)
- # clojure-italy (2)
- # clojure-nl (4)
- # clojure-norway (3)
- # clojure-seattle (3)
- # clojure-uk (13)
- # clojurescript (2)
- # cloverage (1)
- # code-reviews (4)
- # conjure (2)
- # cursive (5)
- # datalevin (4)
- # datascript (33)
- # datomic (16)
- # events (1)
- # graphql (10)
- # gratitude (1)
- # honeysql (6)
- # introduce-yourself (2)
- # jobs (1)
- # lsp (88)
- # malli (8)
- # off-topic (3)
- # other-languages (4)
- # polylith (3)
- # re-frame (16)
- # reagent (17)
- # reitit (3)
- # releases (2)
- # remote-jobs (1)
- # rewrite-clj (3)
- # shadow-cljs (3)
- # slack-help (2)
- # sql (36)
- # testing (31)
- # tools-deps (41)
- # xtdb (23)
Would anyone here have any pointers as to the best way to interop with R. I have a cljs implementation of an R coxph model and I need to write a coverage test that checks the cljs against the R code?
Hey, I have no idea what would actually work best in your situation, but I did just discover this possibility of calling graaljs
(e.g. using compiled cljs) from this Truffle-based R-Graal implementation: https://github.com/oracle/fastr/blob/1ce6f36bec5c5f8520ab0f0f330f9dee23ed7c55/documentation/user/Interoperability.md
Out of interest, are you using DataScript in the cljs as the underlying engine for the regression model? Or is it just one part of the picture?
You could also consider, as a first pass, avoiding interop entirely. Might not be worth it. Could either shell out to R from CLJS or have separate R and CLJS programs that write the results of the test expressions to disk and then have a third program examine and compare the results.
hello! I’m trying to load in a serialized db using the JS API and can’t get it to work. I have the database in EDN format. I’ve tried several things, but this is the latest:
let ds = require('datascript');
let edn = require('jsedn');
let d = require('fs').readFileSync('./persona.edn', 'utf8');
let data = edn.parse(d);
let conn = ds.conn_from_datoms(
edn.toJS(edn.atPath(data, ':datoms')),
edn.toJS(edn.atPath(data, ':schema'))
);
let query = '[:find ?id :where [?b :block/uid ?id]]';
let result = ds.q(query, conn);
console.log(result);
conn
is created fine but when running the query I get [object Object] is not ISeqable
. Looking at the code, it doesn’t seem to run js->clj
on the value of the datom, is that the problem? I can’t find any examples for doing this through JSit runs but the query errors with Cannot compare :block/parents to :block/refs
. I know this might be specific to my db, but that query works from the place I exported the db from. I’m not referencing :block/parents
at all — any ideas where I should look?
let ds = require('datascript');
let edn = require('jsedn');
let d = require('fs').readFileSync('./persona.edn', 'utf8');
let data = edn.parse(d);
// let schema = edn.toJS(edn.atPath(data, ':schema'));
let schema = {"person/id": {":db/unique": ":db.unique/identity"}};
//let datoms = edn.toJS(edn.atPath(data, ':datoms'));
let datoms = [[1, "person/id", 1],
[1, "person/name", "Will"]];
let conn = ds.conn_from_datoms(
datoms, schema
);
let query = '[:find ?v :where [?p "person/id" ?v]]';
let result = ds.q(query, ds.db(conn));
console.log(result);
hmm i see. datascript does not convert strings to keywords other than ds-specific strings like :db/id
and schema definition keywords
so you'll need to wrap your keyword attrs you're loading from disk in quotes in your query
not the nicest but unless you're going to read the EDN in as actual CLJS data yourself that might be as good as you get
also not sure what will happen if you try and round trip the db, i.e. make changes to the db and then write it back out to disk
is there any other way to provide a query? I’m confused about this writeup: https://github.com/kristianmandrup/datascript-tutorial/blob/master/javascript_api.md#jsedn-converter
so that turns it into JS data. then datascript reads that JS data, and treats the attributes it finds as strings
so in your case that would work well because you're parsing the datums into JS objs and then you could parse the query string as well
yeah, thanks! I’ve tried it though and something is weird. why do that pass query
as an array? d.q([query], …)
I’ve tried let result = ds.q(edn.parse(query), ds.db(conn));
which gives No protocol method ICounted.-count defined
yeah that is weird. if you note in that example they do not wrap the query string in a vector, it's just kws and variables