This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-05
Channels
- # announcements (15)
- # aws (7)
- # babashka (105)
- # beginners (35)
- # biff (5)
- # calva (48)
- # cider (5)
- # clj-kondo (25)
- # cljdoc (14)
- # clojure (84)
- # clojure-czech (2)
- # clojure-dev (6)
- # clojure-europe (58)
- # clojure-nl (6)
- # clojure-norway (19)
- # clojure-portugal (2)
- # clojure-uk (5)
- # clojurescript (23)
- # cloverage (5)
- # code-reviews (5)
- # conjure (28)
- # data-science (1)
- # datomic (53)
- # events (6)
- # exercism (7)
- # fulcro (16)
- # graalvm-mobile (2)
- # honeysql (29)
- # improve-getting-started (2)
- # kaocha (32)
- # lambdaisland (2)
- # lsp (29)
- # malli (3)
- # overtone (1)
- # pedestal (8)
- # polylith (3)
- # portal (6)
- # quil (2)
- # rdf (15)
- # releases (2)
- # rewrite-clj (14)
- # sci (9)
- # shadow-cljs (7)
- # specter (5)
- # sql (5)
- # xtdb (38)
Cli-matic example with bb: https://raw.githubusercontent.com/l3nz/cli-matic/master/examples/bb/toycalc.bb
Some random weirdness that I’m trying to get a handle on…. I have an Rscript that reads a CSV and attaches it like so:
param <- read.csv("params.csv")
attach(param)
This works fine when called from bash. The weirdness is that the attach fails when shelling out to the same Rscript from babashka. The read.csv call works fine there, but the attach doesn’t.There are variants where I pass the current directory to Rscript, but in this variant I just set it to the correct dir in adjcox.R.
And why would this work with bash but not with sh? Maybe you could try:
(babashka.process/sh ["Rscript" ...])
which is similarI wondered about babashka.process, but I could not see the benefit since the R code is self-contained. It reads its own files and writes it’s own results to file.
Maybe you can log the current directory, etc from the Rscript, to debug what's different.
I would be able to take a closer look if you could make a repro in a github repo I could check out
Yes - the err: output is exactly what you would expect from R when it sees NULL instead of the correct value for one f the header variables.
(babashka.process/sh ["Rscript" "resources/r_model_tests/kidney/waiting/adjcox.R"])
generates the same issue:
{:proc #object[java.lang.ProcessImpl 0x5eabdbcd "Process[pid=2775, exitValue=1]"], :exit 1, :in #object[java.lang.ProcessImpl$ProcessPipeOutputStream 0x3d98c7c6 "[email protected]"], :out "", :err "Error in adjcox(cent = tests$cent[i], sex = tests$sex[i], eth = tests$eth[i], : \n object 'tx_sex_m' not found\nExecution halted\n", :prev nil, :cmd ["Rscript" "resources/r_model_tests/kidney/waiting/adjcox.R"]}
If you want to make a ready to go repro I can clone and execute locally, including a csv file, and instructions how to install Rscript, I can take a look. No ideas at this point.
Well that was interesting. The issue only appears in the Calva babashka repl. In other contexts it’s fine. Gist is here: https://gist.github.com/gmp26/b859872eeb53c753ece08c7e632f7b02
As @U02N27RK69K hinted, it may also have to do something with tty-ish
just merged https://github.com/tatut/clj-chrome-devtools/pull/32 and clj-chrome-devtools now works with babashka (haven't tested very extensively)
The first trouble I have with the README and get going quickly is that I can't see where connect
is coming from
(require '[clj-chrome-devtools.core :as core]
'[clj-chrome-devtools.automation :as auto])
(def a (auto/create-automation (core/connect)))
(auto/to a "")
(auto/print-pdf a "clojure.pdf"
{:print-background true
:paper-width 8.3
:paper-height 11.7})
the connect actually needs chrome to be already up, there's a launcher ns as well which will launch a chrome instance
Now just relaunched with the port, it worked!
22: (throw (ex-info (str "Error in command " method ": " (:message error))
^--- Error in command Page.printToPDF: Printing is not available
23: {:request payload
For the bb script example, you can do this without the classpath hassle:
(ns devtools
(:require [babashka.deps :as deps]))
(deps/add-deps
'{:deps {tatut/devtools {:git/url ""
:git/sha "62a8aba789bbda6d954d17f2dc6f92dd74ec8619"}
org.babashka/spec.alpha {:git/url ""
:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}})
(require '[clj-chrome-devtools.automation :as auto]
'[clj-chrome-devtools.core :as core])
(def a (auto/create-automation (core/connect)))
(auto/to a "")
I don't know what kind of protocol firefox has... chrome has the CDP protocol that is described as json and you can easily autogenerate the functions
I started this bb support because I had an idea to use AWS Lambda custom runtime to have a lambda that takes in HTML and returns back PDF
for sure! For AWS Lambda #nbb could also be an interesting option: https://github.com/babashka/nbb/blob/main/doc/aws_lambda.md There are many pdf things for Node.js as well. But I don't want to distract you too much from this project, since I could see it being very useful for browser testing in bb + JVM
As for lambda: if you could move clojure.spec aside too, then this code would load even faster.
I might bring clojure.spec.alpha as a built-in in the future, then that becomes irrelevant for startup time, but right now it has to load a bunch of spec code at startup
well, it might not be absolutely necessary, but all the autogenerated commands have fdef specs
I could imagine moving the specs to auxiliary namespaces and having some switch to skip loading them...
If your program relies on spec, then that's good, keep it! But often spec is loaded not for any good reason. Not in this case.
@U11SJ6Q0K Just spitballing here, but would it help in any way if a browser were controllable through nREPL: https://twitter.com/borkdude/status/1511456422667735042/photo/1 I feel there could be some kind of synergy between the debug protocol and the thing I'm currently working on
I noticed when trying firefox on the debug protocol, that after:
(def a (auto/create-automation (core/connect)))
(auto/to a "")
it did go to http://clojure.org, but then the script was waiting and the next expression wasn't evaluatedRunning into what seems like a regression running main from a jar in 0.8.0 (works in 0.7.8 and prior) that at first glance doesn't appear to be related to my changes in 0.8.0 😆: https://gist.github.com/cap10morgan/65e0c9bfabdb2b161ee2cc7617a5d7ab anything jump out at you there @borkdude? or anything else you'd like me to provide?
what makes you think it's related to arg parsing, out of curiosity?
ah ok
darn, thought you had noticed something I hadn't 😉
haven't been able to repro in a more minimal example yet... but I'll keep working on it
hmm... don't think I've done that before. is that documented somewhere?
to clarify, I've done git bisect
, but haven't run bb w/ jvm (is that bb clojure
? not sure how to do that w/ an arbitrary git sha)
@U06FS3DLH I mean, just the process of choosing a git sha, checking if the error happens there, etc.
ah, I see. I'll give that a try. thanks!
how do you deal with the git submodules when you do that? according to jira they're not supported in deps.edn git deps
:thumbsup: makes sense
ok false alarm. it was a problem in my code after all. just strange that it behaved so differently in 0.7.8. it's possible it was a combination of things I hadn't tested before. anyway, I don't think babashka is to blame either way.