Fork me on GitHub
#portal
<
2022-12-02
>
orestis22:12:24

I am playing around with the Calva Notebooks feature, really slick stuff! I'm finally seeing Portal in action! I immediately run into trouble, trying to get an SQL response back:

Error: Invalid symbol: next.jdbc.result-set/navize-row/fn--49358.
    at new pj (+.)
    at qj (+.)
    at rj (+.)
    at St (+.)
    at Ut (+.)
    at $t (+.)
    at Nu (+.)
    at Cu (+.)
    at Eu (+.)
    at Gu (+.)
Which is very weird, since the results are plain data - but I think that jdbc.next is actually datafying them so perhaps there's a hitch somewhere?

djblue22:12:40

Can you share the edn that is causing this issue?

seancorfield22:12:48

That's metadata on the hash map

seancorfield22:12:28

The metadata has an anonymous function as the key in the metadata. I bet it can't handle that as EDN?

djblue22:12:44

I think it might be that next.jdbc.result-set/navize-row/fn--49358 is a valid symbol in clj but not cljs :thinking_face:

seancorfield22:12:03

Ah, could be 🙂

djblue22:12:17

(clojure.edn/read-string "next.jdbc.result-set/navize-row/fn--49358") works fine in clj

djblue22:12:27

Execution error (ExceptionInfo) at (<cljs repl>:1).
Invalid symbol: next.jdbc.result-set/navize-row/fn--49358.
Is what I get in a cljs repl

seancorfield22:12:27

The same thing works in Portal-in-VS-Code so this is specific to how the notebook integration works?

👍 1
djblue22:12:42

Yeah, the default serialization is not edn. In the future, I'll probably change the serialization for notbooks, but that involves some coordination with the calva folks and setting up some nrepl middleware. The funny bit here is that (symbol "next.jdbc.result-set/navize-row/fn--49358") works fine in cljs so it's some specific about edn.

orestis23:12:29

I guess it’s worth reporting to the CLJS dev team? They usually care for parity with CLJ

💯 1
skylize22:12:39

Got portal started up inside VS Code. Then evaluated a ns declaration in a test file. Portal responded with "clojure.test/report is not a multimethod, some reporting functions have been disabled." Seems to be caused by requiring namespaces from test.check. Should I care about this? Is there a "fix" I should consider?

seancorfield22:12:26

How did you start your REPL and what type of project is it?

djblue22:12:32

It's probably caused by https://github.com/djblue/portal/blob/master/src/portal/nrepl.clj#L109 which is shadowing the var to capture test output on eval.

seancorfield22:12:18

I think Leiningen messes with the test reporter, or at least some of it's plugins do?

1
skylize23:12:04

> How did you start your REPL? I added an alias to deps.edn as listed at https://cljdoc.org/d/djblue/portal/0.35.0/doc/guides/nrepl#toolsdeps for using nrepl middleware. Then made a custom connect sequence that runs the code in https://cljdoc.org/d/djblue/portal/0.35.0/doc/guides/nrepl#customization after connecting, but with (portal.api/open {:launcher :vscode") added before calling add-tap.

skylize23:12:50

It is a cljc project (aiming to work equally on bb/clj/cljs), but running repl as clj deps.edn. Requiring clojure.test does not trigger the warning, but requiring clojure.test.check.FOO does.

seancorfield23:12:38

Interesting. We use test.check and I run the Portal middleware and haven't run into this...

skylize23:12:16

Correction: Seems limited to clojure.test.check.clojure-test

seancorfield23:12:25

I just eval'd every file at work that requires any clojure.test.check.* nses and they all load without error and the Portal middleware shows all the evals (`nil` for the ns form and then every function or test var). And we use c.t.c.c-t...

skylize23:12:55

I am using .generators,`.properties`, and .clojure-test. The other 2 are fine, but .clojure-test invokes warning from any namespace. Using "RELEASE" build of nrepl, cider, and portal with latest Calva and Code.

seancorfield23:12:13

Same setup here. Where exactly are you seeing that warning -- and does it seem to break any functionality?

skylize23:12:01

Warning is in Portal window underneath the nil returned by calling ns function.

seancorfield23:12:53

Is it actually the ns form eval causing the warning or is it some specific function from c.t.c.c-t that might be causing it? We use ct/defspec and test reports work for that (I see Portal reports each defspec run as a hash map -- which is fine for the low numbers of iterations we use but might be problematic for, say, 1000 iterations? @U1G869VNV)

skylize23:12:28

Occurs when calling`(require '[clojure.test.check.clojure-test])`. or (ns my.ns (:require [clojure.test.check.clojure-test])) in a fresh repl.

seancorfield23:12:05

Here's the c.t.c.c-t code that is performing that check:

