This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-03
Channels
- # announcements (1)
- # asami (13)
- # babashka (14)
- # beginners (58)
- # calva (49)
- # cljs-dev (6)
- # clojure (99)
- # clojure-europe (28)
- # clojure-gamedev (4)
- # clojure-nl (19)
- # clojure-spec (4)
- # clojure-uk (39)
- # clojured (5)
- # clojurescript (39)
- # code-reviews (3)
- # conjure (4)
- # cryogen (12)
- # cursive (21)
- # data-science (4)
- # datalog (1)
- # datomic (16)
- # duct (4)
- # events (1)
- # fulcro (6)
- # graalvm (1)
- # graphql (1)
- # jobs (13)
- # jobs-discuss (23)
- # kaocha (2)
- # lsp (15)
- # malli (24)
- # missionary (6)
- # off-topic (21)
- # polylith (75)
- # releases (2)
- # remote-jobs (4)
- # shadow-cljs (47)
- # sql (35)
- # vim (10)
- # xtdb (4)
Morning. I'm trying to write a simple task orchestrator using asami as temporary storage, since a job workflow is basically a DAG.
I was thinking to use loom.alg/topsort
both to check that a job has no cycle and to get the tasks without requirements (so I can run them first).
This is what I got so far:
(defn graph-test
[conn]
(let [t1 {:db/ident :t1 :task/name "Task 1"}
t2 {:db/ident :t2 :task/name "Task 2"}
j1 {:db/ident :j1 :job/name "Job 1"}]
@(d/transact conn [t1 t2 j1])
@(d/transact conn [{:db/ident :j1 :tasks [{:db/ident :t1}
{:db/ident :t2}]}
{:db/ident :t1 :requires {:db/ident :t2}}])
(->> conn
d/db
d/graph
a/topsort)))
But the result is unclear to me, I get both node properties, entities and ids.
Is there a better way to do this? What am I missing?
Thanks.The structure looks OK, but I honestly have no idea what topsort does! I’ll have to learn more about it before I can say, sorry
Sure, I was hoping that someone had the same problem and how solve it
Just a shot in the dark 😅
I haven’t done a lot with Loom, sorry. I still need to update it for the on-disk storage (it only works with in-memory stores)
Don't worry, it's probably something I can implement myself
@mdallastella just throwing out some general related knowledge i have in case it's useful. usually a topo sort operates on a set of pairs, parent/child or dependency/depender. in asami or a graph db this is a parent child relationship. so you'd want to get the set of parent/child pairs from asami, then feed that to the topo function. in your case probably it would be pairs of EIDs
e.g. `'[:find [?dependency ?depender] :where [?depender :depends-on ?dependency]]`
... then feed those pairs to a topo algo
Thanks @alandipert, it's something I was thinking of
...it might also be possible to define the topology order in terms of a datalog query, maybe with aforementioned extensions quoll demonstrated for navigating deep transitive relationships between entities. but i've never done that myself, in any datalog
There's a little bit of research around the web, but probably it's out of the scope of a datalog engine
Hi everyone. I’ve written an https://github.com/threatgrid/asami/wiki/Introduction for people who are new to it. If anyone gets a chance, I would love some feedback please! 🙂