asami

Asami, the graph database https://github.com/threatgrid/asami
quoll 2021-02-25T00:13:09.043600Z

OK, so this is a bug. Either the connection is not returning the modified graph, or the as-connection is not properly wrapping the graph.

2021-02-25T09:24:42.043900Z

Pretty sure the error is happening between lines 34 and 32. As inspecting the data returned by line 34 you can see the connection contains only the explicit triples and none of the inferred ones:

2021-02-25T09:24:57.044100Z

2021-02-25T09:27:23.044500Z

Inspecting the data at line 32 looks like this:

2021-02-25T09:27:50.044700Z

2021-02-25T09:31:16.045100Z

which yeah you’re right — I think it looks a bit garbled.

2021-02-25T09:34:11.045400Z

ok looks like the issue might be with asami’s graph-transact?! Inspecting this :

(-> index/empty-graph
    (graph/graph-transact 0 [user-data] nil)
    )

2021-02-25T09:34:18.045600Z

yields:

2021-02-25T09:34:21.045800Z

{:spo
 {[:ref/female :skos/inScheme :scheme/genders]
  {[:skos/inScheme :rdfs/range :skos/ConceptScheme] #{nil}}},
 :pos
 {[:skos/inScheme :rdfs/range :skos/ConceptScheme]
  {nil #{[:ref/female :skos/inScheme :scheme/genders]}}},
 :osp
 {nil
  {[:ref/female :skos/inScheme :scheme/genders]
   #{[:skos/inScheme :rdfs/range :skos/ConceptScheme]}}}}

2021-02-25T09:38:34.046400Z

ok I think I just spotted the issue…

2021-02-25T09:40:36.046600Z

Ok @quoll you’ll be relieved that this is a bug in my code, not in asami/naga 🙂

(def user-data [[:ref/female :skos/inScheme :scheme/genders]
                [:skos/inScheme :rdfs/range :skos/ConceptScheme]
                ])
,,,

    (graph/graph-transact 0 [user-data] nil)
that graph-transact line should be: (graph/graph-transact 0 user-data nil)

2021-02-25T09:41:37.046800Z

With that correction, asami does indeed return the correct / expected results!! :partywombat:

quoll 2021-02-25T15:51:31.047Z

OK… but I should probably have some better data checking in there. Silently failing while building invalid data structures isn’t particularly user friendly!

2021-02-25T15:58:26.047200Z

Perhaps… I did wonder if your plumatic schema stuff might have caught it, if I’d turned it on in dev with s/set-fn-validation! but I’ve just tried and it seems it still gets through

quoll 2021-02-25T15:59:08.047400Z

There are diminishing returns with checking for everything, and the cost can be high

quoll 2021-02-25T15:59:48.047600Z

My main reason for using plumatic schema has been documenting APIs. It really helps a lot! It’s also nice when it catches a bug 🙂

2021-02-25T15:59:59.047800Z

agreed — but it can work well to do it in development/repl contexts

2021-02-25T16:02:18.048Z

For example I’ve just added

(comment
  (require '[schema.core :as s])
  (s/set-fn-validation! true))
At the end of my file, so when I hack on this next I can evaluate that and hopefully reduce any other mistakes like this.

quoll 2021-02-25T16:02:58.048300Z

I was making shortcuts last night by NOT using schema in my code. You’re going to guilt me into putting it back in 🙂

quoll 2021-02-25T16:03:57.048900Z

Note for anyone looking… @rickmoynihan solved his problem in the thread above

2👍
2021-02-25T16:12:10.049100Z

Well problems like this come with the territory of using a dynamic language. If I thought type systems were more important than everything else I’d be using Haskell or Idris day to day. You’ve clearly pulled in plumatic schema because you feel it benefits cases like this though, so it probably makes sense to keep leveraging it; but please don’t let me guilt you into anything. What you have already is great! 🙇

quoll 2021-02-25T16:13:43.049400Z

99% of why I use Schema is to document what a function does. This helps me write and debug code, since I know what is supposed to go in and out. It also documents it for someone else who wants to look at it, but really, I do it for me 🙂

1👍
quoll 2021-02-25T16:14:00.049600Z

catching bugs is just a side effect

2021-02-25T16:17:27.049900Z

Anyway now I’m over this hurdle I shall look forward to playing with naga in my vanishingly little spare time

quoll 2021-02-25T16:20:11.050100Z

I have 3 children, so I can relate to this 🙂

2021-02-25T16:21:04.050300Z

I have 2 under 2 😂

1❤️