This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-15
Channels
- # announcements (1)
- # babashka (81)
- # beginners (48)
- # calva (49)
- # clj-kondo (52)
- # cljdoc (7)
- # cljs-dev (39)
- # clojure (33)
- # clojure-australia (18)
- # clojure-europe (48)
- # clojure-italy (2)
- # clojure-morsels (2)
- # clojure-nl (3)
- # clojure-uk (6)
- # clojurescript (5)
- # community-development (2)
- # conjure (6)
- # cursive (3)
- # data-science (29)
- # datalog (4)
- # datomic (14)
- # events (1)
- # fulcro (1)
- # graphql (18)
- # gratitude (2)
- # helix (11)
- # introduce-yourself (2)
- # java (15)
- # keyboards (2)
- # lsp (6)
- # luminus (4)
- # membrane (32)
- # minecraft (1)
- # missionary (7)
- # nextjournal (2)
- # off-topic (28)
- # portal (28)
- # releases (1)
- # ring (1)
- # shadow-cljs (3)
- # sql (6)
- # xtdb (23)
wondering if writing nrepl-port file under say .bb/
or . nbb/
for nbb, would be a thing, to avoid clobbering jvm/clojure nrepl server written port file, kinda like .shadow-cljs/nrepl-port
etc.
This could work if Calva and CIDER would support this. @U0ETXRFEW @U051BLM8F
Currently Calva by default will look for the files in the project root, as [".bb-nrepl.port"]
and [".nbb-nrepl.port"]
. I am totally ready to change the defaults to harmonize/standardize. The user also can create a Custom REPL connect sequence and specify the port file there. https://calva.io/connect-sequences/ in case they don’t fancy whatever defaults we go with.
dunno, but what use is it to attempt read this file if the tool doesn't know it should produce this file :)
but it's good that Calva has something for this. now it's just a matter of coming up with the right dir + name
Yeah, so before you didn’t like the idea of bb creating this file. So then the user (or Calva) would need to do it. You gave me a nice snippet of code:
(import [ ServerSocket]
[java.lang ProcessBuilder$Redirect])
(require '[babashka.wait :as wait])
(let [nrepl-port (with-open [sock (ServerSocket. 0)] (.getLocalPort sock))
pb (doto (ProcessBuilder. ["bb" "--nrepl-server" (str nrepl-port)])
(.redirectOutput ProcessBuilder$Redirect/INHERIT))
proc (.start pb)]
(wait/wait-for-port "localhost" nrepl-port)
(spit ".nrepl-port" nrepl-port)
(println "Press enter to kill the nREPL server.")
(read-line)
(.destroy proc))
I adapted that some (can’t find it now, but anyway) and planned for Calva to help with both creating the file and looking for it at connect time. Then I decided to make Calva Jack-in watch stdout instead for when bb writes the port it uses there… Yeah, not sure I am making sense, but there it is. 😃Well, I do like the convenience, but I don't like bb overwriting the clj REPL's file
I hope to be able to support babashka’s and nbb’s REPLs while connected to clj or lein REPLs some day, so I totally agree about not overwriting the file.
In the beginning of bb I was overthinking this, considering the situation that there can also be multiple nREPL servers for the same tool
Or what about bb
, then we can also put scripts in there and it could be on the classpath by default
Both lein and clojure get by with using just one file for this, but babashka and nbb are different animals of course.
Being highly receptive to spontaneous ideas, his own and other's, is part of what explains the @U04V15CAJ phenomenon, I think.
Wondering babashka scripts would use .bb
suffix and be stored in src
, but maybe a bad idea 🙂 (just realised that I've been using .bb
suffix for maybe no reason :D)
That’s also a option. This is already supported btw on the classpath, .bb has priority.
Trying out a "pure" bb project (just bb.edn
, no deps.edn
so far) with calva. Calva testing support does not work at all for me. What would be the trick to get a smoother test experience? Introducing deps.edn
?
Not sure about #calva, perhaps @U0ETXRFEW has an idea here?
Do you mean Calva’s test runner commands, @U06FLL69W? They rely on cider-nrepl, so unless babashka has a shim for that, it won’t work. What you can do is create some custom commands/snippets that run the tests for you. See https://calva.io/custom-commands/ for how those works. And please reach out if you need help with it. When connected to babashka the repl session clj
is used.
I usually call (clojure.test/run-tests 'namespace)
or just the test as a function
Yes, so on that page there is an example snippet conf for the latter:
{
"name": "CLJ Test Top Level Defined Symbol",
"repl": "clj",
"snippet": "(clojure.test/test-var #'$top-level-defined-symbol)"
},
And something like this would run namespace tests and bind it to the keyboard shortcut ctrl+alt+space n
{
"name": "Run namespace testsl",
"repl": "clj",
"snippet": "(clojure.test/run-tests '$ns)",
"key": "n",
},
This feature request is somewhat related too, I think: https://github.com/BetterThanTomorrow/calva/issues/1305
One more: I want to ship an oci image with an uberscript. Building this thing requires a jvm and bb. Is there a publically avaiable bb builder image or efforts on the way to provide one?
@U06FLL69W Could you elaborate a bit more on builder image? you want to build an uberscript and have another image as a multistage? So the final image needs jvm and bb in it?
I think he means that the builder image needs a jvm (to resolve dependencies) but the final one doesn't
What @U04V15CAJ says.
got it. yeah we dont have one that has both now. probably a clojure/jdk image + installing bb could be the easiest
This is what I am doing. However, most java/clojure images had issues and it took a while to find one that works for this usecase. If we want this, I'd volunteer to build such a thing. However, I think is should live under the babashka umbrella at github.
@U06FLL69W Yes, I can give you a repo to work on if you want
@U04V15CAJ can we do it as adding a PR to the circleci setup that we have?
as far as i understand we just need to build a docker image with the jvm and install bb in it right? can be done as another pipeline step?
build and push it
ok, @U06FLL69W perhaps you can share your Docker image and we can make something similar to that and push it to Dockerhub
I can also start this thing under my deas
gh account. However, it would be helpful to understand its final home context. Such as ci.
the CI setup is here: https://github.com/babashka/babashka/blob/master/.circleci/config.yml we use circle ci
the relevant docker build, which could be of interest: https://github.com/babashka/babashka/blob/master/.circleci/config.yml#L451
@U06FLL69W I think the Clojure docker images could be a good place for this, too. Issue: https://github.com/Quantisan/docker-clojure/issues/129
There are a lot of clojure/java images. Most I tried had "issues" out of the box. I was aiming at minimalism. Currently ended up with:
# Most other images are missing git, curl or whatnot
FROM openjdk:11 as build
COPY . /build
WORKDIR /build
RUN curl -s -o install && \
chmod 755 install && \
./install && \
./test-runner.clj && \
bb uberscript foo.clj -f src/foo.clj
FROM babashka/babashka:latest
# COPY --from=build ...
I got holy-lambda babashka runtime working with the aws pod to do some nifty stuff today. I really like babashka.
Babashka runtime soon will land a support for arm64. Which means even lower cold start and better performance.
What challenges have you come across when using holy-lambda? @UAB2NMK25
I think the hardest thing was figuring out how to look at the event and ctx objects to see how I could use it. You might want to document the keys/values for both event and ctx to make it easier for someone to get started. I used an api gateway and (hr/json) to "export" the objects to inspect them.
Once I knew what was available in those, it was smooth sailing, and it's really a great framework for getting something going fast. I replaced a python lambda that was taking 500ms per run with bb that is under 100ms per run doing the same thing.
Oh! Thanks for sharing. It would be probably easier to inspect the event shape using sam invoke. If you were following the tutorial this is a way to know the shape of the object. You can also check generate-event command :D Anyway, it's hard to document every single event option since HL does not transform the event much. Thanks for your thoughts.
I used sam local at the beginning, but because I was using aws apis and needed a valid keyid/secret I had to do my looking from the live lambda up in aws.
Even just a few pointers in the docs about how to get vars from the url would have saved me a bunch of time. I got past it doing (hr/json {:event event}) and using my browser to explore the json output with formatters.
@UAB2NMK25 I'm trying to do something similar. do you have a link to your code?
@U06FS3DLH have you tried following HL tutorial?