This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-23
Channels
- # aleph (1)
- # architecture (4)
- # aws (7)
- # beginners (249)
- # boot (17)
- # calva (4)
- # cider (30)
- # cljdoc (7)
- # cljs-dev (1)
- # cljs-experience (3)
- # clojure (69)
- # clojure-dev (7)
- # clojure-europe (1)
- # clojure-italy (7)
- # clojure-japan (15)
- # clojure-spec (6)
- # clojure-uk (39)
- # clojurescript (51)
- # cursive (31)
- # data-science (4)
- # datavis (1)
- # datomic (40)
- # dirac (67)
- # duct (8)
- # editors (15)
- # emacs (9)
- # events (3)
- # figwheel-main (2)
- # fulcro (157)
- # juxt (4)
- # kaocha (11)
- # lein-figwheel (1)
- # off-topic (31)
- # pathom (18)
- # re-frame (4)
- # reagent (2)
- # reitit (16)
- # remote-jobs (1)
- # shadow-cljs (11)
- # specter (2)
- # speculative (1)
- # tools-deps (27)
- # vim (1)
- # yada (2)
is there a nice way to pass sample size into a datalog query as a parameter?
(d/q '[:find (sample ?sample-size ?eid) . :in $ ?sample-size :where [?eid :organisation/id]]
db
3)
Execution error (ClassCastException) at datomic.aggregation/sample (aggregation.clj:63).
class clojure.lang.Symbol cannot be cast to class java.lang.Number (clojure.lang.Symbol is in unnamed module of loader 'app'; java.lang.Number is in module java.base of loader 'bootstrap')
has problems with variable bindingI can do something like
((fn [sample-size]
(d/q {:find [(list 'sample sample-size '?eid) '.]
:in '[$]
:where '[[?eid :organisation/id]]}
db))
3)
=> [17592186045475 17592186045480 17592186045485]
but seems like a pretty ugly solutionI guess
((fn [sample-size]
(take sample-size
(shuffle
(d/q '[:find [?eid ...] :in $ :where [?eid :organisation/id]] db))))
3)
=> (17592186045484 17592186045483 17592186045485)
is my best bet ..?abstracted as
(defn sampled-query
"return no more than n items from datomic query, shuffled randomly"
[n & qargs]
(take n
(shuffle (apply d/q qargs))))
Afaik each item in find can only use one bound var and each bound var can only be used once in find
So for eg you can’t put a pull expression in a binding then do (pull ?eid ?pull-expr) (violates first rule)
@ben.hammond try
(d/q '[:find (sample sample-size ?eid) .
:in $ sample-size
:where [?eid :organisation/id]]
db 3)
(d/q '[:find (sample sample-size ?eid) .
:in $ sample-size
:where [?eid :organisation/id]]
db 3)
Execution error (ClassCastException) at datomic.aggregation/sample (aggregation.clj:63).
class clojure.lang.Symbol cannot be cast to class java.lang.Number (clojure.lang.Symbol is in unnamed module of loader 'app'; java.lang.Number is in module java.base of loader 'bootstrap')
sample
wants a number
we've only given it a symbol
hmm, i have a confounding situation where pull isn’t behaving as i expect. shouldn’t i see the same two :demux/id
values in both situations below?
(q '{:find [?did]
:where [[?f :flowcell/id "HW27TBBXX"]
[?d :demux/flowcells ?f]
[?d :demux/id ?did]]})
=> #{["demux-id-two"] ["demux-id"]}
(pull [{:demux/_flowcells [:demux/id]}]
[:flowcell/id "HW27TBBXX"])
=> #:demux{:_flowcells #:demux{:id "demux-id-two"}}
(`q` and pull
are just partial applications of the fns from datomic.api
)if this is a data shape you expect (multiple "demux"es sharing the same "flowcell" then :demux/flowcells should not be isComponent=true
@U09R86PA4 that was it! thanks. looks like i can’t alter the schema to make flowcell no longer a component, but i need to rethink this data model now anyway.
here for on-prem: https://docs.datomic.com/on-prem/schema.html#altering-component-attribute
i get:
{:errors ({:db/error :db.error/incompatible-schema-install,
:entity :demux/flowcells,
:attribute :db/isComponent,
:was true,
:requested false}),
:db/error :db.error/invalid-install-attribute}
i think i’m actually going to keep it as a component, though, and create new flowcell entities each time
seems like this is the first place where i can’t just :db.install/_attribute
over what i have but need to detect update vs create and do :db.alter/_attribute
instead
The logic is managed by CloudFormation. Certain parameters can't be updated in place, but mandates construction of a new resource. It has to do with AWS rather than Ions itself.
do I need to do a restart after updating the IAM policy attached to my compute node(s)?
I had invalid EDN in my Ion parameters and I got an exception that looks like this:
"Msg": "LoadIonsFailed",
"Ex": {
"Cause": "EOF while reading",
"Via": [
{
"Type": "clojure.lang.Compiler$CompilerException",
"Message": "java.lang.RuntimeException: EOF while reading, compiling:(config.clj:10:14)",
"At": [
"clojure.lang.Compiler$InvokeExpr",
"eval",
"Compiler.java",
3700
]
},
It would've been great if I got an error saying that ion/get-env
failed due to an EOF error.is it possible to make use of a src-var in an aggregator, or is that just for datomic to know which source to use for passing in the coll to the aggregator? I’m trying to write a “best” aggregator that takes in a collection of entity ids, pulls in some further attributes from those entities, calculates a composite score, and returns the best composite. Can I access the database specified by the src-var passed into the aggregator, or is what I’m trying to do only possible in-memory on the client side?