This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-18
Channels
- # announcements (10)
- # babashka (21)
- # beginners (99)
- # biff (66)
- # catalyst (3)
- # cherry (1)
- # cider (11)
- # clojure (38)
- # clojure-austin (3)
- # clojure-dev (23)
- # clojure-europe (21)
- # clojure-hungary (10)
- # clojure-nl (2)
- # clojure-norway (57)
- # clojure-uk (2)
- # clojurescript (9)
- # cursive (6)
- # fulcro (5)
- # hyperfiddle (14)
- # integrant (4)
- # introduce-yourself (3)
- # lsp (24)
- # off-topic (14)
- # reagent (12)
- # reitit (13)
- # releases (8)
- # sci (16)
- # shadow-cljs (8)
- # solo-full-stack (1)
- # spacemacs (5)
- # squint (3)
- # xtdb (14)
Hi 👋 Is it possible to initialize SCI as though it was Babashka?
(sci/init {???})
So that we can evaluate forms from a Babashka compatible version of SCI running inside the JVM:
(sci/eval-form ctx form)
Or even better, is there a way we can Depend on Babashka and evaluate from it? something like:
(bab/eval ...)
I want to evaluate Babashka notebooks using JVM notebook tools (Clay), switching the evaluator.
The SCI part works great, but I'm not sure how to initialize it to behave like Babashka with aliases etc.Is it important that your code runs through SCI or would you just like to have the babashka dependencies available?
Thank you for the pointers!
It's not necessary to run in SCI, my main goal is that the notebook is runnable with bb
as well as evaluated correctly to produce results for the notebook. Ideally I'd like it to give the same results in both (error for stuff that shouldn't work, and values when it should work). I took a look into main.clj
and the challenge seems to be that the construction of the options is inside the exec
... so I'm not sure how to feed it one form at a time. Maybe I should actually set up a process with exec
and feed it lines from the file over a REPL, or something like that instead :thinking_face: That seems like it would be closest to a real BB env. /shrug
Ah O.K. I'll experiment with that for a bit 🙂
perhaps spinning up a prepl would be convenient for your use case, this is also how bb support for http://nextjournal.com was done
Nice! Thank you I didn't know about prepl, that sounds perfect. I'll try that. One thing that's confusing me still; Inside a Clojure REPL when I try
(require '[babashka.main :as bb])
I get an error:
Execution error (FileNotFoundException) at babashka.impl.features/eval11693 (features.clj:33).
Could not locate babashka/impl/xml__init.class, babashka/impl/xml.clj or babashka/impl/xml.cljc on classpath.
I have
babashka/babashka {:mvn/version "1.3.184"}
in my deps, and I can navigate to babashka.impl.features, and even
(require '[babashka.impl.features])
works fine, but still I can't load babashka.main to run (-main).
Is intended to load IN Babashka not Clojure?Maybe instead I should launch an nrepl-server and connect with an nrepl-client instead of trying to have it all run in the same process. :thinking_face:
Hi Michiel, I've been experimenting and ran into a problem with metadata:
bb -e '(clojure.core.server/io-prepl)'
(set! *print-meta* true)
{:tag :ret, :val "true", :ns "user", :ms 2, :form "(set! *print-meta* true)"}
^:foo {}
{:tag :ret, :val "{}", :ns "user", :ms 1, :form "^:foo {}"}
Notice :val "{}"
clojure -e '(clojure.core.server/io-prepl)'
(set! *print-meta* true)
{:tag :ret, :val "true", :ns "user", :ms 3, :form "(set! *print-meta* true)"}
^:foo {}
{:tag :ret, :val "^{:foo true} {}", :ns "user", :ms 1, :form "^:foo {}"}
Notice :val "^{:foo true} {}"
The metadata is essential to the behavior of the notebook, but in babashka it was lost.Actually I tried this and it seems to work better: 1. Launch a bb nrepl-server 2. Connect and request the bb session load a custom evaluator that will read the notebook and preserve the metadata as desired 3. The results of custom evaluation are received over the nrepl socket back to the Clojure world 4. profit I wasn't expecting the custom evaluator to just work in babashka, so that's great that it does 🙂