Fork me on GitHub
#babashka
<
2023-03-02
>
lispyclouds07:03:05

with the newest loomed bb, when running bb -e "(set-agent-send-off-executor! (java.util.concurrent.Executors/newVirtualThreadPerTaskExecutor)) @(future (println (.getName (Thread/currentThread))))" i get a clojure.lang.ExceptionInfo: Method getName on class java.lang.VirtualThread not allowed! should it be added to the reflection config?

borkdude08:03:45

The added clause should not mention the private class, but just: (instance? Thread ..) Thread

lispyclouds08:03:57

Okay will do an issue+PR

borkdude12:03:33

I'll have a look. Want to take this one? ;)

borkdude12:03:10

> Please test locally (with native-image, JVM is not sufficient) and a test

borkdude12:03:17

I meant to say: please add a test

lispyclouds13:03:06

@U04V15CAJ any recommended place to put the test?

lispyclouds13:03:57

not sure if any of the existing files quite fit, could go with a new file?

borkdude13:03:15

when I have no specific place, I put it in main_test

borkdude13:03:42

but we could move some of these interop tests to a new file. I've recently added another one in main_test

lispyclouds13:03:41

i can do the tests cleanup in another PR? for this one im creating an interop_test.clj?

lispyclouds13:03:56

decided the empty str check is good enough otherwise i need to use a thread factory to set names

borkdude13:03:56

yes, as long as the interop works like expected.

lispyclouds13:03:39

finally needed to add the --enable-preview 😄

borkdude14:03:12

neh I guess it's fine. I've made the virtual threads stuff optional so bb can still be compiled with 11-18

borkdude14:03:18

but for the tests it doesn't matter I guess

lispyclouds14:03:35

yeah its quite necessary for this particular test

borkdude14:03:58

I mean, people compiling their own bb (and nix package etc) doesn't care about the tests

lispyclouds14:03:07

im building this little (now much more efficient) DDoS tool in bb, thats how i noticed this issue 😛

lispyclouds14:03:46

hopefully that will be a much more comprehensive loom demo for bb

lispyclouds14:03:41

flaky test failures, the one from me passed

borkdude14:03:19

let's wait for windows

borkdude14:03:10

ok merged

2
borkdude14:03:07

@U7ERLH6JX github actions is failing lein test :only babashka.interop-test/vthreads-test https://github.com/babashka/babashka/actions/runs/4314843844/jobs/7528417244#step:12:247 https://github.com/babashka/babashka/actions/runs/4314843844/jobs/7528417244#step:12:248 ERROR in (vthreads-test) (test_utils.clj:100) https://github.com/babashka/babashka/actions/runs/4314843844/jobs/7528417244#step:12:249 can invoke methods on java.lang.VirtualThread https://github.com/babashka/babashka/actions/runs/4314843844/jobs/7528417244#step:12:250 expected: (= "" (bb nil "(set-agent-send-off-executor! (java.util.concurrent.Executors/newVirtualThreadPerTaskExecutor)) @(future (.getName (Thread/currentThread)))")) https://github.com/babashka/babashka/actions/runs/4314843844/jobs/7528417244#step:12:251 actual: clojure.lang.ExceptionInfo: ----- Error -------------------------------------------------------------------- https://github.com/babashka/babashka/actions/runs/4314843844/jobs/7528417244#step:12:252 Type: java.lang.IllegalArgumentException https://github.com/babashka/babashka/actions/runs/4314843844/jobs/7528417244#step:12:253 Message: No matching method newVirtualThreadPerTaskExecutor found taking 0 args https://github.com/babashka/babashka/actions/runs/4314843844/jobs/7528417244#step:12:254 Location: <expr>:1:1

borkdude14:03:15

Maybe because graal must be updated there or so

lispyclouds14:03:04

i'll take a look in a bit?

borkdude14:03:27

Bumping myself now

Daniel Gerson11:03:44

Not sure if neil stuff is applicable on this channel, but I'm getting the following java.util.concurrent.ExecutionException error. See in 🧵

Daniel Gerson11:03:25

> neil dep upgrade
----- Error --------------------------------------------------------------------
Type:     java.util.concurrent.ExecutionException
Message:  java.lang.NullPointerException
Location: /opt/homebrew/bin/neil:1556:3

