humdum, realising that asking this before doing any amount of study 😄, but does integrant work with babashka? 🙂
another blatant without-study question, does babashka compile on arm architecture?
ah, that's tracked on https://github.com/babashka/babashka/issues/241
There is a list of projects that are known to work and integrant is not on it https://github.com/babashka/babashka/blob/master/doc/projects.md
you can try though. if it works, we can add it there
First obstacle:
user=> (require '[integrant.core :as ig])
java.lang.Exception: Could not find namespace: clojure.spec.alpha. [at integrant/core.cljc:3:3]
ah, sorry too fast
0% cat deps.edn
{:deps {integrant/integrant {:mvn/version "0.8.0"}}
:paths ["resources"]}
kimmoko@paju ~/work/bb-integrant
0% export BABASHKA_CLASSPATH=$(clojure -Spath)
kimmoko@paju ~/work/bb-integrant
0% echo $BABASHKA_CLASSPATH
resources:/Users/kimmoko/.m2/repository/integrant/integrant/0.8.0/integrant-0.8.0.jar:/Users/kimmoko/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:/Users/kimmoko/.m2/repository/weavejester/dependency/0.2.1/dependency-0.2.1.jar:/Users/kimmoko/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar:/Users/kimmoko/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar
kimmoko@paju ~/work/bb-integrant
0% bb
Babashka v0.2.10 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (require '[integrant.core :as ig])
clojure.lang.ExceptionInfo: Could not resolve symbol: clojure.lang.Compiler/demunge [at clojure/spec/alpha.clj:128:16]
the previous paste already had some hacksah, spec is tracked on https://github.com/babashka/babashka/issues/558
@viesti You can maybe use spartan.spec
as a standin
Instead of clojure.lang.Compiler/demunge
they should probably use demunge
from:
(require '[clojure.main :refer [demunge]])
which works with bbyeah, I can try that, to see if it covers the specs in integrant
why does integrant need spec btw? can't this be made optional?
I want to include spec proper in babashka btw, but since it's alpha, not yet
got integrant working with spartan.spec 🙂
0% cat deps.edn
{:deps {integrant/integrant {:mvn/version "0.8.0"}
borkdude/spartan.spec {:git/url "<https://github.com/borkdude/spartan.spec>"
:sha "e5c9f40ebcc64b27b3e3e83ad2a285ccc0997097"}}
:paths ["resources"]
:aliases {:remove-clojure {:classpath-overrides {org.clojure/clojure nil
org.clojure/spec.alpha nil
org.clojure/core.specs.alpha nil}}}}
kimmoko@paju ~/work/bb-integrant
0% cat <http://bb_integrant.bb|bb_integrant.bb>
(require 'spartan.spec)
(require '[integrant.core :as ig]
'[org.httpkit.server :as server]
'[<http://clojure.java.io|clojure.java.io> :as io])
(defn app [_req]
{:status 200
:body "Hello from Babashka!"})
(defmethod ig/init-key :system/handler [_ _]
app)
(defmethod ig/init-key :system/http-server [_ {:keys [port ip]}]
{:stop-fn (server/run-server app
{:port port
:ip ip})})
(defmethod ig/halt-key! :system/http-server [_ {:keys [stop-fn]}]
(stop-fn))
(let [config (ig/read-string (slurp (io/resource "config.edn")))
system (ig/init config)]
(println "System started, press enter to exit")
(.read System/in)
(ig/halt! system)
(println "System stopped"))
kimmoko@paju ~/work/bb-integrant
0% cat resources/config.edn
{:system/http-server {:port 1234
:ip "127.0.0.1"
:handler #ig/ref :system/handler}
:system/handler {}}
ah cool!
worth documenting this example in the same fashion as #742
I will add it to the CI tests and projects.md page
right, I can open an issue and put the example there for now
yes, please
wrote https://github.com/babashka/babashka/issues/743, and while writing, realised that I used that remove-clojure
alias
I think it should also work without it
but it doesn't hurt
yeah, nvm, not actually needed with spartan spec
@adam.james btw, the remove-clojure alias is also a solution to your uberscript problem with spartan.spec:
:aliases {:remove-clojure {:classpath-overrides {org.clojure/clojure nil
org.clojure/spec.alpha nil
org.clojure/core.specs.alpha nil}}
but I've adapted the README to how to best load spartan.spec to make it compatible with uberscript
Oh, thanks for the tip! I'll have to try this soon :)
👋 I’m trying to create a Web app with Babashka and I’m running into a problem inserting into a PostgreSQL array column with the PostgreSQL pod.
I’m having trouble debugging this problem and I don’t have a lot of time so I’m considering dropping the pod, adding a JVM to my server environment, and switching to using babashka.deps
to download and utilize the full-blown jdbc.next
and standard PostgreSQL JDBC driver. (I was already considering doing so, in order to use Compojure and Ring.) Before I take the time to do that, I thought I’d ask if anyone has any suggestions?
Links: https://gist.github.com/aviflax/f804c40e1ae823e7ce9e2c3766f75f53, https://github.com/aviflax/availability.help/blob/95caba1e7f3e1b9282e0cdb0ed8f2ae1daf89939/web/server.bb#L242
Thanks!
@aviflax Hey hey! The current workaround for this (and json
and jsonb
) is to convert it to ::text
and then convert it to something else in Clojure.
@aviflax There is an issue here: https://github.com/babashka/babashka-sql-pods/issues/7 What would be the sane thing to do here? Convert to a vector automatically? Same for json/jsonb -> Clojure?
The issue is that we can't serialize PGObjects over the wire (I think)
Thanks! Taking a look 👀
Maybe we can provide this automatic behavior as opt-in behavior via options
I get the select
as ::text
part, but that doesn’t (seem to) address how to insert
.
That said, now that I’m thinking about this with a fresher mind (rather than at midnight last night) I think I’m being perfectionist here, in my very specific use case right now. I can just change this column to text
, store a comma-delimited string value, and get on with it. It’ll suffice.
I think I’ll proceed with that, unless there is some quick workaround for inserting into a Postgres array column.
BTW am I missing something, or do I indeed need a JVM and need to use babashka.deps
if I want to use Ring and Compojure in a bb script?
ah, inserting a vector you mean? yeah we could also automatically convert that into a pg array on the pod side, feel free to comment in the same issue
about ring and compojure: if there is ring middleware that happens to work from source, you can add this as a dep. compojure doesn't work from source right now I believe (since it has a dependency on instaparse?)
You can build a small router from core.match, that might help: https://gist.github.com/borkdude/1627f39d072ea05557a324faf5054cf3
All makes sense, thanks very much!!!
@aviflax I think the insert problem will solve itself if we switch the pod format to transit which can cope with serializing arrays
Makes sense, sounds promising. I’d love to help test if/when the time comes!
For retrieving array we still need to do something, as described here: https://github.com/seancorfield/next-jdbc/blob/develop/doc/tips-and-tricks.md#working-with-arrays
That's only a once line change in the code :)
well no a few more, instead of EDN we need to use transit, but should be relatively small change
I have a pod using transit already here: https://github.com/babashka/pod-babashka-buddy
What do you think, will it be possible to run #reveal (using JavaFX) via bb? Though at that point I can perhaps just start clj because it will not be that fast anyway...
I don't think we are going to add JavaFX to bb, since this is probably out of scope for scripting. Probably better to GraalVM-compile your own JVM project
You could try https://github.com/djblue/portal if you wanted to inspect data from bb
Ah, thanks!
Yeah, building a small web-app on top of httpkit is probably a better approach for bb than javafx :)
I might make a small pgadmin-like tool, now that I think of it
^ @adam.james is streaming again
Does anyone here know how to produce HTML from markdown with the bootleg pod from babashka?