This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-08
Channels
- # announcements (1)
- # asami (3)
- # babashka (51)
- # beginners (86)
- # chlorine-clover (1)
- # cider (18)
- # clara (5)
- # clj-kondo (6)
- # cljsrn (6)
- # clojure (2)
- # clojure-europe (18)
- # clojure-uk (1)
- # clojurescript (57)
- # clojureverse-ops (2)
- # code-reviews (9)
- # cryogen (11)
- # depstar (5)
- # jackdaw (2)
- # malli (8)
- # nrepl (2)
- # off-topic (66)
- # practicalli (3)
- # reitit (6)
- # shadow-cljs (83)
- # sql (4)
- # vim (24)
- # xtdb (4)
@plexus Next bb will have better error msg:
1: (defrecord Foo [] Comparable (compareTo [x y] -1))
^--- Records currently only support protocol implementations, found: Comparable
How can I get the output of the script with p/process
?
(with-out-str @(p/process ["docker" "run" "--rm"
"-v" (str (.getAbsolutePath (io/file "")) ":/project")
"--user" USER_GID
"-it" IMAGE_CORDS
"/bin/bash" "-c" "clojure -Spath"
]
{:inherit true}))
I'm trying to take clojure path as a string, but automatically prints the output to the consoleAaaaa
Hmm.. Without inherit set to true docker spits to stderr the following error: the input device is not a TTY
Ok this works! Thanks @borkdude
(:out @(p/process ["docker" "run" "--rm"
"-v" (str (.getAbsolutePath (io/file "")) ":/project")
"--user" USER_GID
"-it" IMAGE_CORDS
"/bin/bash" "-c" "clojure -Spath"
]
{:out :string
:inherit true
:err :string}))
Is it possible to set throw error
option in p/process opts?
Hmm ok I will take a look into the source code! Thanks 🙂
@ everyone: I have written tasks docs: https://book.babashka.org/master.html#tasks Please read through them before I publish 0.4.0 where tasks will be "official"
@grazfather I have the following issue with parallel. Was running into this when writing the docs:
{:tasks {:init (def log (Object.))
:enter (locking log (println (java.util.Date.)))
a (Thread/sleep 5000)
b (Thread/sleep 5000)
c {:enter (println "R")
:depends [a b]}
d {:enter nil
:task (do
(let [parallel (:parallel (current-task))]
;; if d runs in parallel, we invoke c in parallel too
(time (run 'c {:parallel parallel}))))}}}
If we invoke bb run --parallel d
and d invokes (run 'c)
should c run automatically run in parallel too, or should this be the choice of who invokes run
explicitly?so with Make typically you just j
for jobs, it’s how many threads you allow, but the implication is that everything is parallelizable
basically the idea again is the dependency graph: The topological sort should let you find independent branches tnat can safely run in parallel
BUT in this case b runs c explicitly
i get what you’re asking
is run
a new function to bb?
yep exactly what I am getting to
yes, run
can be used to force things in a certain succession, so you can withstand them being run in parallel. with make you can do this too
I think that invoking make manually sucks in general, but in that case it’s up to the invoker to choose whether to paralellize… I am not even sure if a task ‘knows’ if it is running in parallel (for it to pass to its child invokation)
oh is it?
so I would say that the default should be to implicitly pass parallel, but allow it to be serialized explicitly
I can see people having issues with that (secret arguments)
but it seems to make more sense to me
people who use parallel will be confused if it’s dropped magically, people who don’t use parallel won’t notice anything either way so it doesn’t matter
(defn run
([task] (run task nil))
([task {:keys [:parallel]
:or {parallel (:parallel (current-task))}}]
(let [[[expr]] (assemble-task task parallel)]
(sci/eval-string* @ctx expr))))
is :or
a destructuring feature?
cool, TIL
Looks like a lot of effort is going into the tasks feature 🙂 is it pretty popular?
ok, so:
{:tasks {:init (def log (Object.))
:enter (locking log (println (str (:name (current-task))
":")
(java.util.Date.)))
a (Thread/sleep 5000)
b (Thread/sleep 5000)
c {:depends [a b]}
d {:task (time (run 'c))}}}
$ clojure -M:babashka/dev run --parallel d
d: #inst "2021-05-08T14:14:56.322-00:00"
a: #inst "2021-05-08T14:14:56.357-00:00"
b: #inst "2021-05-08T14:14:56.360-00:00"
c: #inst "2021-05-08T14:15:01.366-00:00"
"Elapsed time: 5023.894512 msecs"
That looks great to me
@grazfather So far tasks is being used by several people already: https://book.babashka.org/master.html#_real_world_examples I'm going to announce 0.4.0 this weekend with tasks as an "official" feature
That’s beautiful. Unfortunately I haven’t been able to play with BB in a while
That looks great to me
Something that could be nice as a babashka built-in: a typo-checker that can detect and show typos in a given string based on some accepted values. Those values could be read from the file system (via glob), git, a raw set of strings etc.
The tasks stuff looks fabulous btw!