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.
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:
Inspecting the data at line 32 looks like this:
which yeah you’re right — I think it looks a bit garbled.
ok looks like the issue might be with asami’s graph-transact?! Inspecting this :
(-> index/empty-graph
(graph/graph-transact 0 [user-data] nil)
)
yields:
{: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]}}}}
ok I think I just spotted the issue…
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)
With that correction, asami does indeed return the correct / expected results!! :partywombat:
OK… but I should probably have some better data checking in there. Silently failing while building invalid data structures isn’t particularly user friendly!
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
There are diminishing returns with checking for everything, and the cost can be high
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 🙂
agreed — but it can work well to do it in development/repl contexts
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.I was making shortcuts last night by NOT using schema in my code. You’re going to guilt me into putting it back in 🙂
Note for anyone looking… @rickmoynihan solved his problem in the thread above
2👍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! 🙇
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👍catching bugs is just a side effect
Anyway now I’m over this hurdle I shall look forward to playing with naga in my vanishingly little spare time
I have 3 children, so I can relate to this 🙂
I have 2 under 2 😂
1❤️