This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-23
Channels
- # babashka (104)
- # beginners (23)
- # calva (15)
- # cider (2)
- # clojure (29)
- # clojure-europe (14)
- # clojure-nl (2)
- # clojure-norway (3)
- # clojure-spec (4)
- # clojure-switzerland (1)
- # cursive (3)
- # datomic (6)
- # emacs (17)
- # etaoin (2)
- # expound (1)
- # fulcro (4)
- # graphql (4)
- # honeysql (7)
- # introduce-yourself (2)
- # jackdaw (5)
- # malli (3)
- # meander (19)
- # nbb (3)
- # off-topic (35)
- # pathom (6)
- # pedestal (4)
- # polylith (31)
- # rdf (11)
- # re-frame (8)
- # reitit (6)
- # shadow-cljs (8)
- # specter (4)
- # squint (15)
- # vim (6)
@corasaurus-hex Yes, working on it. There is a prototype here in user space that you can use today: https://github.com/rads/bbin
i think this reply is in the wrong thread
haha for sure
enjoy those views, dang
oh wow!
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?
it was posted in the wrong thread but that's the gist of it.
Ah, ok. I see something I can try here https://gist.github.com/vdikan/6b6063d6e1b00a3cd79bc7b3ce3853d6/
Maybe nbb would be a better choice. Came across this example https://github.com/babashka/nbb/blob/aa17450b9b333306ef582ccd73d44d928fd229cd/examples/vega-lite/example.cljs
nbb is super powerful and worth a shot
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.
they have a list here https://nrepl.org/nrepl/usage/clients.html#command-line-clients
I need a REPL client with a shell loop.
grench is only for one shot evaluation.
I tried parle
from https://nrepl.org/nrepl/usage/clients.html#command-line-clients but it didn’t work.
The others are written in clojure, and suffer from a long load time
trenchman might fit your requirements, give it a shot
@borkdude what would it take to compile repl-y to a native image?
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
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: https://github.com/babashka/nrepl-client
The best for me is the native build of repl-y. Can you add me to the repo?
Thank you @borkdude!
Hi 🙂 I just created an issue, if you need any more details please let me know 😉 Thanks! https://github.com/babashka/babashka/issues/1343
@U0230KNPHDM Can you try with the master version?
Sûre no problème 👌
Works! Thanks 🙂
Well it compiles at least, I should probably execute some sql
One sec
yeah, better test. There's also pod-babashka-postgresql, you're probably aware of this right?
Yeah but the pod is missing some critial apis like jdbc/plan
for streaming result sets
I knew how to build a pod I would make an MR
Ok works thanks 🙂
(for some reason though I can't use (with-open [conn (jdbc/get-connection ds ...)
But this was a limitation before, just different behaviors between bb and clj
@U0230KNPHDM What's the issue with that?
: 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(MultiFn.java:239)
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 clojure.lang.AFn.call(AFn.java:18)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:829)
at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:705)
at com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:202)
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})))))
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
Done 😉
Thanks anyways
Still very usable and not a big issue
How do we run unit tests in babahska?
You can also use the https://github.com/cognitect-labs/test-runner but you have to include https://github.com/babashka/tools.namespace as well
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
I cannot use https://github.com/cognitect-labs/test-runner. Here’s what I get
bb "(require 'cognitect.test-runner)"
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: Unable to resolve classname: java.net.URLClassLoader
Location: clojure/java/classpath.clj:21:3
----- Context ------------------------------------------------------------------
17: ^{:author "Stuart Sierra"
18: :doc "Utilities for dealing with the JVM's classpath"}
19: clojure.java.classpath
20: (:require [ :as io])
21: (:import ( File)
^--- Unable to resolve classname: java.net.URLClassLoader
22: (java.util.jar JarFile JarEntry)
23: ( URL URLClassLoader)))
24:
25: (defprotocol URLClasspath
26: (urls [loader]
----- Stack trace --------------------------------------------------------------
clojure.java.classpath - clojure/java/classpath.clj:21:3
clojure.tools.namespace.find - 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
This is my demo repo: https://github.com/viebel/klafim/tree/d223fb1e54da6c87c447be257a006d3cd5611a55
My bad! Works now
I was confused because I copy pasted blindy the deps coordinates from here https://github.com/babashka/tools.namespace#releases-and-dependency-information
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
I asked on #calva and they said that babashka cider-nrepl needs to provide test-var-query
and retest
.
https://clojurians.slack.com/archives/CBE668G4R/p1661326366720939?thread_ts=1661268149.551749&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
From my very limited nREPL understanding I think those ops need to be implemented in https://github.com/babashka/babashka.nrepl/blob/master/src/babashka/nrepl/impl/server.clj#L350-L410 which i imagine could be some significant work? scanning namespaces for tests i assume?
learned a lot looking at: https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/test.clj#L306-L334 and https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/test.clj#L352-368 😅
@borkdude What would it take to add the test related ops from https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/test.clj#L386-L390 to babashka?
@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: https://github.com/babashka/babashka.nrepl/blob/master/src/babashka/nrepl/server/middleware.clj 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 namespace is also exposed within babashka. If those functions had a way to add middleware, extra ops could be implemented in user space
how is the nrepl started?
You can start it from the CLI: bb nrepl-server
but you can also start it programmatically
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?
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
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.
In Neil, we run a bb tests
alias:
https://github.com/babashka/neil/blob/main/bb.edn#L30
Hi, I want to convert an SVG to various size PNGs, is Babaskha in combination with ImageMagick’s convert
a good choice?
haha thanks
Good news @borkdude, https://github.com/clj-commons/clj-http-lite full test suite is now run with bb. Found minor things you might (or might not) be interested in. 🧵
Notes from the https://github.com/clj-commons/clj-http-lite/commit/6c128fdee7f773335c799ab4298cf072442610e4:
Some tests initially failed under bb:
- Tests were checking specifically for thrown
`java.net.ssl.SSLException` and `java.net.SocketTimeoutException`.
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.