Fork me on GitHub
#babashka
<
2021-11-12
>
borkdude11:11:48

šŸš€ 4
šŸ‘Œ 1
šŸ‘ 1
joshuamz16:11:19

This is a game changer for me at work. I'll give bb a try now for work ops.

hugod11:11:52

When registering transit handlers in a pod, we need to use the cllentā€™s pod namespace. The namespace name varies by client, which makes it difficult to dev on clojure and run in babashka. Making registration declarative seems tricky, but could the pod client pass its namespace in the ā€œdescribeā€ message?

borkdude11:11:32

Not sure if I understand the problem. The registration of transit handlers is a global effect I think.

borkdude11:11:59

We need to use the client's pod namespace?

borkdude11:11:52

The namespace varies by client, how so?

borkdude11:11:53

In the AWS pod I did this:

(def reg-transit-handlers
  (format "
(require 'babashka.pods)
(babashka.pods/add-transit-read-handler!
    \"%s\"
    identity)
(babashka.pods/add-transit-read-handler!
    \"%s\"
    (fn [s] {:class (symbol s)}))"
          throwable-key class-key))
The only assumption there is that the client has the babashka.pods namespace.

hugod11:11:05

Isnā€™t that babashka.pods.jvm in a clojure client?

borkdude11:11:26

No, you can also use babashka.pods on the JVM

borkdude11:11:52

at least, you should be able to. šŸ˜…

hugod11:11:10

I seem to get Syntax error compiling fn* at (1:1)

borkdude11:11:21

On the JVM the babashka.pods namespace forwards to babashka.pods.jvm

hugod11:11:22

and no error using .jvm

borkdude11:11:17

$ clj
Clojure 1.10.1
user=> (require 'babashka.pods)
nil

borkdude11:11:40

can you try to repro? do you have the newest pod dependency?

hugod11:11:42

oh, if I require babashka.pods then it works

borkdude11:11:04

so problem solved?

borkdude12:11:01

As a heads up, I bumped the tools-build branch of bb to use normal SCI again, I found out how to not need changes in SCI to get tools namespace compatibility https://github.com/borkdude/tools.namespace/commit/49fab463f51da056c9d2261de34982c9377239c1

borkdude12:11:20

so use that commit rather than the previous one

hugod12:11:24

ok, thanks.

borkdude12:11:51

I will see if I can port more stuff from tools.namespace to bb and after that I will port back changes from the tools build branch to master and add tests for some of those

hugod12:11:52

It seems there was an issue in the ā€œcodeā€ I was sending. It had a ā€œ^Fileā€ type hint, which seemed to work when loaded via the .jvm namespace, but not otherwise

hugod12:11:59

I was just getting a ā€œSyntax errorā€ , and wasnā€™t seeing the cause. When I hacked process-namespace to catch, print and rethrow, the issue became apparent.

borkdude12:11:54

I think you need to type hint it with java.io.File perhaps?

borkdude12:11:10

hmm, no, that can't be it I think, but worth a try

hugod12:11:41

I think cider has an issue with displaying stack traces with no source path.

borkdude12:11:00

I think it could be that since the imports are maybe not installed in a namespace created with create-ns or so

borkdude12:11:34

yep:

user=> (create-ns 'dude)
#object[clojure.lang.Namespace 0x55ea2d70 "dude"]
user=> (in-ns 'dude)
#object[clojure.lang.Namespace 0x55ea2d70 "dude"]
dude=> File
Syntax error compiling at (REPL:0:0).
Unable to resolve symbol: File in this context

borkdude15:11:00

@U0HFRSY0M Another heads up. Please use commit f4096049b42e36fa7fb9b0bcb36226b6f5567cd6from the tools namespace fork. Now all tests pass. I've cut out the dependency on java.classpath as well and no tests were failing: it seems there weren't any tests for this at all

borkdude15:11:56

$ ~/Dropbox/dev/clojure/babashka/bb test

Running tests in #{"src/test/clojure"}

Testing clojure.tools.namespace.dependency-test

Testing clojure.tools.namespace.dir-test
Temporary directory /var/folders/2m/h3cvrr1x4296p315vbk7m32c0000gp/T/t-scan-by-canonical-path5751497664913222173.tmp
Temporary directory /var/folders/2m/h3cvrr1x4296p315vbk7m32c0000gp/T/t-scan-by-canonical-path-other7953437145715633615.tmp

Testing clojure.tools.namespace.find-test
Temporary directory /var/folders/2m/h3cvrr1x4296p315vbk7m32c0000gp/T/t-find-clj-and-cljc-files2393781066831749619.tmp
Temporary directory /var/folders/2m/h3cvrr1x4296p315vbk7m32c0000gp/T/t-find-cljs-and-cljc-files3311774040746548801.tmp

Testing clojure.tools.namespace.move-test
Temporary directory /var/folders/2m/h3cvrr1x4296p315vbk7m32c0000gp/T/tools-namespace-t-move-ns4313522759469419488.tmp

Testing clojure.tools.namespace.parse-test

Ran 23 tests containing 58 assertions.
0 failures, 0 errors.

borkdude15:11:11

it's using its own tools namespace to run the cognitect test runner ;)

hugod15:11:57

Yay! Iā€™ll update these later. I couldnā€™t get by tools.build fork running with the cognitect-runner in babaska. When I tried passing arguments :task (cognitect.test-runner/-main "-n" "test-.*") I got ā€œCould not resolve symbol: cognitect.test-runner/-mainā€. Works as a plain symbol, but then it doesnā€™t find the tests.

borkdude15:11:04

I now moved the repo here. Check this example. https://github.com/babashka/tools.namespace/blob/babashka/bb.edn

šŸ‘ 1
borkdude15:11:18

It's only compatible with bb in the tools-build branch, since there are some missing classes, notably java.io.Closeable.

borkdude10:11:22

@U0HFRSY0M I merged the tools.build branch to bb master now

borkdude10:11:07

I forked tools.build here: https://github.com/babashka/tools.bbuild The default branch is babashka. Please PR your changes so far against this branch.

borkdude10:11:32

And then we can continue there. I gave you admin rights.

borkdude10:11:57

Let's keep the master branch untouched

borkdude11:11:54

@U0HFRSY0M Should we release a new version of bb or do you expect more changes coming?

borkdude11:11:59

If you are more comfortable with maintaining tools.bbuild in your own personal repo that'd be also fine with me, please just say so.

hugod12:11:16

Iā€™m fine with having the tools.build fork under babashka

hugod12:11:45

Iā€™m not expecting any more changes to bb.