Fork me on GitHub
#clerk
<
2023-09-24
>
zane17:09:30

Getting this error pretty often when working with Clerk + TableCloth:

Unhandled java.lang.NullPointerException
Cannot invoke "java.util.Map$Entry.getValue()" because "<local6>" is null
Curious whether anyone else has seen it before?

mkvlr17:09:32

I haven’t but not using TableCloth heavily. Can you share your tablecloth viewer? In previous implementations I’ve seen all Clerk did was convert it to a seq of seqs so not much going on.

zane18:09:59

I’m converting it to maps using tc/rows and then passing it to either clerk/table or clerk/vl.

mkvlr18:09:38

so something along these lines?

(ns tablecloth-viewer
  (:require [tablecloth.api :as tc]
            [nextjournal.clerk :as clerk]))

(comment
  (clojure.repl.deps/add-lib 'scicloj/tablecloth {:mvn/version "4.04"}))

(def tablecloth-table-viewer
  {:pred tc/dataset?
   :transform-fn (clerk/update-val (fn [dataset]
                                     (clerk/table {:head (into [] (tc/column-names  dataset))
                                                   :rows (into [] (tc/rows dataset))})))})

(clerk/add-viewers! [tablecloth-table-viewer])

(def dataset
  (tc/dataset "" {:key-fn keyword}))

zane18:09:59

I’m not using a custom viewer at all.

mkvlr18:09:10

so having the conversion happen inline? Are you using tc/rows :as-maps ?

zane18:09:17

Yes, and yes.

mkvlr18:09:57

I’d recommend using seqs of seqs as in my example as there’s no normalization work for clerk to do and the order of the cols is kept

zane18:09:23

Well, among other things I need to pass it to Vega-Lite which expects objects.

mkvlr18:09:26

unsure if that fixes your original issue however

mkvlr18:09:39

can you share the stacktrace for your issue?

zane18:09:23

Yes, sure. Next time it happens.

👍 1
zane18:09:29

(It appears to be intermittent.)

mkvlr18:09:46

if nextjournal.clerk.viewer/normalize-table-data shows up in the stacktrace what I wrote above might be worth a try

zane18:09:01

There’s part of the stacktrace.

zane18:09:06

It’s showing up in the browser.

mkvlr18:09:18

huh, interesting, seems to be related to the editscript diff

mkvlr18:09:51

unfortunately I don’t know anything about to underlying ham-fisted.ImmutList datascructure to know what’s going on

mkvlr18:09:59

is there a channel for tech-ml-dataset?

zane18:09:36

I don’t think so.

zane18:09:40

Probably #C0BQDEJ8M is best?

👍 1
zane18:09:43

Longer stack trace:

Daniel Slutsky20:09:00

Hi. I'm not sure whether this is related, but in the past, some tech.ml.dataset/Clerk incompatibilities were caused by tech.ml.dataset's overriding of https://github.com/taoensso/nippy serializations (which were used in Clerk's cache). We recorded one such behaviour https://github.com/scicloj/visual-tools-experiments/tree/main/clerk-cache-tmd-columns-tc-1 (but I think it has been fixed later). I'm mentioning it here since this kind of situation might be difficult to debug without knowing of such relationship (and is tricky to reproduce because it may depend on the cache state).

👀 1
mkvlr06:09:46

thanks @U066L8B18. The stacktrace makes me believe it’s unrelated to Clerk’s caching however as it happens when Clerk is doing a editscript diff to figure out the diff to send to the browser to update the display.

👍 1
zane18:09:13

Here’s another weird (to me) one:

1. Caused by java.lang.IllegalArgumentException
   No implementation of method: :peek-char of protocol:
   #'clojure.tools.reader.reader-types/Reader found for class:
   rewrite_clj.reader.NewlineNormalizingReader

zane18:09:25

The file evaluates just fine in the REPL.

zane18:09:39

Might this be an issue with tagged literals, which we use?

mkvlr18:09:08

can you share a repro for this one?

zane18:09:34

That would be challenging, but I can try.

mkvlr18:09:37

do you have code of the failing cell?

mkvlr18:09:26

ah wait, so this is code with a custom reader?

mkvlr18:09:08

clerk uses edamame to read, but it should respect *data-readers*

zane18:09:19

The code doesn’t use custom readers.

zane18:09:26

But the code reads an EDN file that uses tagged literals.

mkvlr12:09:16

Can’t really say what goes wrong here. Would be great to have a repro.