Fork me on GitHub

@corasaurus-hex Yes, working on it. There is a prototype here in user space that you can use today:


Maybe use vega lite or shell out to some tool

Cora (she/her)12:08:45

i think this reply is in the wrong thread


Can you fix this for me? I'm in the mountains

⛰️ 1
Cora (she/her)12:08:26

enjoy those views, dang


Sweet views indeed. Enjoy! Thank you @borkdude and @corasaurus-hex.


I'd like to use Babashka in a GitHub Action to create some data visualisations and publish them to GH Pages. Any pointers on getting this done? Is there some library that works with Babashka to handle server-side chart generation?

Cora (she/her)12:08:58

it was posted in the wrong thread but that's the gist of it.

Cora (she/her)19:08:16

nbb is super powerful and worth a shot

Yehonathan Sharvit12:08:55

What’s the fastest (in terms of load time)) nrepl client out there? I run babashka with an nrepl server. It loads super fast. Now, I want to connect to it from the command line. lein repl :connect is a bit slow for me.

Yehonathan Sharvit13:08:34

I need a REPL client with a shell loop. grench is only for one shot evaluation. I tried parle from but it didn’t work. The others are written in clojure, and suffer from a long load time

Cora (she/her)13:08:48

trenchman might fit your requirements, give it a shot

Yehonathan Sharvit13:08:53

@borkdude what would it take to compile repl-y to a native image?


I will reply in two hours

Yehonathan Sharvit13:08:58

OK. Timer set:smile:


I have a native build of repl-y in a private repo. I didn't publish it because I hacked it together quickly


if you want, I can add you to the repo


but you could also just use rebel readline perhaps? It uses a JVM but if you have a longer running process, maybe that's not too bad?


There is also a small library here for doing one-off stuff again an nREPL server:

Yehonathan Sharvit15:08:44

The best for me is the native build of repl-y. Can you add me to the repo?


what's your github handle again?


got it: viebel

Nicolas Estrada13:08:09

Hi 🙂 I just created an issue, if you need any more details please let me know 😉 Thanks!


@U0230KNPHDM Can you try with the master version?

Nicolas Estrada17:08:14

Sûre no problème 👌

Nicolas Estrada18:08:08

Works! Thanks 🙂

Nicolas Estrada18:08:25

Well it compiles at least, I should probably execute some sql


yeah, better test. There's also pod-babashka-postgresql, you're probably aware of this right?

Nicolas Estrada18:08:12

Yeah but the pod is missing some critial apis like jdbc/plan for streaming result sets

Nicolas Estrada18:08:26

I knew how to build a pod I would make an MR


alright, I'm fine with maintaining the feature flag of course

Nicolas Estrada18:08:45

Ok works thanks 🙂

Nicolas Estrada18:08:26

