Fork me on GitHub
#clerk
<
2023-03-09
>
mkvlr01:03:17

Adding execution progress in https://github.com/nextjournal/clerk/pull/429. Feedback welcome if folks get a chance to take it for a spin.

Carsten Behring08:03:55

I cannot render any notebook on that branch exec-state

Carsten Behring08:03:51

When doing clerk/show! I get always:

*e
;; => #error {
 :cause "Cannot invoke \"clojure.lang.IObj.withMeta(clojure.lang.IPersistentMap)\" because \"x\" is null"
 :via
 [{:type java.lang.NullPointerException
   :message "Cannot invoke \"clojure.lang.IObj.withMeta(clojure.lang.IPersistentMap)\" because \"x\" is null"
   :at [clojure.core$with_meta__5485 invokeStatic "core.clj" 220]}]
 :trace
 [[clojure.core$with_meta__5485 invokeStatic "core.clj" 220]
  [clojure.core$vary_meta invokeStatic "core.clj" 677]
  [clojure.core$vary_meta doInvoke "core.clj" 677]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.lang.Atom swap "Atom.java" 79]
  [clojure.core$swap_BANG_ invokeStatic "core.clj" 2372]
  [clojure.core$swap_BANG_ doInvoke "core.clj" 2362]
  [clojure.lang.RestFn invoke "RestFn.java" 497]
  [nextjournal.clerk.webserver$set_status_BANG_ invokeStatic "webserver.clj" 192]
  [nextjournal.clerk.webserver$set_status_BANG_ invoke "webserver.clj" 191]
  [nextjournal.clerk$show_BANG_ invokeStatic "clerk.clj" 37]
  [nextjournal.clerk$show_BANG_ invoke "clerk.clj" 22]
  [example$eval60102 invokeStatic "NO_SOURCE_FILE" 9]

teodorlu16:03:05

1. i think this is looking great! 2. I haven't come across any weird behavior / potential bugs 3. really appreciate knowing that "something is actually happening right now". When running slow computations, i've often been wondering if something is actually happening, or if i've done something wrong and made something crash. Clerk feels snappier with this somehow. (or perhaps you've made clerk faster in other ways!) 4. also really appreciate that the execution progress indicator isn't taking up tons of screen estate. I think I'd appreciate some visual signifier that "the evaluation has come this far in space" as well. I'm looking at the form -- if I can easily see that "clerk is evaluating this form right now", I don't have to break my attention and read a var name / read a form aiming my attention back to the form. (i tried {:sha "b2cb2144a89ab0e6c69a25ca5cc2d38f0c5672d9"})

mkvlr01:03:41

@U3X7174KS thanks for the feedback, great to hear it feels snappier with this! Indicating the executing cell in the doc will come in a follow-up, currently we only refresh the doc after the evaluation completed so the cell might not be there, yet. But yes, agree that that’ll be good to have, just want to make sure it doesn’t become slower when we do this.

👍 2
teodorlu14:03:03

@U5H74UNSF i did stumble over something weird now, still on {:sha "b2cb2144a89ab0e6c69a25ca5cc2d38f0c5672d9"}: I expected to see :abc, not #viewer-eval (keyword ":abc").

teodorlu14:03:26

clerk makes it really easy to reproduce things 😁

teodorlu14:03:51

this looks weird too, expecting :abc, not ::abc. Edit: my fault -- (keyword ":abc") is indeed ::keyword!

Carsten Behring19:03:12

Am I doing something wrong ? For me it does not work at all:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
(index):420 Uncaught ReferenceError: nextjournal is not defined
    at (index):420:515
(anonymous) @ (index):420

Carsten Behring19:03:55

I just run it from branch exec-state via bb dev :browse\? true and then clerk/show! the exec_status.cljnotebook

Carsten Behring20:03:30

Firefox is more clear on error message:

Loading module from "" was blocked because of a disallowed MIME type ("").

teodorlu20:03:53

