pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
wilkerlucio 2021-03-16T06:49:07.000100Z

@markaddleman fixed for viz elements just pushed up

2021-03-16T08:44:23.003900Z

lately we have been thinking about a way to create something like auto discovery or some kind of documentation for params. Now, It’s hard for clients to know what parameters can be used. initially we are just including the parameters as part of defresolver.

(pco/defresolver a-resolover
   {::pco/output [...]
    ::pco/params [...]})
with the hope that later we could generate somekind of docs from it. does this make sense? would it be worthy to include params as metadata in the index?

souenzzo 2021-03-16T12:35:32.006600Z

::pco/params as any other :custom-key that you put in that map will be included on indexes Tools like pathom-viz can already show it.

2021-03-16T12:43:18.007Z

awesome 🙂 didn’t know that 🙂

2021-03-16T12:43:26.007200Z

thanks!

2021-03-16T12:45:59.009400Z

one more thing 🙂 what’s the best way on pathom,3 to short circuit the execution of a particular attribute? Currently facing some performance issues when there is an optional attribute in the output.

2021-03-17T16:03:26.000300Z

@wilkerlucio yes, we know what’s causing the slow down. Imagine the following:

;; spec
(s/def ::a (s/keys :req [:a/code :a/id])
                   :opt [:a/ref] ) ;; ref is optional

;; data
[{:a/id 1 :a/code "x"} {:a/id 2 :a/code "y" :a/ref "y2}]

(pco/defresolver all
   {::pco/output [:all [:a/code a/ref :a/id]]}
 ...some io )

(pco/defresolver by-id
   {::pco/input  [:a/id]
    ::pco/output [:a/code a/ref]
    ::pco/batch? true }
 ...some io )

(pco/defresolver by-code
   {::pco/input  [:a/code]
    ::pco/output [:a/code a/ref]
}
 ...some io )

with the eql
[{:all [:a/code :a/ref]}]
Pathom now executes all the resolvers trying to find an :a/ref for [:a/id 1] if :all is large enough we get slowdowns. so we thought that the solution is to tell pathom to stop trying to search for the attribute after the first resolver is executed as we already know that the attr will not be found.

2021-03-17T16:13:07.000800Z

so far to avoid the problem what we did is to create a new batch resolver to solve any optional parameter. so we remove :a/ref from the existing resolvers and created a new batch resolver

(pco/defresolver ref-resolver
   {::pco/input  [:a/id]
    ::pco/output [:a/ref]
    ::pco/batch? true }
 ...some io )
not sure however if this ideal

wilkerlucio 2021-03-17T16:17:19.001100Z

I'm still not getting what is the issue here, and what you expect to be different, can you send images from pathom viz where you can highlight what is slow?

wilkerlucio 2021-03-17T16:18:11.001300Z

(and in general, if batch is getting faster results, use it)

2021-03-17T16:22:32.001500Z

i will prepare something from viz but going back to the above: when running:

[{:all [:a/code :a/ref]}]
The all resolver would return [{:a/id 1 :a/code "x"} {:a/id 2 :a/code "y" :a/ref "y2}] already at this moment the programmer could know that [:a/id 1] doesn’t have a ref. however pathom will try to find it so it would go and run by-id with inpunt [:a/id 1] and will not find the ref, so it will go an execute next resolver by-code with input [:a/code "x"] because this is not a batch resolver it could execute many times. (one time for each entry that doesn’t have a ref)

2021-03-17T16:24:16.001700Z

on pathom 2 the first resolver could return

(with-meta [{:a/id 1 :a/code "x"} {:a/id 2 :a/code "y" :a/ref "y2}] {::p/final true})
so the other resolvers wouldn’t be executed

wilkerlucio 2021-03-17T16:27:42.002100Z

gotcha, is about the nested thing

wilkerlucio 2021-03-17T16:27:56.002300Z

I was confused because you mentioned OR, so I though was something inside the internal processing of a specific graph

wilkerlucio 2021-03-17T16:28:38.002600Z

ok, I think its time to get ::final in Pathom 3, I can do that later today

2021-03-17T16:30:53.002800Z

🙂 sorry for the confusion.

wilkerlucio 2021-03-17T16:33:39.003Z

no worries 🙂

wilkerlucio 2021-03-17T16:42:19.003200Z

@jmayaalv ^::pco/final [...] now works on Pathom 3 master (also for maps, etc...)

🧙 1
wilkerlucio 2021-03-17T16:43:21.003700Z

tests with examples at https://github.com/wilkerlucio/pathom3/commit/58b5585bc99a83661a37f6225a61290b647cb810

2021-03-17T16:43:26.003900Z

oh wow you are fast man!

😎 1
wilkerlucio 2021-03-17T16:52:39.004500Z

@jmayaalv thank you for the sponsoring! 😄

👍 1
souenzzo 2021-03-16T13:11:28.011200Z

pathom2 had a ^:final metadata that says to parser "do not enter this structure. Not sure about pathom3

wilkerlucio 2021-03-16T21:41:52.014800Z

can you pinpoint what is getting slow? planning? running? have you checked with Pathom Viz?