This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-14
Channels
- # babashka (53)
- # beginners (158)
- # calva (25)
- # cider (21)
- # clara (1)
- # clj-kondo (12)
- # cljsrn (6)
- # clojure (94)
- # clojure-australia (2)
- # clojure-bay-area (6)
- # clojure-europe (40)
- # clojure-nl (10)
- # clojure-spec (16)
- # clojure-uk (18)
- # clojurescript (95)
- # cursive (14)
- # data-science (1)
- # datascript (6)
- # datomic (18)
- # depstar (2)
- # duct (36)
- # emacs (15)
- # events (4)
- # fulcro (16)
- # graalvm (10)
- # helix (25)
- # honeysql (6)
- # jackdaw (4)
- # jobs (2)
- # leiningen (24)
- # lsp (4)
- # malli (10)
- # off-topic (3)
- # pathom (3)
- # polylith (19)
- # practicalli (4)
- # prelude (1)
- # re-frame (6)
- # reagent (13)
- # reitit (3)
- # remote-jobs (10)
- # ring (12)
- # ring-swagger (2)
- # shadow-cljs (54)
- # testing (17)
- # tools-deps (10)
- # xtdb (14)
I’m looking for an example of setting up babashka (including paths and such) on CircleCI. Anyone have such an example?
@jeroenvandijk I think you should just be able to do this:
bash < <(curl -s )
you might need sudo
Had to use sudo
indeed
@U04V15CAJ minimal example of .circleci/config.yml
:
version: 2
jobs:
build:
docker:
- image: circleci/clojure:lein-2.7.1
working_directory: ~/repo
steps:
- run:
name: Install bb
command: |
sudo bash < <(curl -sL )
- run:
name: Test bb
command: |
bb version
I’ll give it a try! Thanks. I found this example as well https://github.com/babashka/pod-babashka-aws/blob/main/.circleci/config.yml#L93 But I figured there might be a more complete one where babashka is used for all scripts
@jeroenvandijk you can use bb.edn
:paths
. rewrite-clj is using this extensively now (look at all those bb scrips in the script dir)
https://github.com/clj-commons/rewrite-clj
ah yeah. That’s a very complete example 🙂
Hi! I struggle with combining -m
with a custom script. I have ~/Library/me/bin/mb-callls.bb
that starts with (ns mb-calls ...)
and invoke bb --classpath ~/Library/me/bin -m mb-calls/testit "hi"
but it fails with
> Message: Could not find namespace: mb-calls.
(ideally, I would be able to run bb -f ~/Library/me/bin/mb-calls.bb -m mb-calls/testit "hi"
IMHO)
What do I do wrong? (I do not use bb.edn) Thank you!
Thanks, it works!
with babashka tasks, I’m often feeling the need to use bash
things (like VAR=SOMETHING command ...
or do-soething > save-here.file
), and given the shell doesn’t have those, I wonder about having another helper to handle these common cases, maybe: (bash "NOW_VARS=likeThis will-work")
the env var need is more common than the others, so there is also the option to maybe provide :env
to shell
in some way
@U066U8JQJ This is already supported :)
(shell {:out "the-file.txt" :extra-env {"NOW_VARS" "likeThis"}} "dude")
oh, awesome! I wasn’t aware 🙂
thats nice, glad to learn this, gonna use often 🙂
@pez sure! @lukaszkorecki can tell you more maybe. there is also this blog: https://www.jocas.lt/blog/post/babashka-aws-lambda/
@pez I built a POC for Lambda+Docker, as IMHO it's easier to deal with than custom layers and stuff (and you can use your code outside of lambda too if you need to): https://gist.github.com/lukaszkorecki/a1fe27bf08f9b98e9def9da4bcb3264e We're migrating one of our Clojure services (no BB, yet!) into Lambda, and that's the approach we're taking
I understand that bb's startup time is pretty low, but shouldn't you actually have some sort of event-handling-loop inside that lambda's code? I'd expect something similar to https://github.com/andthearchitect/aws-lambda-java-runtime/blob/master/src/main/java/com/ata/aws/lambda/LambdaBootstrap.java#L58-L77
even the documentation in https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html states: > Your runtime code is responsible for completing some initialization tasks. Then it processes invocation events in a loop until it's terminated. The initialization tasks run once https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html to prepare the environment to handle invocations.
I see - we didn't get as far as deploying to the actual lambda environment (due to other blockers on our end) - but it def worked in the simulator. That said, you can add the while true
loop here: https://gist.github.com/lukaszkorecki/a1fe27bf08f9b98e9def9da4bcb3264e#file-core-clj-L57-L63 and it will work just like the Java example (I think, caveat emptor)
For the JVM Clojure we're just using the SDK + deploying an uberjar with Terraform - startup time in our use case is not relevant
It occurred to me that would it make sense to have the Lambda custom runtime polling loop as a mini library even? Could help taking bb into use in Lambda maybe more. Maybe using http-kit client, or even so that another http client could be used (might help to run as a jvm lib without http-kit even).
Oh totally, I think I have more structured code laying around somewhere, but you know how it works - lack of time etc etc etc
here's also one implementation https://github.com/dainiusjocas/babashka-lambda-layer/tree/master/src/lambda
I thought I had seen some discussions about how inspect a jar from Babashka. Google mentions something from the slack archive, but I can’t seem to open the page. Any other suggestions?
@jeroenvandijk Here is an example: https://github.com/babashka/babashka/blob/master/examples/ls_jar.clj
Ah perfect thanks 🙂
I forgot to look there 😅
The next version of bb will add support for the https://github.com/helins/binf.cljc library (by adding relevant Java classes): read and write binary formats with ease. This could be useful if you e.g. want to write a parsing library for midi, or WASM, or whatever other binary format. This library will then also work with bb (according to @adam678): https://github.com/helins/wasm.cljc
Indeed, here is a very short but fully working example of decompiling a WASM program into Clojure data and pretty printing it: https://gist.github.com/helins/eacfc7d8b92b97693a93dd46e8a89677
Speaking about wasm, did someone try this? https://github.com/i-net-software/JWebAssembly ? Useful to have a sandbox for Sci projects? :thinking_face:
btw @jeroenvandijk I couldn't find our old discussion, but bb 0.3.5 now has the :requires
functionality
Ah awesome! Thanks!
@U04V15CAJ It works! I did find that the require is only needed in the list form:
{:paths
["bb-scripts"]
:tasks {midje-a {:requires ([tasks])
:task (tasks/midje)}
midje-b {:task tasks/midje}}}
Both workGreat! Thanks
It occurred to me that would it make sense to have the Lambda custom runtime polling loop as a mini library even? Could help taking bb into use in Lambda maybe more. Maybe using http-kit client, or even so that another http client could be used (might help to run as a jvm lib without http-kit even).