> I just run it from branch exec-state via bb dev :browse\? true and then clerk/show! the exec_status.cljnotebook I'm not running Clerk from the Clerk repo -- I'm using io.github.nextjournal/clerk {:sha "b2cb2144a89ab0e6c69a25ca5cc2d38f0c5672d9"} from my https://github.com/teodorlu/lab/blob/a4336c561426947e273359bb9fdb2ba924a496ae/deps.edn#L5-L12. I find that easier.

Ash10:03:34

`:nextjournal.clerk/width` ignored on viewers rendered within Tap Inspector? I’ve some wide data that I’d like to tap> to the Tap Inspector but setting {::clerk/width :full} on the data’s viewers ( clerk/table , v/vl, etc.) seems to be ignored. Am I doing it wrong, is it a bug, or does Tap Inspector not support `:nextjournal.clerk/width`? :thinking_face:

mkvlr10:03:36

doesn’t support it, yet. Issue welcome, think we can fix this shortly.

otfrom15:03:26

I've created a horrible helper to turn http://tech.ml/tablecloth datasets into alignable markdown tables. It probably has lots of sharp edges and I bet there is a better way to handle right aligning my numbers in a column. https://gist.github.com/otfrom/3295146a43d03c119da85d51f908a546

otfrom15:03:26

I suppose the nice thing to do would be to turn that into an example in clerk.garden

genmeblog16:03:08

Is native printing not enough?

otfrom16:03:07

other than me completely forgetting about all the wonderful things you've built? No, not really 😄

bananadance 2
otfrom16:03:45

I'd like to be able to file off the table name (or make it prettier) as this is for delivery to clients

otfrom16:03:55

mostly I was after stupid tc/markdown tricks

otfrom16:03:31

@U1EP3BZ3Q should p/dataset->str be wrapped in a println by default?

(defn print-dataset
  "Prints dataset into console. For options see
  tech.v3.dataset.print/dataset-data->str
"
  ([ds] (println (p/dataset->str ds)))
  ([ds options] (println (p/dataset->str ds options))))

otfrom16:03:13

which has nicer formatting except for the dataset name and shape (which is good for me but not for clients), but I could take that off by chopping off the first bit of the string

genmeblog17:03:21

Actually it's produced by TMD. Yeah, remove two first lines by hand, there is no option to skip it.

genmeblog17:03:25

Looks great! 👏

genmeblog17:03:03

It's a bug for sure. PR?

otfrom17:03:06

hmm... doesn't seem to be like that in latest github. Now I'm confused

otfrom17:03:28

@U1EP3BZ3Q I'll dig, I think I can actually fix this one. 🙂

genmeblog09:03:29

@U0525KG62 I was too quick (heading home and it was quick answer without much thinking 😕, my bad, sorry for that ). The idea behind print-dataset is actual printing 🙂 I though it might return a dataset itself, not a string representation. To get a string you can call tc/dataset->str which does exactly what you need - a formatted string.

👍 2
genmeblog09:03:25

I think we can enhance dataset->str to have an option of stripping first to line (ie. dataset name and empty line). What do you think?

otfrom09:03:22

that all sounds good. I'm easy either way on the stripping off of the dataset name as it is easy enough to do

otfrom18:03:39

I've only just noticed that the markdown tables here are in a serif font. Is that expected? https://github.clerk.garden/otfrom/md-tc-clerk-example/commit/3659b98c0347bc172ec4b2368122e792b0958e96/

Andrea11:03:06

Hi @U0525KG62 if markdown is intended for prose, maybe. But you can provide your own style. The source of this notebook shows how to customise markdown rendering https://snapshots.nextjournal.com/clerk/build/2356ac2e3a2f1063b65e84ef8019595d7bda2557/index.html#/notebooks/viewers/custom_markdown.clj

Andrea12:03:55

clerk/table could be more suited for the job of transforming data and strings are rendered sans by default https://snapshots.nextjournal.com/clerk/build/2356ac2e3a2f1063b65e84ef8019595d7bda2557/index.html#/notebooks/viewers/table.clj

otfrom13:03:20

Where can I find out more about add-child-viewers that looks like it might solve some alignment and formatting problems for me

Andrea13:03:14

> add-child-viewers is mentioned in the book:tm: in the context of tables, but it’s the same principle https://book.clerk.vision/#transform

👍 2