Fork me on GitHub
#babashka
<
2021-04-17
>
borkdude10:04:10

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

👍 8
mike_ananev12:04:36

@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_ananev12:04:24

I mean using :depends section?

mike_ananev12:04:38

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

borkdude13:04:33

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

mike_ananev13:04:59

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

borkdude13:04:29

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

borkdude13:04:09

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

🆒 4
pinkfrog14:04:52

(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

borkdude14:04:56

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

borkdude14:04:46

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

pinkfrog14:04:10

Thaks for that info

grazfather16:04:10

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

grazfather16:04:40

looks like it, that’s really nice

grazfather16:04:29

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

grazfather16:04:41

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

borkdude16:04:58

@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)

grazfather16:04:34

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

borkdude16:04:39

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

grazfather16:04:47

yep vector works as well

grazfather16:04:26

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

grazfather16:04:55

bb can’t even parse the tasks

borkdude16:04:08

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

grazfather16:04:27

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

borkdude16:04:52

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

grazfather16:04:15

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

borkdude16:04:17

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

👍 2
grazfather16:04:54

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

borkdude16:04:38

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

grazfather16:04:58

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

borkdude16:04:47

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

borkdude16:04:13

You can see that in the REPL by doing:

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

grazfather16:04:48

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

borkdude16:04:57

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

grazfather16:04:57

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

grazfather16:04:06

same idea about reader macros?

borkdude16:04:30

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

grazfather16:04:37

strange that #{} does though

grazfather16:04:52

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

borkdude16:04:56

EDN is just a subset of clojure for data notation

grazfather16:04:19

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

borkdude16:04:52

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

mike_ananev19:04:39

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_ananev19:04:58

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_ananev19:04:14

What I'm doing wrong?

borkdude19:04:11

@mike1452

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