----- Context ------------------------------------------------------------------
1552:
1553:
1554:
1555: (defn -main [& _args]
1556:   (cli/dispatch
        ^--- java.lang.NullPointerException
1557:    [{:cmds ["add" "dep"] :fn dep-add :args->opts [:lib]}
1558:     {:cmds ["add" "test"] :fn add-cognitect-test-runner}
1559:     {:cmds ["add" "build"] :fn add-build}
1560:     {:cmds ["add" "kaocha"] :fn add-kaocha}
1561:     {:cmds ["add" "nrepl"] :fn add-nrepl}

----- Stack trace --------------------------------------------------------------
clojure.core/deref-future            - <built-in>
clojure.core/future-call/reify--8544 - <built-in>
clojure.core/deref                   - <built-in>
clojure.core/map/fn--5935            - <built-in>
clojure.core/seq--5467               - <built-in>
... (run with --debug to see elided elements)
clojure.core/seq--5467               - <built-in>
babashka.neil/-main                  - /opt/homebrew/bin/neil:1556:3
babashka.neil/-main                  - /opt/homebrew/bin/neil:1555:1
babashka.neil                        - /opt/homebrew/bin/neil:1616:3
babashka.neil                        - /opt/homebrew/bin/neil:1615:1

> neil --version
neil 0.1.56

Daniel Gerson11:03:55

{:paths ["src" "resources"]
 :deps {com.cognitect.aws/endpoints {:mvn/version "1.1.12.415"}
        com.cognitect.aws/dynamodb {:mvn/version "825.2.1262.0"}
        com.cognitect.aws/apigatewayv2 {:mvn/version "821.2.1107.0"}
        com.grzm/awyeah-api {:git/url ""
                             :git/sha "9257dc0159640e46803d69210cae838d411f1789"
                             :git/tag "v0.8.41"}
        org.babashka/spec.alpha {:git/url ""
                                 :git/sha "433b0778e2c32f4bb5d0b48e5a33520bee28b906"}
        zprint/zprint {:mvn/version "1.2.3"}
        babashka/fs {:mvn/version "0.2.12"}
        io.aviso/pretty {:mvn/version "0.1.36"}}
 :aliases {:test {:extra-paths ["test"]
                  :extra-deps {}}}}

borkdude12:03:15

I'll take a look

borkdude13:03:01

the issue is the grzm library, I am trying to fix it now

Daniel Gerson13:03:41

It's not blocking me at all, so don't sweat it! 🙂 I was trying to work out a different problem and thought upgrading libs would help... ended up working that out which had nothing to do with the libs (as per usual). Just reporting back here to make the borkstack better :facepunch:

borkdude13:03:38

Thanks :) Fixed in v0.1.57

nice 2
István Karaszi13:03:36

`bb prepare` in Docker

István Karaszi13:03:45

=> ERROR [6/6] RUN bb prepare                                                                                                                                                                                 0.3s 
------                                                                                                                                                                                                              
 > [6/6] RUN bb prepare:
#0 0.305 Exception in thread "main" java.lang.Exception: Couldn't find 'java'. Please set JAVA_HOME.
#0 0.306        at borkdude.deps$get_java_cmd.invokeStatic(deps.clj:252)
#0 0.306        at borkdude.deps$_main.invokeStatic(deps.clj:608)
#0 0.306        at borkdude.deps$_main.doInvoke(deps.clj:588)
#0 0.306        at clojure.lang.RestFn.applyTo(RestFn.java:137)
#0 0.306        at clojure.core$apply.invokeStatic(core.clj:667)
#0 0.306        at babashka.impl.deps$add_deps$fn__26386$fn__26387.invoke(deps.clj:101)
#0 0.306        at clojure.lang.AFn.applyToHelper(AFn.java:152)
#0 0.306        at clojure.lang.AFn.applyTo(AFn.java:144)
#0 0.306        at clojure.core$apply.invokeStatic(core.clj:667)
#0 0.306        at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1990)
#0 0.306        at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1990)
#0 0.306        at clojure.lang.RestFn.invoke(RestFn.java:425)
#0 0.306        at babashka.impl.deps$add_deps$fn__26386.invoke(deps.clj:101)
#0 0.306        at babashka.impl.deps$add_deps.invokeStatic(deps.clj:101)
#0 0.307        at babashka.main$exec$fn__30987.invoke(main.clj:865)
#0 0.307        at clojure.lang.AFn.applyToHelper(AFn.java:152)
#0 0.307        at clojure.lang.AFn.applyTo(AFn.java:144)
#0 0.307        at clojure.core$apply.invokeStatic(core.clj:667)
#0 0.307        at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1990)
#0 0.307        at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1990)
#0 0.307        at clojure.lang.RestFn.invoke(RestFn.java:425)
#0 0.307        at babashka.main$exec.invokeStatic(main.clj:817)
#0 0.307        at babashka.main$main.invokeStatic(main.clj:1139)
#0 0.307        at babashka.main$main.doInvoke(main.clj:1108)
#0 0.307        at clojure.lang.RestFn.applyTo(RestFn.java:137)
#0 0.307        at clojure.core$apply.invokeStatic(core.clj:667)
#0 0.307        at babashka.main$_main.invokeStatic(main.clj:1172)
#0 0.307        at babashka.main$_main.doInvoke(main.clj:1164)
#0 0.307        at clojure.lang.RestFn.applyTo(RestFn.java:137)
#0 0.307        at babashka.main.main(Unknown Source)

István Karaszi13:03:09

could be the case that bb prepare is not working with the official Docker image?

borkdude13:03:59

yes. the official docker image does not contain java but only the bb binary and curl

borkdude13:03:16

it's probably better to start with an image that has java or install java yourself

borkdude13:03:42

what you can also do is build an uberjar with bb uberjar and then inside the official image:

bb --classpath uberjar.jar 

borkdude13:03:02

build the uberjar in an environment where java is available and then copy it into the image

István Karaszi13:03:11

hmm, where can I find a doc about which directories should I sync over for e.g. with a muti stage docker setup?

István Karaszi13:03:23

yes, I guess uberjar could work

István Karaszi13:03:12

I also noticed a small issue with the ubuntu image, I’ll open a PR in the following days

👍 2
otfrom14:03:59

What is the equivalent of babashka/blambda(other?)/aws lambda but for google cloud?

borkdude14:03:36

There are some docs about #nbb (node.js) on google cloud https://github.com/babashka/nbb/blob/main/doc/gcloud_functions.md but I haven't tried running bb on google cloud. Perhaps @U5H74UNSF or @U07SQTAEM?

❤️ 2
borkdude14:03:04

Or maybe you can ask @U054AT6KT to build support ;P

😂 2
🚫 2
otfrom14:03:58

I'm not sure my need is burning enough yet to ask for too much help beyond existence

jackrusher15:03:11

@U0525KG62 it was easy to get nbb working in that context, as the above sample shows 🙂

❤️ 2
borkdude15:03:58

blambda implements an event-loop thingie here: https://github.com/jmglov/blambda/blob/main/resources/bootstrap.clj might not be too hard to change for gcloud, but I have no idea if it works similar to that

otfrom15:03:06

looks like Pathom might have a thing as well https://pathom3.wsscode.com/docs/tutorials/serverless-pathom-gcf/ (tho obvs that isn't nbb or babashka)

kwladyka20:03:02

https://book.babashka.org/#libraries > cheshire.core aliased as json cheshire.core works but json doesn’t. Why? This is my very first bb.edn.

{:paths []
 :deps {org.babashka/cli {:mvn/version "0.4.39"}}
 :tasks
 {sde-zzeve-com {:doc "Download all JSONs"
                 :task (let [tables ""]
                         (-> (org.httpkit.client/get foo)
                           (deref)
                           :body
                           (cheshire.core/parse-string true)
                           (println))
                         )}}}

lispyclouds20:03:25

only these fns are available without explicit imports in the context of tasks: https://github.com/babashka/babashka/blob/master/src/babashka/impl/tasks.clj#L224-L236

👍 2
lispyclouds20:03:32

the aliases mentioned are more from the context of scripting. maybe we can mention this in the book

lispyclouds20:03:46

but doesnt say that the others arent there

kwladyka20:03:47

org.httpkit.client and cheshire.core are usable. Just no with aliases.

lispyclouds20:03:07

yeah fully qualified ns should work

lispyclouds20:03:09

should work but always recommended to require

lispyclouds20:03:51

general rule is to require anything thats not clojure.core

borkdude20:03:04

the json alias is only available in the user namespace but tasks aren't executed in the user namespace

💡 4