./script/compile: line 49: ~/Downloads/graalvm-ce-java11-20.3.1/Contents/Home/bin/native-image: No such file or directory
I’ll try 20.3.0 just in case 20.3.1 doesn’t workGot past that part by installing the native-image via gu install native-image
but ran into another snag: I built it on OS X when it needs to be built on a similar OS. Setting up a docker container for it now.
@jayzawrotny FWIW, babashka itself also has a Dockerfile, maybe it helps
I am looking into how to get an overview of test coverage while running tests on some BB code. I can include cloverage
as a dependency but unsure how to set the arguments that are required..
Clojure CLI Tool
To use cloverage in a Clojure CLI Project, clj -Sdeps '{:deps {cloverage {:mvn/version "RELEASE"}}}' -m cloverage.coverage *args-to-coverage*
Where args-to-coverage will usually be something like "-p src -s test"
https://github.com/cloverage/cloverage
(deps/add-deps '{:deps {cloverage/cloverage {:mvn/version "1.2.2"}}})
Any pointers on how i could set the required parameters?@marco.pasopas cloverage is a pretty low level tool which will instrument your clojure code in a JVM. I'm pretty sure it doesn't work with bb / sci. But what you can do is run your scripts with JVM clojure / leiningen in development and then run cloverage as usual. And then run your scripts with bb when done.
@borkdude Do you have an alternative that could be used with bb / sci?
Not that I know of
@marco.pasopas Btw, you can run a JVM with bb as well:
bb --clojure ...
this might help somewhatWil give it a try 🙂
but you will have to add deps that are built into bb explicitly in a deps.edn file
if you are using those
A small ring router using clojure.core.match: https://twitter.com/borkdude/status/1353674980425404417 Source: https://gist.github.com/borkdude/1627f39d072ea05557a324faf5054cf3
Is it so that https://book.babashka.org/#_uberscript does not work with scripts that require a pod? (I am trying to make something that will be simple to run in AWS Lambda. The original https://github.com/dainiusjocas/babashka-lambda/ uses uberscript but I need to include 1-2 pods (thi binaries are present))
@holyjak pods aren't included in uberscripts, an uberscript is just one source file
you can also make an uberjar, but I don't think you can run binaries from a jar
so it's probably best to include them in the docker image by explicitly adding them
or you can let them download in the lambda but I don't know if that will persist somehow (probably not) and this will incur some startup time
I build the uberjar and include that + bb + the pods. That seems to work.
cool
Question about the AWS pod - I have a fn like this that return the credentials to use for an S3 call:
(defn assume-s3-writer-role []
(-> (aws/invoke sts-client
{:op :AssumeRole
:request {:RoleArn "arn:aws:iam::123:role/my-s3-role"
:RoleSessionName "xyz"}})
:Credentials
(select-keys [:AccessKeyId :SecretAccessKey :SessionToken])))
how best to plug it into the s3-client? The basic provider does not support session token yet so I guess I need to set system properties and use the sys. property one...@holyjak I think you can pass these tokens along with the basic credential provider: https://github.com/babashka/pod-babashka-aws#credentials
not for session token - see https://github.com/cognitect-labs/aws-api/issues/170
I think the aws pod does support it
https://github.com/babashka/pod-babashka-aws/search?q=session-token
to mee it seems you just wrap the cognitect provider, which as per ☝️ does not support it https://github.com/babashka/pod-babashka-aws/blob/main/src/pod/babashka/aws/impl/aws/credentials.clj#L37
@holyjak right. @i.slack might be able to explain you what he did here: https://github.com/babashka/pod-babashka-aws/commit/58b0e80709eb00e715abf20174811c50cb4147d4
the profile and sys. props. providers support it but not the basic one
then use those?
Yes, that is what I was thinking. Sadly it seems I cannot use the with-system-properties
macro so it is slightly more work but still possible.
@holyjak Maybe it works when you just set the right system property before the call?
@jeroenvandijk might also have ideas. his credential-process logic might support it, but I'm not sure. this allows you to call out to a different program
Yes, both the cred. process and the sys, props would work.
I ended up with this:
(defn set-s3-writer-credentials-sysprops []
(-> (aws/invoke sts-client
{:op :AssumeRole
:request {:RoleArn "arn:aws:iam::123:role/my-s3-role"
:RoleSessionName "xyz"}})
:Credentials
((juxt :AccessKeyId :SecretAccessKey :SessionToken))
(->> (zipmap ["aws.accessKeyId" "aws.secretKey" "aws.sessionToken"])
(run! (fn [[k v]] (System/setProperty k v))))))
(set-s3-writer-credentials-sysprops)
(def s3-client (aws/client {:api :s3
:region region
;; the basic-provider does not support session token yet - see <https://github.com/cognitect-labs/aws-api/issues/170>
:credentials-provider (credentials/system-property-credentials-provider)}))
cool, hope it works!
Any tips how to troubleshoot https://github.com/babashka/pod-babashka-aws/issues/30 ? I would like to find out where the exception is thrown and whether it contains any details about the problematic http response. I guess it was a redirect - from which url to which? ...
Is it possible for you to reproduce this using the "normal" aws-api lib?
good idea, will try
@holyjak Ah, I think I've seen that before. https://github.com/cognitect-labs/aws-api/issues/15
https://github.com/cognitect-labs/aws-api#invalid-location-header-null
> This indicates that you are trying to access an S3 resource (bucket or object) that resides in a different region from the client's region. Remedy: create a new s3 client in the same region you are trying to access.
thanks a lot!!! That could be it
I had the same problem, you can look at the tests, there as also set the region
I do set it. The problem is that the bucket is obviously elsewhere than I expected 🙂
sorry to be late to the party here. @holyjak you got! that is exactly what I do in my scripts. I have generic util package that runs aws-adfs and returns key, token, etc and I just set it to my system properties. It works and I can just :require the package in the same JVM which does not allow to set env vars.
BTW thanks a lot for the aws pod
:thumbsup: good to see it being used
Hello everyone, can someone tell me what they are using for logging given most of the libs require some reflection and won’t work without compiling ?
@gary001 you mean for a graalvm project, apart from bb?
no, for my bb script.
ah right. I'm not aware of any fancy logging library for bb, besides the usual prn
, println
and (binding [*out* *err*] ...)
Simple logger to stderr, including namespace, line and col:
(ns logger)
(defmacro log [& msgs]
(let [m (meta &form)]
`(binding [*out* *err*] ;; or bind to (io/writer log-file)
(println (str (ns-name *ns*) ":"
~(:line m) ":"
~(:column m))
~@msgs))))
(ns bar (:require logger))
(logger/log "what goes on here")
bar:13:1 what goes on here
^ @gary001