Fork me on GitHub
#babashka
<
2022-07-05
>
pieterbreed10:07:00

I have a question about awyeah-api. The README specifies a specific git hash to use for the dependency on it and a specific git-hash for the dependency on org.babashka/spec.alpha. Is the idea I use those specific versions only forever? Or am I supposed to take the git-hash from current master or is there some other strategy I must use?

borkdude10:07:50

@U2G3G2S6S Yes, just take the SHAs from both master branches and upgrade when necessary

pieterbreed13:07:58

Is prepare supposed to download pods? I'm seeing some inconsistencies which I don't understand. (I'm posting shell output in the thread.)

pieterbreed13:07:07

% ../target/layer/bin/bb version
babashka v0.8.158-SNAPSHOT

% ../target/layer/bin/bb --config ./bb.edn prepare

% stat $BABASHKA_PODS_DIR       
stat: cannot statx '/home/pieter/.../.pods-dir': No such file or directory

% ../target/layer/bin/bb --config ./bb.edn -e "(require '[babashka.pods]) (babashka.pods/load-pod 'tzzh/mail \"0.0.2\")"  
Downloading pod tzzh/mail (0.0.2)
Successfully installed pod tzzh/mail (0.0.2)
#:pod{:id "pod.tzzh.mail"}

% cat bb.edn
{:paths ["src"]
 :deps  {}
 :pods  {tzzh/mail {:version "0.0.2"}}}

% stat $BABASHKA_PODS_DIR                                                                                               
  File: /home/pieter/.../.pods-dir
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 10302h/66306d   Inode: 10485967    Links: 3
Access: (0775/drwxrwxr-x)  Uid: ( 1000/  pieter)   Gid: ( 1000/  pieter)
Access: 2022-07-05 15:01:45.531117414 +0200
Modify: 2022-07-05 15:01:45.531117414 +0200
Change: 2022-07-05 15:01:45.531117414 +0200
 Birth: 2022-07-05 15:01:45.531117414 +0200

borkdude13:07:43

It should, yes:

prepare                       Download deps & pods defined in bb.edn and cache their metadata.

borkdude13:07:35

I'm not exactly sure what I'm looking at. Can you explain?

pieterbreed13:07:49

I have a bb.edn that contains a reference to a pod I want to use. I'm in the same directory as this file. I set BABASHKA_PODS_DIR and run prepare but it does not download anything. If I eval (load-pod ...) then the download happens, and it's using the correct BABASHKA_PODS_DIR.

pieterbreed13:07:57

so the prepare does not trigger the downloading of the pod

borkdude13:07:33

Can you just try:

bb -e '(+ 1 2 3)'
This should have the same effect as prepare

pieterbreed13:07:11

% rm -rf $BABASKHA_PODS_DIR

% ../target/layer/bin/bb --config ./bb.edn -e "(+ 1 2 3)" 
6

% ../target/layer/bin/bb --config ./bb.edn -e "(require '[babashka.pods]) (babashka.pods/load-pod 'tzzh/mail \"0.0.2\")"
Downloading pod tzzh/mail (0.0.2)
Successfully installed pod tzzh/mail (0.0.2)
#:pod{:id "pod.tzzh.mail"}

borkdude13:07:43

so that did work?

pieterbreed13:07:12

no, it does not download the pod in the bb.edn if I just eval a simple expression

pieterbreed13:07:08

I feel like such an idiot. I'm sorry... the mistake was on my side. There was an extra } in the bb.edn file, which messed things up

pieterbreed13:07:24

I was like it's almost like it's ignoring the bb.edn file and that was because the file was invalid.

pieterbreed13:07:32

Thanks for looking, sorry for wasting space.

lispyclouds13:07:20

extra } is the clojure equivalent of the extra ; problem in other languages i think :rolling_on_the_floor_laughing:

pieterbreed13:07:54

esp when I' just quickly using nano to edit, rather than something with smartparens...

lispyclouds13:07:28

humans balancing parens is just inhuman

1
1
cap10morgan14:07:11

might be nice to spit out a warning in this case like: "I found a file named bb.edn but I couldn't use it because X"?

borkdude14:07:50

Yeah, good idea. So what actually happened, the config file got ignored silently?

pieterbreed14:07:31

yes, the bb.edn file had unbalanced brackets of many kinds and if it showed a warning about that, I might have not bothered anybody here about it.

sheluchin15:07:08

https://clojurians.slack.com/archives/C1Q164V29/p1657033467025239 from #sql... Has anyone used babashka along with Postgres COPY FROM to populate their DB from EDN? One suggestion was to convert the EDN to CSV using bb with data.csv first. Just wondering if someone has experience at this intersection of Postgres + jdbc and potentially babashka as the FROM PROGRAM.

borkdude15:07:14

You could also maybe use bb + honeysql to produce sql statements

sheluchin15:07:48

I have been using HoneySQL in my program. Even with prepared statements and :auto-commit false, inserting a large number of records is pretty slow. I'm hoping COPY FROM can be of help, but it doesn't look like it can be https://github.com/seancorfield/next-jdbc/issues/136#issuecomment-663383750, so I don't think HoneySQL has much of a role here. But I haven't been using next.jdbc for very long and I'd be happy to learn that I'm mistaken.

jgdavey16:07:44

This may or may not suit your use case, but I have a (admittedly incomplete) library that uses Clojure protocols + jdbc connection to do postgres COPY for bulk import: https://github.com/jgdavey/clj-pgcopy

🙏 2
jgdavey16:07:09

I doubt it works on bb, but I’ve also never tested

sheluchin16:07:01

Thanks @U0AUQ25KP! I'll try that out and read through the source.