scicloj / notespace

using your namespace as a notebook
Eclipse Public License 2.0
148 stars 10 forks source link

add progress logging #18

Closed behrica closed 3 years ago

behrica commented 3 years ago

As I work on "Long running" notespaces, I would find it very helpfull to have some progress report, which "Note" gets evaluated This could be as simple as adding a "print" or "log" statement here:

https://github.com/scicloj/notespace/blob/a915b2effe1be88993c1e96d1fd61d511bf4ff2c/src/notespace/note.clj#L136

behrica commented 3 years ago

This can be nicely implemented by having a new configuration option:

:progress-render-fn (fn [cur-node-idx node-count expected-duration])

So a fn, which takes the value:

Having this I can plugin my own render-fn, which could, for example, print this to console:

evaluate note:  42 / 49 , expected duration (s):  0.003
evaluate note:  43 / 49 , expected duration (s):  0.0
evaluate note:  44 / 49 , expected duration (s):  0.004
evaluate note:  45 / 49 , expected duration (s):  7.052
evaluate note:  46 / 49 , expected duration (s):  0.124
evaluate note:  47 / 49 , expected duration (s):  0.308
evaluate note:  48 / 49 , expected duration (s):  5.051
evaluate note:  49 / 49 , expected duration (s):  0.266

For me, this improves usability a lot, because I can "see" that something happens, while a notspespace evaluates

It requires only one small change here: https://github.com/scicloj/notespace/blob/a915b2effe1be88993c1e96d1fd61d511bf4ff2c/src/notespace/note.clj#L136

I can do a PR, if you want

behrica commented 3 years ago

I use now 2 call back functions.

I use both, to get feedback printed on console,