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

markaddleman 2021-03-16T15:44:14.012Z

Hi - I loaded up my OIR index and my query into the tool. I'm not really sure what I'm looking at.

markaddleman 2021-03-16T15:44:45.012200Z

When I execute the failing query, I get an indication that the final node is unreachable.

markaddleman 2021-03-16T15:45:16.012400Z

However, when I change the query to return the problematic attribute, it computes the plan just fine and returns the correct result

markaddleman 2021-03-16T15:46:34.012600Z

Should the "Log Graph" button do something? When I click it, the console displays a (presumably ClojureScript) object but it does not look intelligible

wilkerlucio 2021-03-16T16:30:38.012800Z

@markaddleman can you check if you are in pathom latest? because the viz uses its own compiled version of pathom to compute the plan there, I wonder if you missing some fix

wilkerlucio 2021-03-16T16:31:03.013Z

the log graph, yeah, was a oversight, because in dev logs fine, but on the site its not usable

wilkerlucio 2021-03-16T16:31:13.013200Z

I can fix that to log a pr-str of the graph

markaddleman 2021-03-16T16:37:13.013400Z

I'm using pathom commit 6b2282e6dc4cfabd449cf7837fcefdd1c9b09891 . I'm not sure how to get the version of Pathom Viz but I'm almost certain it's the latest compiled binary from github. btw, the exception that I'm getting is from Pathom, not Viz

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

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

wilkerlucio 2021-03-16T21:42:10.015Z

ok, I think its time to get the stepper to the next level

wilkerlucio 2021-03-16T21:43:33.015200Z

currently using that view from embed has an issue, actually more than one: 1. it runs using the internal pathom, not the client pathom, and that can cause confusion 2. this version only looks at index-oir, which is not complete, it don't contemplate the nested queries (and I believe that may be the case you are hitting)

wilkerlucio 2021-03-16T21:43:59.015400Z

the next level is to integrate that properly in Pathom Viz, some sort of button to debug a query, that can leverage all index, and run in your environment

markaddleman 2021-03-16T22:29:52.015600Z

that would be great