(when #?(:clj true :cljs (not (and *ns* (re-matches #".*\$macros" (name (ns-name *ns*))))))
  ;; This check accomodates a number of tools that rebind ct/report
  ;; to be a regular function instead of a multimethod, and may do
  ;; so before this code is loaded (see TCHECK-125)
  (if-not (instance? #?(:clj clojure.lang.MultiFn :cljs MultiFn) ct/report)
    (binding [*out* #?(:clj *err* :cljs *out*)]
      (println "clojure.test/report is not a multimethod, some reporting functions have been disabled."))

seancorfield23:12:04

Interesting. I wonder why I don't see the warning but you do, given we have the same versions of everything otherwise...

seancorfield23:12:11

Just to double-check: is this in .clj or .cljs?

seancorfield23:12:02

But you're eval'ing it as Clojure? i.e., via the Clojure REPL, not the cljs REPL

skylize23:12:44

I have in cljc though, so I can also run tests in ClojureScript.

skylize23:12:08

Have a few reader conditionals.

seancorfield23:12:11

Ah! I am getting that but it only shows in Calva's REPL window which I never have open -- I don't see it in Portal!

; clojure.test/report is not a multimethod, some reporting functions have been disabled.

seancorfield23:12:24

So we are seeing the exact same behavior 🙂

seancorfield23:12:48

(and I didn't see it in Portal's log-like output because the nil from the ns eval looks "fine" but I just expanded it up and there's stderr in that log message too -- which does have the warning...

seancorfield23:12:21

@U1G869VNV It might be nice if Portal indicated there was stdio to look at when it renders a log line?

skylize23:12:06

Mystery solved. So left with whether or not there is anything to be done about it.

seancorfield23:12:42

How would I know to expand a log line to see stdio?

👍 1
💯 1
skylize23:12:59

Hmm. What view are you using? I don't seem to have one that looks like that. The warning is pretty obvious in every view option I seem to have available.

seancorfield23:12:09

@U90R0EPHA Well, c.t.c.c-t caters to the non-multimethod binding and Portal isn't the only tool to do that... This is the code that doesn't run:

(let [begin-test-var-method (get-method ct/report #?(:clj  :begin-test-var
                                                         :cljs [::ct/default :begin-test-var]))]
      (defmethod ct/report #?(:clj  :begin-test-var
                              :cljs [::ct/default :begin-test-var]) [m]
        (reset! last-trial-report (get-current-time-millis))
        (when begin-test-var-method (begin-test-var-method m)))

      (defmethod ct/report #?(:clj ::trial :cljs [::ct/default ::trial]) [m]
        (when-let [trial-report-fn (and *report-trials*
                                        (if (true? *report-trials*)
                                          trial-report-dots
                                          *report-trials*))]
          (trial-report-fn m)))

      (defmethod ct/report #?(:clj ::shrinking :cljs [::ct/default ::shrinking]) [m]
        (when *report-shrinking*
          (with-test-out*
            (fn []
              (println "Shrinking" (get-property-name m)
                "starting with parameters" (pr-str (::params m)))))))

      (defmethod ct/report #?(:clj ::complete :cljs [::ct/default ::complete]) [m]
        (when *report-completion*
          (prn (::complete m))))

      (defmethod ct/report #?(:clj ::shrunk :cljs [::ct/default ::shrunk]) [m]
        (when *report-completion*
          (with-test-out*
            (fn [] (prn m))))))))
so it's some of the additional reporting that is suppressed around timing of trials and shrinking. That probably matters if you get a failure and need more detail but not much for successful running...

seancorfield23:12:56

That view is Portal inside VS Code with the nREPL middleware enabled so each evaluation looks like a log entry.

seancorfield23:12:54

What I see in Portal when I run tests:

seancorfield23:12:52

That block of {}3 lines is the five hash map results from running defspec

seancorfield23:12:25

(and you can see the pass below it, with the summary showing number of tests)

seancorfield23:12:05

(I have customized that a little bit to separate things out a bit more)

skylize23:12:01

I don't seem to have an option for the log view. :thinking_face:

skylize23:12:04

Oh, I see, that is somehow a variation of the inspector view that looks different than mine.

skylize00:12:25

Seems like it would be nice if Portal had some custom display options around test.check. It dumps 100+ maps into the inspector for every passing test. And for a failing test it takes 1 double-click to view the failing case, and back out for another 2 double-clicks to view the shrunken case.

seancorfield00:12:38

Ah, I didn't think I'd messed with it too much -- but it is all very configurable 🙂

skylize16:12:50

I don't think I really got an answer to my questions here, which are • Should I care about this (or is this just an annoyance to be ignored)? • Is there a "fix" I should consider? (and now adding one more) • If there is no fix, should I file an issue? or is this just expected behavior?

seancorfield17:12:46

I hadn't noticed the lack of reporting so I didn't even know there was anything wrong. So I would consider it an annoyance to be ignored. I'm not sure it can be fixed fully. Even if Portal uses a multimethod to override clojure.test/report and provides all defmethod paths and delegates to the original, I don't know what would happen if middleware or other library code tried to override clojure.test/report -- as defspec does. I suspect Portal would not be able to capture those new paths and you might be worse off since Portal's report would be cut out of the loop.

✌️ 1
seancorfield17:12:28

I think it's an inherent problem with the way clojure.test is written -- or perhaps with multimethods themselves -- in that you can't replace the reporting mechanism completely...?

skylize16:12:50

I don't think I really got an answer to my questions here, which are • Should I care about this (or is this just an annoyance to be ignored)? • Is there a "fix" I should consider? (and now adding one more) • If there is no fix, should I file an issue? or is this just expected behavior?