Fork me on GitHub
#babashka
<
2019-11-18
>
jeroenvandijk08:11:30

Did someone already thought of using babashka in the AWS Lambda context?

jeroenvandijk11:11:41

I was trying to use ex-info's, ex-message and`ex-data`. I see that these are not implemented yet. I'm looking into this, but it seems it is not very straightforward as it involves isInstance (https://github.com/clojure/clojure/blob/clojure-1.9.0/src/clj/clojure/core.clj#L144). Did someone already consider using ex-data etc?

borkdude11:11:17

@jeroenvandijk

$ bb '(ex-data (ex-info "foo" {:a 1}))'
{:a 1}

borkdude11:11:35

TIL ex-message. Feel free to add it

🙏 4
borkdude11:11:51

but this also works for now:

$ bb '(.getMessage (ex-info "foo" {:a 1}))'
"foo"

jeroenvandijk13:11:13

ex-info en ex-data do work indeed (had to update babashka)

jeroenvandijk13:11:38

Made the change. Locally I can use ex-message now

borkdude13:11:18

The tests fail for clojure 1.9.0

borkdude13:11:33

not relevant to babashka, but sci also supports that version of clojure

borkdude13:11:23

so maybe paste the definition of ex-message at the top of the namespaces.cljc file and define it if it doesn't exist yet

jeroenvandijk14:11:14

ah I should have waited for the test result 😬 will fix it

✔️ 4
jeroenvandijk15:11:52

Found an issue with newlines I think (I can work around it for now) https://github.com/borkdude/babashka/issues/116

jeroenvandijk17:11:49

@borkdude Thanks! (apologies for the extra work!)

borkdude17:11:07

still failing though 🙂

jeroenvandijk17:11:05

nice! I'm a bit lost in the magic of all the difference versions now. And I thought this was any easy addition 🙈

borkdude17:11:39

don't worry, it works now 🙂

borkdude17:11:34

now available on babashka master as well

borkdude17:11:54

you too, I didn't even know this function existed 😉

jeroenvandijk17:11:49

btw, there is also ex-cause 😛 But I didn't need it yet (so I'm not a good tester)

borkdude18:11:19

user=> (apropos "ex-")
(clojure.core/ex-cause clojure.core/ex-data clojure.core/ex-info clojure.core/ex-message clojure.main/ex-str clojure.main/ex-triage clojure.spec.alpha/regex-spec-impl clojure.string/index-of clojure.string/last-index-of)

👌 4
Jakub Holý (HolyJak)19:11:54

@borkdude Weird thing, I upgraded to bb 0.0.30 and connect to its socket repl from Chlorine. When I try to send to it the first form, (def dry-run? true) it fails with > Could not resolve symbol: tooling$eval-res [at line 6, column 963] (the location clearly does not match my code)

mauricio.szabo19:11:46

Probably this can be a bug on Chlorine too. I'll upgrade bb and see what's happening

Jakub Holý (HolyJak)19:11:06

Also, when I tried to run my script as a whole it executed for a short while and then exited with unhelpful (the first string is obviously the path of f in the code) > ./asc/posts/1111-11-11-why-clojure-talk-transcript.asc [at line 47, column 22] This is my code, starting with line 47:

(with-open [rdr (io/reader f)
                 wrt (io/writer (.getPath f'))]
       (binding [*out* wrt]
         (run!
          #(println %)
          (line-seq rdr))))
(Removing binding and using .write wrt does not help)

Jakub Holý (HolyJak)20:11:27

Hm, I see now I get the same error with bb .28

mauricio.szabo19:11:59

@holyjak yes, it was working on version 0.0.24 and it is not working right now. The line numbers, unfortunately, will not match (yet? is there a way to tell bb what's the file name and line number of the current evaluation?)

Jakub Holý (HolyJak)19:11:57

FYI I have Chlorine 0.3.2. I did run brew upgrade recently but it would surprise me (a little) if it did upgrade Chlorine... A few days ago I used this w/o any issue

mauricio.szabo20:11:18

I'm on Chlorine 0.3.4. Somehow, the "blob" I send to capture the evaluation results is not being recognized on the newer version of bb. I'm seeing if I can come to the issue

👍 4
mauricio.szabo20:11:56

@borkdude this code isn't working anymore: (try ['tooling$eval-res (+ 1 2)])

mauricio.szabo20:11:35

Even if I rename to (try ['a-symbol (+ 1 2)]), for example, it fails with Could not resolve symbol: a-symbol

Jakub Holý (HolyJak)20:11:37

@mauricio.szabo It isn't Chlorine issue. When I downgrade to bb 0.0.28-SNAPSHOT then evaluation in Chl. works. When I try again 0.0.30 it again does not.

mauricio.szabo20:11:24

@holyjak just submitted a ticket 🙂

👍 4
Jakub Holý (HolyJak)20:11:16

OK, --verbose helps a little to troubleshoot https://clojurians.slack.com/archives/CLX41ASCS/p1574106906330500 but still does not tell me why it failed: > ExceptionInfo: ./2018-12-21-aws-rds-find-out-login-credentials.asc [at line 47, column 22]

borkdude21:11:11

@mauricio.szabo Thanks, will look into it asap

👍 4
borkdude21:11:40

Fix underway

borkdude22:11:06

@mauricio.szabo Fixed in v0.0.31:

$ bb "(try 'hello)"
hello

mauricio.szabo22:11:48

@borkdude Great, it works! @holyjak Just tested with Chlorine's last version, and I can evaluate commands again 🙂

borkdude22:11:29

I made an optimization: before 0.0.30 the body of functions and loops would be analyzed on every iteration, which was unnecessary. This error had to do with that change.

sogaiu23:11:30

worked here too with latest babashka master and chlorine 0.3.4