(for some reason though I can't use (with-open [conn (jdbc/get-connection ds ...)

Nicolas Estrada18:08:53

But this was a limitation before, just different behaviors between bb and clj


@U0230KNPHDM What's the issue with that?

Nicolas Estrada18:08:47

: Method close on class org.postgresql.jdbc.PgConnection not allowed! user 
clojure.lang.ExceptionInfo: Method close on class org.postgresql.jdbc.PgConnection not allowed! {:type :sci/error, :line nil, :column nil, :file nil}
	at sci.impl.utils$throw_error_with_location.invokeStatic(utils.cljc:37)
	at sci.impl.utils$throw_error_with_location.invoke(utils.cljc:34)
	at sci.impl.utils$throw_error_with_location.invokeStatic(utils.cljc:35)
	at sci.impl.evaluator$eval_instance_method_invocation.invokeStatic(evaluator.cljc:189)
	at sci.impl.analyzer$analyze_dot$reify__4993.eval(analyzer.cljc:856)
	at sci.impl.evaluator$eval_try.invokeStatic(evaluator.cljc:144)
	at sci.impl.analyzer$analyze_try$reify__4960.eval(analyzer.cljc:774)
	at sci.impl.evaluator$eval_let.invokeStatic(evaluator.cljc:71)
	at sci.impl.analyzer$analyze_let_STAR_$reify__4875.eval(analyzer.cljc:507)
	at sci.impl.analyzer$return_do$reify__4237.eval(analyzer.cljc:139)
	at sci.impl.fns$fun$arity_0__3517.invoke(fns.cljc:105)
	at sci.lang.Var.invoke(lang.cljc:174)
	at sci.impl.analyzer$return_call$reify__5204.eval(analyzer.cljc:1205)
	at sci.impl.analyzer$return_call$reify__5208.eval(analyzer.cljc:1205)
	at sci.impl.analyzer$return_call$reify__5212.eval(analyzer.cljc:1205)
	at sci.impl.analyzer$return_call$reify__5216.eval(analyzer.cljc:1205)
	at sci.impl.analyzer$return_call$reify__5208.eval(analyzer.cljc:1205)
	at sci.impl.analyzer$return_call$reify__5212.eval(analyzer.cljc:1205)
	at sci.impl.interpreter$eval_form.invokeStatic(interpreter.cljc:39)
	at sci.core$eval_form.invokeStatic(core.cljc:307)
	at babashka.nrepl.impl.server$eval_msg$fn__28061$fn__28062.invoke(server.clj:110)
	at babashka.nrepl.impl.server$eval_msg$fn__28061.invoke(server.clj:106)
	at babashka.nrepl.impl.server$eval_msg.invokeStatic(server.clj:96)
	at babashka.nrepl.impl.server$fn__28165.invokeStatic(server.clj:365)
	at babashka.nrepl.impl.server$fn__28165.invoke(server.clj:365)
	at clojure.lang.MultiFn.invoke(
	at babashka.nrepl.server.middleware$default_process_msg.invokeStatic(middleware.clj:13)
	at babashka.nrepl.server.middleware$wrap_process_message$fn__28215.invoke(middleware.clj:31)
	at clojure.core$completing$fn__8528.invoke(core.clj:6931)
	at clojure.core$map$fn__5931$fn__5932.invoke(core.clj:2759)
	at babashka.nrepl.impl.server$session_loop.invokeStatic(server.clj:418)
	at babashka.nrepl.impl.server$listen$fn__28201.invoke(server.clj:438)
	at sci.impl.vars$binding_conveyor_fn$fn__424.invoke(vars.cljc:133)
	at clojure.core$binding_conveyor_fn$fn__5823.invoke(core.clj:2047)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$

Nicolas Estrada18:08:08

This is the code

(defn fetch-intra-campuses
  (reset-cfg! {:host (env "INTRA_HOST") :port 5432 :dbname (env "INTRA_DB")})
  (with-open [conn (jdbc/get-connection (mk-datasource)
                                        {:user        (env "INTRA_USER")
                                         :password    (env "INTRA_PASSWORD")
                                         :auto-commit false
                                         :read-only   true})]
    (->> ["SELECT id, name, active, slug FROM campus order by id"]
         (jdbc/execute! conn)
         (map (fn [{:keys [campus/id campus/name campus/slug campus/active]}]
                {:id id :name (s/trim name) :slug slug :active? active})))))


OK, this can be fixed as well.


It's a bit more work, please make an issue for that

Nicolas Estrada19:08:40

Sûre thanks anyways … most of my scripts use only one connection and don't close them anyway 😅 it's only in the REPL where I clean up resources

👍 1
Nicolas Estrada19:08:17

Still very usable and not a big issue

Yehonathan Sharvit14:08:02

How do we run unit tests in babahska?

Yehonathan Sharvit15:08:39

Do Calva test-related commands know how to handle it?


I assume (but don't know for sure) that Calva-related test commands just assume clojure.test. If that is true, then it should work


Better ask in #calva

Yehonathan Sharvit11:08:13

I cannot use Here’s what I get

bb "(require 'cognitect.test-runner)"
----- Error --------------------------------------------------------------------
Type:     java.lang.Exception
Message:  Unable to resolve classname:
Location: clojure/java/classpath.clj:21:3

----- Context ------------------------------------------------------------------
17:   ^{:author "Stuart Sierra"
18:      :doc "Utilities for dealing with the JVM's classpath"}
20:   (:require [ :as io])
21:   (:import ( File)
      ^--- Unable to resolve classname:
22:            (java.util.jar JarFile JarEntry)
23:            ( URL URLClassLoader)))
25: (defprotocol URLClasspath
26:   (urls [loader]

----- Stack trace --------------------------------------------------------------       - clojure/java/classpath.clj:21:3 - clojure/tools/namespace/find.clj:13:3
cognitect.test-runner        - /Users/viebel/.gitlibs/libs/io.github.cognitect-labs/test-runner/dfb30dd6605cb6c0efc275e1df1736f6e90d4d73/src/cognitect/test_runner.clj:2:3
user                         - <expr>:1:1


^ you need to include the babashka fork of tools.namespace

Yehonathan Sharvit11:08:43

I was confused because I copy pasted blindy the deps coordinates from here


Ah, understandable

Yehonathan Sharvit13:08:37

When I run in Calva the “Run current test” command it says:

; Running test: dummy…
; The server does not recognize or cannot perform the 'undefined' operation

Yehonathan Sharvit13:08:38

I asked on #calva and they said that babashka cider-nrepl needs to provide test-var-query and retest.;cid=CBE668G4R @borkdude Do you understand what they mean?


I'll get back to you soon. I'm traveling so I have only short intervals I can look into things


If you want to look into the code check out babashka.nrepl


From my very limited nREPL understanding I think those ops need to be implemented in which i imagine could be some significant work? scanning namespaces for tests i assume?


You could also just execute tests in the REPL yourself, using just cljs.test code


eh wait, clojure.test even


@U0L91U7A8 I'm not familiar with these nREPL ops, they're not part of the nREPL spec but something custom which CIDER adds on top of it. I think to enable such custom things, we need to have a way to let users write middleware for the babashka nREPL implementation.


There is already a concept of middleware in the bb nREPL implementation: but it's currently not exposed to bb scripts, only to people who use bb.nrepl as a library in their bb-like projects


Perhaps @U7RJTCH6J who implemented most of that has a good idea how this could be exposed to bb scripts that implement some middleware


👋 trying to catch up on the thread. > but it's currently not exposed to bb scripts, only to people who use bb.nrepl as a library in their bb-like projects If I remember correctly, that's a build-time config option to expose that namespace when building babashka?


This is all there is right now:

👍 1

This namespace is also exposed within babashka. If those functions had a way to add middleware, extra ops could be implemented in user space

👍 1

o wait, the opts argument: perhaps it is already possible...?


how is the nrepl started?


You can start it from the CLI: bb nrepl-server but you can also start it programmatically


I don't think the middleware ns is exposed though


If I'm following, you would have to: 1. expose the middleware namespace 2. implement the required ops 3. start the nrepl programmatically and provide the middleware I guess at that point, it would make sense to just implement those ops directly into babashka.nrepl?


Perhaps yes


I guess I'm not an advanced enough CIDER user to make the proper judgement here, I usually just call clojure.test myself from the REPL without relying on some tool doing that for me

Yehonathan Sharvit08:08:49

One of the benefits of running the tests vi Calva is that it highlights the failures in the buffer that contains the tests that fail.


Hi, I want to convert an SVG to various size PNGs, is Babaskha in combination with ImageMagick’s convert a good choice?


Good news @borkdude, full test suite is now run with bb. Found minor things you might (or might not) be interested in. 🧵

👏 1

Notes from the

Some tests initially failed under bb:
- Tests were checking specifically for thrown
`` and ``.
Neither of these classes are currently available in bb.
I switched to checking the message only.
- Encoding tests were testing against "windows-1252" charset.
Bb does include this charset, but on Windows only.
I switched the test to use "iso-8859-1" which is available on bb on
all platforms.


Not suggesting any action should be taken, just sharing what I learned.


Exception types are usually cheap to add, PR welcome

👍 1

The latter: good to know, thanks