Made a video showing bb tasks
as it is currently. I'd love to have your feedback!
https://youtu.be/b-XwAIM0bV0
@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 ?
I mean using :depends
section?
solved: I made a as a function and call a from b and c with different params
@mike1452 Correct, you should just use a function, since :depends
cannot decide if a task has already been run if you use parameters
How I can print :doc section inside task for this task or another task? Can I access to it via meta?
There isn't anything around this (yet). You could just parse the EDN file yourself and look up the docstring perhaps.
thanks
Since bb now supports rewrite-clj, rewrite-edn is also compatible with babashka: https://github.com/babashka/babashka/issues/793
(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@i babashka can only run clojure from source (`.clj`, etc.) and I guess the datomic.api namespace is AOT-ed
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
Thaks for that info
nice video. In your -java-files
example, is it that a depency’s return value is bound to that name in the task context?
looks like it, that’s really nice
test1 {:task ["echo hello"]}
test2 {:task '("echo hello")}
would you expect the second to fail? is '()
not a thing in edn?
@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)
yep I switched to list, I just got a weird error about my tasks map not being valid
but usually it doesn't matter if you make a list or vector so [1 2 3]
may also work
yep vector works as well
i wanted to test a simple task that only returns something and ’(..) failed
bb can’t even parse the tasks
Ah I see why it failed. In EDN {:foo 'bar}
is parsed as {:foo ' bar}
which is an invalid map :)
ahh
yeah I was wondering, but I didn’t know how to get the intermediate representation
you can also do (do '(1 2 3))
which would probably work
yeah there are many ways around it i just wanted to confirm it was my problem and not bbs
in general it may be best to avoid the '
if you can
You should have used the coffee example for your parallel demo 😉
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
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
@grazfather btw, about the quote thing: you can also write (quote (1 2 3))
, this is what '(1 2 3)
expands into
true
You can see that in the REPL by doing:
user=> `'(1 2 3)
(quote (1 2 3))
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
#(+ 1 2 3 %)
also doesn't work in EDN btw
since it’s less clear when the eval is, i think
same idea about reader macros?
well, #{1 2 3}
does work for example
strange that #{}
does though
yes exactly
it had me wondering because of the parallel tasks thing from before
EDN is just a subset of clojure for data notation
right, but why do some reader macros work and not others?
I think because #{1 2 3}
is data but '(1 2 3)
has to do with evaluation
¯\(ツ)/¯
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))}
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
What I'm doing wrong?
{:deps {cprop/cprop {:mvn/version "0.1.16"}}
:tasks {-env {:requires ([cprop.core :refer [load-config]])
:task (load-config)}}}
ah! thanks!