babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2021-04-17T10:26:10.226Z

Made a video showing bb tasks as it is currently. I'd love to have your feedback! https://youtu.be/b-XwAIM0bV0

👍 3
mike_ananev 2021-04-17T12:25:36.228700Z

@borkdude if task b depends on a and task c depends on a, but task a should have different params from b and c how I can implement such behaviour ?

mike_ananev 2021-04-17T12:31:24.229500Z

I mean using :depends section?

mike_ananev 2021-04-17T12:50:38.230200Z

solved: I made a as a function and call a from b and c with different params

borkdude 2021-04-17T13:02:33.230700Z

@mike1452 Correct, you should just use a function, since :depends cannot decide if a task has already been run if you use parameters

mike_ananev 2021-04-17T13:10:59.232Z

How I can print :doc section inside task for this task or another task? Can I access to it via meta?

borkdude 2021-04-17T13:12:29.232600Z

There isn't anything around this (yet). You could just parse the EDN file yourself and look up the docstring perhaps.

mike_ananev 2021-04-17T13:16:18.233100Z

thanks

borkdude 2021-04-17T13:59:09.233700Z

Since bb now supports rewrite-clj, rewrite-edn is also compatible with babashka: https://github.com/babashka/babashka/issues/793

🆒 2
2021-04-17T14:09:52.234800Z

(cp/add-classpath classpath)

(require '[datomic.api :as d])
dynamically adds datomic pass to classpaht, but errs with: ----- Error -------------------------------------------------------------------- Type: java.lang.Exception Message: Could not find namespace: datomic.api. Location: 15:1

borkdude 2021-04-17T14:11:56.235500Z

@i babashka can only run clojure from source (`.clj`, etc.) and I guess the datomic.api namespace is AOT-ed

borkdude 2021-04-17T14:12:46.236100Z

There was a PR which tried to add the datomic pro client as a built-in library to bb, but it stalled: https://github.com/babashka/babashka/pull/505

2021-04-17T14:13:10.236500Z

Thaks for that info

grazfather 2021-04-17T16:00:10.237500Z

nice video. In your -java-files example, is it that a depency’s return value is bound to that name in the task context?

grazfather 2021-04-17T16:02:40.237700Z

looks like it, that’s really nice

grazfather 2021-04-17T16:03:29.237900Z

test1 {:task ["echo hello"]}
          test2 {:task '("echo hello")}

grazfather 2021-04-17T16:03:41.238300Z

would you expect the second to fail? is '() not a thing in edn?

borkdude 2021-04-17T16:05:58.239700Z

@grazfather correct. and the second thing currently works but this is because ' is allowed in EDN, it's just parsed as a separate token. In a second pass it's parsed as normal code. If you want a list you can also use (list 1 2 3)

grazfather 2021-04-17T16:06:34.240400Z

yep I switched to list, I just got a weird error about my tasks map not being valid

borkdude 2021-04-17T16:06:39.240600Z

but usually it doesn't matter if you make a list or vector so [1 2 3] may also work

grazfather 2021-04-17T16:06:47.240800Z

yep vector works as well

grazfather 2021-04-17T16:07:26.241600Z

i wanted to test a simple task that only returns something and ’(..) failed

grazfather 2021-04-17T16:07:55.242300Z

bb can’t even parse the tasks

borkdude 2021-04-17T16:08:08.242600Z

Ah I see why it failed. In EDN {:foo 'bar} is parsed as {:foo ' bar} which is an invalid map :)

grazfather 2021-04-17T16:08:14.242800Z

ahh

grazfather 2021-04-17T16:08:27.243200Z

yeah I was wondering, but I didn’t know how to get the intermediate representation

borkdude 2021-04-17T16:08:52.243600Z

you can also do (do '(1 2 3)) which would probably work

grazfather 2021-04-17T16:09:15.244400Z

yeah there are many ways around it i just wanted to confirm it was my problem and not bbs

borkdude 2021-04-17T16:09:17.244600Z

in general it may be best to avoid the ' if you can

👍 1
grazfather 2021-04-17T16:09:54.245100Z

You should have used the coffee example for your parallel demo 😉

borkdude 2021-04-17T16:10:38.246Z

Maybe I will do another video about parallel, since I also forgot to demo the parallel dev task I had :/. Thanks for reminding me, I'll also include the coffee

grazfather 2021-04-17T16:11:58.247Z

yeah it’s pretty powerful. You don’t need to include the coffee, I meant it as an example since it would clearly show the time saved, your demo in this video unfortunately didn’t save a ton

borkdude 2021-04-17T16:15:47.247800Z

@grazfather btw, about the quote thing: you can also write (quote (1 2 3)), this is what '(1 2 3) expands into

grazfather 2021-04-17T16:15:57.248Z

true

borkdude 2021-04-17T16:16:13.248500Z

You can see that in the REPL by doing:

user=> `'(1 2 3)
(quote (1 2 3))

grazfather 2021-04-17T16:16:48.249200Z

yeah I know how the reader macros work pretty well, I think, I just don’t know as well how they work in edn format

borkdude 2021-04-17T16:16:57.249600Z

#(+ 1 2 3 %) also doesn't work in EDN btw

grazfather 2021-04-17T16:16:57.249700Z

since it’s less clear when the eval is, i think

grazfather 2021-04-17T16:17:06.249900Z

same idea about reader macros?

borkdude 2021-04-17T16:17:30.250400Z

well, #{1 2 3} does work for example

grazfather 2021-04-17T16:17:37.250600Z

strange that #{} does though

grazfather 2021-04-17T16:17:42.250800Z

yes exactly

grazfather 2021-04-17T16:17:52.251300Z

it had me wondering because of the parallel tasks thing from before

borkdude 2021-04-17T16:17:56.251500Z

EDN is just a subset of clojure for data notation

grazfather 2021-04-17T16:18:19.251900Z

right, but why do some reader macros work and not others?

borkdude 2021-04-17T16:20:52.252400Z

I think because #{1 2 3} is data but '(1 2 3) has to do with evaluation

grazfather 2021-04-17T17:06:13.252500Z

¯\(ツ)

mike_ananev 2021-04-17T19:16:39.253100Z

Can't load libraries in task.

-env              {:requires ([babashka.deps :as deps])
                            :task     (do
                                        (require '[babashka.deps :as deps])
                                        (deps/add-deps '{:deps {cprop/cprop {:mvn/version "0.1.16"}}})
                                        (require '[cprop.core :refer [load-config]])
                                        (load-config))}

mike_ananev 2021-04-17T19:16:58.253500Z

16: (def -env (do (require ' [babashka.deps :as deps]) (deps/add-deps ' {:deps {cprop/cprop {:mvn/version "0.1.16"}}}) (require ' [cprop.core :refer [load-config]]) (load-config))) -env
                                                                                                                                                                                    ^--- Could not resolve symbol: load-config

mike_ananev 2021-04-17T19:17:14.253900Z

What I'm doing wrong?

borkdude 2021-04-17T19:19:11.254100Z

@mike1452

{:deps {cprop/cprop {:mvn/version "0.1.16"}}
 :tasks {-env {:requires ([cprop.core :refer [load-config]])
               :task     (load-config)}}}

mike_ananev 2021-04-17T19:20:22.254400Z

ah! thanks!