babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
onetom 2021-04-01T02:05:29.313700Z

node.js has a similar feature for ensuring the version of the runtime (and even the OS and the CPU arch): https://docs.npmjs.com/cli/v7/configuring-npm/package-json#engines it's not necessarily the best place to copy ideas from, but might give u some ideas.

borkdude 2021-04-01T07:41:59.314300Z

@richiardiandrea Maybe you are wrapping the arguments inside a vector while they should not be?

richiardiandrea 2021-04-01T15:23:24.315200Z

the first param is a vector that I want to store as json, the second and third two uuids

borkdude 2021-04-01T15:26:21.315400Z

can you show the entire query, not just the result from the database?

borkdude 2021-04-01T15:26:43.315600Z

oh I see

borkdude 2021-04-01T15:26:52.315800Z

the vector should be saved as json?

borkdude 2021-04-01T15:27:41.316100Z

there are docs for this: https://github.com/babashka/babashka-sql-pods/#json

borkdude 2021-04-01T15:27:56.316300Z

let me know if this works for you

richiardiandrea 2021-04-01T15:28:28.316500Z

yeah that is the goal, i initially tried with the metadata but it was spitting that error then worked around it with json/generate-string

borkdude 2021-04-01T15:29:03.316700Z

show me the original query with metadata that failed please

richiardiandrea 2021-04-01T15:29:12.316900Z

let me share that yeah, just a sec

borkdude 2021-04-01T15:29:17.317100Z

because this should work and if not, I'ld like to know why

richiardiandrea 2021-04-01T15:33:47.317300Z

this is what it is not working

(defn update-diagnostic-report-descriptors!
  [db-or-tx image]
  (let [target-report (:target-report image)
        query "UPDATE diagnostic_reports SET image_descriptors = (?::jsonb) WHERE id = ? AND version_id = ?"
        sqlvec [query
                ^{:pod.babashka.sql/write :jsonb} (:image-descriptors image)
                (:id target-report)
                (:version-id target-report)]]
    (db/execute-one! db-or-tx sqlvec)))

borkdude 2021-04-01T15:36:38.317600Z

you need to write:

(with-meta (:image-descriptors image) {:pod.babashka.sql/write :jsonb} )
but in hindsight, I think I will change this, because this isn't very nice to write

borkdude 2021-04-01T15:37:09.317800Z

I think I'll just offer (db/json ...) and (db/jsonb ...) that will handle this for you

richiardiandrea 2021-04-01T15:38:04.318Z

ok let me try that...and why is that the case? I actually remember that I had to wrap some of my params in a function for attaching metadata once..

richiardiandrea 2021-04-01T15:39:02.318200Z

looks like that worked

richiardiandrea 2021-04-01T15:40:16.318400Z

this also works

> (def v ^{:pod.babashka.sql/write :jsonb} [])
#<SciVar@28395993: []>
> (meta v)
{:pod.babashka.sql/write :jsonb}

richiardiandrea 2021-04-01T15:40:33.318600Z

anyways, thank you for the hint 😄

borkdude 2021-04-01T15:41:25.318800Z

yes, that works, but (meta ^{:m 1} (conj [] nil)) doesn't work so I think it's better to just offer some function that handles these details https://github.com/babashka/babashka-sql-pods/issues/31

👍 1
gdubs 2021-04-01T16:52:05.320600Z

I want to use https://github.com/retro/graphql-builder with babashka. It has dependencies which use java.util.concurrent... stuff. What are my options here? Put graphql-builder in a pod? Rebuild babashka with java.util.concurrent?

gdubs 2021-04-01T17:00:25.321500Z

I'd prefer to just add the necessary classes to upstream babashka. I assume the downsides are this expands the bb binary size?

borkdude 2021-04-01T17:18:26.322Z

@gdwarner You can make an issue where you request the class with some evidence that this is useful for scripting and I'll take a look

borkdude 2021-04-01T17:18:53.322400Z

why does a graphql lib need java.concurrent?

borkdude 2021-04-01T17:36:04.323100Z

@gdwarner I tried this myself and this is needed in clj-antlr which in turn needs the java ANTLR library which is not supported in babashka

gdubs 2021-04-01T17:38:01.323900Z

That's right. And that makes sense why it wouldn't work. Thank you.

richiardiandrea 2021-04-01T18:28:18.325200Z

Hi there, question about pods, is there a way to have load-pod save to a local folder? I like the structure of ~/.babashka/pods/repository/org.babashka and I would like to replicate it and then tar everything for distribution.

borkdude 2021-04-01T18:29:14.325600Z

@richiardiandrea Currently not, but we could make this configurable perhaps, via some env var?

borkdude 2021-04-01T18:29:47.326200Z

I'm also still conflicted between ~/.babashka and ~/.bb. In the future people might have a bb.edn there too...

borkdude 2021-04-01T18:30:02.326500Z

We could also add this to bb.edn

richiardiandrea 2021-04-01T18:36:45.329Z

yeah, cause it's a bit cumbersome to download stuff manually like in this approach https://github.com/eccentric-j/idle-parens/blob/8f4142d66698adadb321ace92da9ed79bbcbcedc/resources/blog/2021-01-27-clojure-like-its-php.md#the-clojure-files Additionally, given pods are OS dependent, you would need to specify the target... Yeah specifying pods in bb.edn is a good option..what about this

{:paths ...
   :deps ...
   :pods {org.babashka/postgresql :github/version "0.0.5"}
And then
bb dump-pods <dir> <arch>

borkdude 2021-04-01T18:41:06.331200Z

Yeah, something like that might work. Perhaps:

bb pods install /tmp/pods --arch ....
but then also:
{:pods {:dir "/tmp/pods" ....}}
if you want to load the pods from some specific dir

richiardiandrea 2021-04-01T18:42:51.331900Z

oh yes right good idea!

richiardiandrea 2021-04-01T18:44:11.332500Z

gonna open a feature request and start checking how difficult that would be to implement 😄

borkdude 2021-04-01T18:44:22.332700Z

ok :)