Fork me on GitHub
#xtdb
<
2020-12-31
>
roelof21:12:11

hmm, im trying the crux tutorial

roelof21:12:23

but get stuck here :

(easy-ingest node (crux/submit-tx
 node
 [[:crux.tx/put (1)
   {:crux.db/id :consumer/RJ29sUU
    :consumer-id :RJ29sUU
    :first-name "Jay"
    :last-name "Rose"
    :cover? true
    :cover-type :Full}
   #inst "2113-12-03" ;; Valid time start
   #inst "2114-12-03"] ;; Valid time end

  [:crux.tx/put (2)
   {:crux.db/id :consumer/RJ29sUU
    :consumer-id :RJ29sUU
    :first-name "Jay"
    :last-name "Rose"
    :cover? true
    :cover-type :Full}
   #inst "2112-12-03"
   #inst "2113-12-03"]

  [:crux.tx/put (3)
   {:crux.db/id :consumer/RJ29sUU
    :consumer-id :RJ29sUU
    :first-name "Jay"
    :last-name "Rose"
    :cover? false}
   #inst "2112-06-03"
   #inst "2112-12-02"]

  [:crux.tx/put (4)
   {:crux.db/id :consumer/RJ29sUU
    :consumer-id :RJ29sUU
    :first-name "Jay"
    :last-name "Rose"
    :cover? true
    :cover-type :Promotional}
   #inst "2111-06-03"
   #inst "2112-06-03"]]))

roelof21:12:48

error message :

; Execution error (ClassCastException) at practicalli.earth/eval36748 (form-init8055691961700094689.clj:29).
; class java.lang.Long cannot be cast to class clojure.lang.IFn (java.lang.Long is in module java.base of loader 'bootstrap'; clojure.lang.IFn is in unnamed module of loader 'app')

roelof21:12:52

; Execution error (ClassCastException) at practicalli.earth/eval36748 (form-init8055691961700094689.clj:29). ; class java.lang.Long cannot be cast to class clojure.lang.IFn (java.lang.Long is in module java.base of loader 'bootstrap'; clojure.lang.IFn is in unnamed module of loader 'app')

Alex Miller (Clojure team)21:12:44

(1) is invoking a number as a function

Johanna21:12:30

The numbers should be commented out - they're there as a reference to the text below

roelof22:12:03

@j.antonelli712 thanks, I will try it but I cannot find that remark/comment

roelof22:12:11

Still no luck

roelof22:12:15

[:crux.tx/put '(3)
   {:crux.db/id :consumer/RJ29sUU
    :consumer-id :RJ29sUU
    :first-name "Jay"
    :last-name "Rose"
    :cover? false}
   #inst "2112-06-03"
   #inst "2112-12-02"]

euccastro22:12:37

try prepending #_ or ;, or just deleting the (1) etc.

👍 3
Lu22:12:15

Hi @roelof! What Johanna was saying is that you should just delete those numbers in parenthesis because they are only used in the documentation as ‘footnote’ references :)

euccastro22:12:40

quote doesn't comment out, it just prevents evaluation. but those are not supposed to be there at all

👍 3
roelof22:12:54

chips. still errrors

; Execution error (ExceptionInfo) at crux.tx.conform/check-doc (conform.clj:16).
; invalid doc

roelof22:12:20

(easy-ingest node (crux/submit-tx
 node
 [[:crux.tx/put
                 {:crux.db/id :consumer/RJ29sUU
                  :consumer-id :RJ29sUU
                  :first-name "Jay"
                  :last-name "Rose"
                  :cover? true
                  :cover-type :Full}
   #inst "2113-12-03" ;; Valid time start
   #inst "2114-12-03"] ;; Valid time end

  [:crux.tx/put 
                 {:crux.db/id :consumer/RJ29sUU
                  :consumer-id :RJ29sUU
                  :first-name "Jay"
                  :last-name "Rose"
                  :cover? true
                  :cover-type :Full}
   #inst "2112-12-03"
   #inst "2113-12-03"]

  [:crux.tx/put 
                 {:crux.db/id :consumer/RJ29sUU
                  :consumer-id :RJ29sUU
                  :first-name "Jay"
                  :last-name "Rose"
                  :cover? false}
   #inst "2112-06-03"
   #inst "2112-12-02"]

  [:crux.tx/put 
                 {:crux.db/id :consumer/RJ29sUU
                  :consumer-id :RJ29sUU
                  :first-name "Jay"
                  :last-name "Rose"
                  :cover? true
                  :cover-type :Promotional}
   #inst "2111-06-03"
   #inst "2112-06-03"]]))

Johanna23:12:30

I don't think you need the easy-ingest here?

roelof23:12:45

you are right

roelof23:12:00

the data is finnaly in the "database"

Johanna23:12:16

Awesome 🎉

roelof23:12:00

wonder one thing that I think none of the tutorials tell me

roelof23:12:29

is there a way I can see all the badges in my manifest

roelof23:12:45

and before I forget Happy new year from the Netherlands

🙂 6
🎉 6
roelof00:01:28

and this one does not give output back in my calva

roelof00:01:36

(ns practicalli.earth
  (:require [crux.api :as crux]))


(def node (crux/start-node {}))

(defn easy-ingest
  "Uses Crux put transaction to add a vector of documents to a specified
  node"
  [node docs]
  (crux/submit-tx node (mapv (fn [doc] [:crux.tx/put doc]) docs)))

(crux/submit-tx
 node [[:crux.tx/put {:crux.db/id :kaarlang/clients
                      :clients [:encompass-trade]}
        #inst "2110-01-01T09"
        #inst "2111-01-01T09"]

       [:crux.tx/put {:crux.db/id :kaarlang/clients
                      :clients [:encompass-trade :blue-energy]}
        #inst "2111-01-01T09"
        #inst "2113-01-01T09"]

       [:crux.tx/put {:crux.db/id :kaarlang/clients
                      :clients [:blue-energy]}
        #inst "2113-01-01T09"
        #inst "2114-01-01T09"]

       [:crux.tx/put {:crux.db/id :kaarlang/clients
                      :clients [:blue-energy :gold-harmony :tombaugh-resources]}
        #inst "2114-01-01T09"
        #inst "2115-01-01T09"]])

(crux/entity-history
 (crux/db node #inst "2116-01-01T09")
 :kaarlang/clients
 :desc
 {:with-docs? true})

Johanna12:01:53

Happy new year to you too!

Johanna12:01:55

That's interesting, the code above works fine in my emacs repl:

[{:crux.tx/tx-time #inst "2021-01-01T12:48:03.436-00:00",
  :crux.tx/tx-id 0,
  :crux.db/valid-time #inst "2115-01-01T09:00:00.000-00:00",
  :crux.db/content-hash #crux/id "0000000000000000000000000000000000000000",
  :crux.db/doc nil}
 {:crux.tx/tx-time #inst "2021-01-01T12:48:03.436-00:00",
  :crux.tx/tx-id 0,
  :crux.db/valid-time #inst "2114-01-01T09:00:00.000-00:00",
  :crux.db/content-hash #crux/id "d4bca6c78409d9d40ee42319a8aec32bffad9030",
  :crux.db/doc
  {:crux.db/id :kaarlang/clients,
   :clients [:blue-energy :gold-harmony :tombaugh-resources]}}
 {:crux.tx/tx-time #inst "2021-01-01T12:48:03.436-00:00",
  :crux.tx/tx-id 0,
  :crux.db/valid-time #inst "2113-01-01T09:00:00.000-00:00",
  :crux.db/content-hash #crux/id "000e5b775b55d06f0bddc77d736184284aa1e4e9",
  :crux.db/doc {:crux.db/id :kaarlang/clients, :clients [:blue-energy]}}
 {:crux.tx/tx-time #inst "2021-01-01T12:48:03.436-00:00",
  :crux.tx/tx-id 0,
  :crux.db/valid-time #inst "2111-01-01T09:00:00.000-00:00",
  :crux.db/content-hash #crux/id "cd71551fe21219db59067ce7483370fdebaae8b0",
  :crux.db/doc
  {:crux.db/id :kaarlang/clients, :clients [:encompass-trade :blue-energy]}}
 {:crux.tx/tx-time #inst "2021-01-01T12:48:03.436-00:00",
  :crux.tx/tx-id 0,
  :crux.db/valid-time #inst "2110-01-01T09:00:00.000-00:00",
  :crux.db/content-hash #crux/id "5ec42ea653288e01e1a9d7d2068b4658416177e0",
  :crux.db/doc {:crux.db/id :kaarlang/clients, :clients [:encompass-trade]}}]

roelof13:01:27

on my calva repl I the prompt disappear and I do not see it back

roelof13:01:06

yep, the reading does work

roelof13:01:39

but this code seems to be hanging

(crux/entity-history
 (crux/db node #inst "2116-01-01T09")
 :kaarlang/clients
 :desc
 {:with-docs? true})

roelof13:01:50

or can this be the culprit

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.

roelof13:01:58

any idea why I do not see the data or how I can see what is going wrong?

Johanna14:01:12

The code looks fine to me, so perhaps you're right and that error message is the culprit? Have you had a look at the URL to see if it gives a hint as to how to solve it?

roelof14:01:37

yep but found nothing

roelof14:01:44

did some experiments

roelof14:01:04

and when I delete the desc part I see this error message :

; Execution error (IllegalArgumentException) at crux.history-options/<-sort-order (history_options.clj:5).
; No matching clause: {:with-docs? true}

Johanna14:01:42

You need the sort order there, try deleting the with-docs map instead

Johanna14:01:20

experiments are good

roelof14:01:33

yep, then I see this output

roelof14:01:27

[{:crux.tx/tx-time #inst "2021-01-01T14:06:03.679-00:00",
  :crux.tx/tx-id 0,
  :crux.db/valid-time #inst "2115-01-01T09:00:00.000-00:00",
  :crux.db/content-hash #crux/id "0000000000000000000000000000000000000000"}
 {:crux.tx/tx-time #inst "2021-01-01T14:06:51.917-00:00",
  :crux.tx/tx-id 1,
  :crux.db/valid-time #inst "2114-01-01T09:00:00.000-00:00",
  :crux.db/content-hash #crux/id "d4bca6c78409d9d40ee42319a8aec32bffad9030"}
 {:crux.tx/tx-time #inst "2021-01-01T14:06:51.917-00:00",
  :crux.tx/tx-id 1,
  :crux.db/valid-time #inst "2113-01-01T09:00:00.000-00:00",
  :crux.db/content-hash #crux/id "000e5b775b55d06f0bddc77d736184284aa1e4e9"}
 {:crux.tx/tx-time #inst "2021-01-01T14:06:51.917-00:00",
  :crux.tx/tx-id 1,
  :crux.db/valid-time #inst "2111-01-01T09:00:00.000-00:00",
  :crux.db/content-hash #crux/id "cd71551fe21219db59067ce7483370fdebaae8b0"}
 {:crux.tx/tx-time #inst "2021-01-01T14:06:51.917-00:00",
  :crux.tx/tx-id 1,
  :crux.db/valid-time #inst "2110-01-01T09:00:00.000-00:00",
  :crux.db/content-hash #crux/id "5ec42ea653288e01e1a9d7d2068b4658416177e0"}]
clj::practicalli.earth=> 

roelof14:01:03

but if I want to do the same again I first have to add everything to the "database"

roelof14:01:36

yep, and if I add the with-docs back it seems to hang

roelof14:01:45

without any error messages

roelof14:01:12

but I do not see the output which is expected from the tutorial 😞

Johanna14:01:20

We are storing the data in memory here, every time you restart your repl you'll have to put it back in. If you've not intentionally restarted the repl it might be a hint as to where the problem lies. I'm not familiar with vs code but let me see if I can replicate there otherwise I can't be of much help to you (my emacs is happily playing nicely)

roelof14:01:47

I did not when experimenting witht the with-docs back

Johanna14:01:25

Unfortunately it's working fine in my vs code too, so it could be an issue with your setup:

roelof14:01:26

pity, dd you work with the calva extension ?

roelof14:01:48

and thanks for helping me

roelof14:01:08

right now no idea why I did not work on my side

Johanna14:01:22

Yeah that's with calva

roelof14:01:25

the rest of the tutorials worked fine

roelof14:01:34

and also only these dependencies:

roelof14:01:55

:dependencies [[org.clojure/clojure "1.10.0"]                  [juxt/crux-core "RELEASE"]]

roelof14:01:46

oke, and I copied it from the blog

Johanna14:01:44

The blog should be fine too, this is the code use in the blog with some extra fluff I was playing with. It might be useful to debug for you - it should be up to date.

Johanna14:01:03

I've just changed all the start-nodes there

roelof14:01:37

oke, so the code can be found on the github

Johanna14:01:41

Another useful sanity check is the nextJournal versions https://nextjournal.com/crux-tutorial

Johanna14:01:25

You can edit / remix the posts and run each tutorial page, it spins up some clojure and actually runs so it's useful to know if it's a bug in the tutorial or something else

Johanna14:01:09

> oke, so the code can be found on the github Unofficially. That one might not be as up to date at all times because I'm lazy with pushing local changes

roelof14:01:26

I copied the code from github

roelof14:01:01

he, I see something wierd

roelof14:01:14

when reading the data I see this :

clj꞉tutorials.crux.jupiter꞉> 
#:crux.tx{:tx-id 0, :tx-time #inst "2021-01-01T14:44:27.567-00:00"}

roelof14:01:34

and it hangs again on the asking part

roelof14:01:06

this will be very difficult to figure out why I think

roelof14:01:14

I have no ideas left

roelof14:01:47

your tutorials github repo I cannot run

roelof14:01:00

you use there clojure cli

roelof14:01:06

and I use lein

roelof14:01:18

so I get this error message

roelof14:01:26

/bin/sh: 1: clojure: not found

roelof14:01:35

clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/cider-nrepl {:mvn/version "0.25.5"} clj-kondo/clj-kondo {:mvn/version "2020.04.05"}}}'  -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
/bin/sh: 1: clojure: not found
Jack-in process exited. Status: 127

roelof15:01:06

or I see this :

roelof15:01:20

sorry I cannot be of more help

roelof15:01:44

I choose clojure clj . maybe I have to choose another one ?

roelof15:01:35

nope, got your repo working

roelof15:01:45

and also there it hangs on the code

Johanna15:01:56

Ah well done. That's a shame though - same error?

roelof15:01:02

just a waiting cursor forever

roelof15:01:06

wierd, the rest of the tutorial works without a problem

roelof15:01:24

only that piece not 😞

roelof15:01:20

the only thing Ic an try is to delete my wsl2 box and only try with clojure cli tools

roelof15:01:23

now I have lein and clojure cli both installed

roelof15:01:49

do you work with Mac or Linux ?

roelof15:01:57

I work from linux (wsl2)

Johanna17:01:33

I'm on linux

roelof17:01:28

still then wonder why that part does not work

roelof17:01:40

I asked someone else on Linux and also on him it works

roelof17:01:18

is there another way to debug this and see why it hangs on my computer ?

Steven Deobald23:12:55

@taylor.jeremydavid Is the crux tutorial on GitHub? It might be good to comment out those “footnotes” directly in the code so new folks can copy/paste… or it’s likely this won’t be the first time this channel see this question. 😉

roelof23:12:52

nope, but I found it here

roelof23:12:56

but even if I delete those numbers the code fails with a bad document

Johanna23:12:47

I think you're right. Unfortunately the formatting on the blogs doesn't make it clear either, sorry for the confusion. I'll get it fixed :face_with_cowboy_hat:

🙏 6
dominicm23:12:34

The asciidoc renderer needs configuring to make those unselectable. Worked on the old blog / works on github.