Fork me on GitHub

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
  (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
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

👍 3

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

alandipert15:06:07 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 for people who are new to it. If anyone gets a chance, I would love some feedback please! 🙂

❤️ 4