nextjournal

cstby 2021-10-12T03:42:11.171200Z

The beholder file watcher seems to always render the file that changed. If I wanted to watch several files but only render the same one, how might I do that?

mkvlr 2021-10-12T08:22:17.174Z

@carl.steib this is what clerk/file-event does (the str/replace being optional, show! takes an absolute path just fine):

(defn file-event [{:keys [type path]}]
  (when (and (contains? #{:modify :create} type)
             (or (str/ends-with? path ".clj")
                 (str/ends-with? path ".cljc")))

    (binding [*ns* (find-ns 'user)]
      (nextjournal.clerk/show! (str/replace (str path) (str (fs/canonicalize ".") fs/file-separator) "")))))
Should be pretty easy to do something similar but calling show! with the same arg, when one file changed that might be a dep of the file you want to show. Weโ€™re also thinking about enabling this sort of file pinning in Clerk itself but would be great to know more about what exactly it is folks need there.

๐Ÿ‘ 1
cstby 2021-10-13T18:23:40.214900Z

Right now I'm mostly just exploring. I'm thinking that I'd likely want helper functions in a different namespace.

mkvlr 2021-10-12T10:18:22.175400Z

Just released https://clojars.org/io.github.nextjournal/clerk/versions/0.1.176 with improved windows support https://nextjournal.com/mk/clerk-preview#0.1.176. Thanks @ales.najmann for the report and @borkdude for help testing!

โค๏ธ 1
littleli 2021-10-12T18:10:44.201400Z

Nice! Thank you. Works great ๐Ÿ™‚

1
mkvlr 2021-10-12T11:45:36.178700Z

@carsten.behring when you have time, it would be great it you could put together a repro for the browser crash you're seeing. I haven't been able to reproduce this yet with tablecloth / http://tech.ml.

2021-10-12T12:04:12.178900Z

yes, I'll do.

2021-10-12T12:04:37.179400Z

it happens with large files, so need to find one online.

2021-10-12T12:12:21.179700Z

@mkvlr It's Chrome only.

2021-10-12T12:12:26.179900Z

Firefox works

2021-10-12T12:13:18.180300Z

I have "lost" this is the discussion.

2021-10-12T13:18:57.182300Z

I mean, would you expect that a map of 300 MB on disk gets "shortened" in the browser successfully ? Do I assume correctly that this map would be handled by clojurescript running in the browser ?

mkvlr 2021-10-12T13:22:43.183800Z

yes, I would expect clerk to only show the first 20 elements and allow you to lazy load more on demand.

mkvlr 2021-10-12T13:25:13.185800Z

can you run those and tell me if they work? Curious if you also see the faulty behavior on eg (range)

mkvlr 2021-10-12T13:26:10.187100Z

Clerk should only send a tiny preview of the 300mb object to the browser, never the whole thing

2021-10-12T13:26:45.187300Z

(range) works fine

2021-10-12T13:27:46.187500Z

How does it make the "tiny preview" on an arbitrary object ?

2021-10-12T13:31:22.187700Z

I start to see the special think about my data.

2021-10-12T13:31:32.187900Z

text columns

2021-10-12T13:32:00.188100Z

so 500 000 times a "medium size text".

2021-10-12T13:32:35.188300Z

the medium size text is too short to get truncated, but we have lots of those.

mkvlr 2021-10-12T13:34:54.189400Z

still should never serve all of them to the browser, just the first 20

2021-10-12T13:37:18.190700Z

This starts to make issues:

(repeat 10000 (apply str (repeat 1000 "a")))

borkdude 2021-10-12T13:37:48.190900Z

oh probably haven't implemented a protocol for some of the specific types

mkvlr 2021-10-12T13:42:00.191500Z

@carsten.behring ok great, will dig into this

mkvlr 2021-10-12T13:42:26.191700Z

@borkdude Iโ€™m afraid itโ€™s entirely my fault and itโ€™s all in plain clojure causing troubles

borkdude 2021-10-12T13:42:57.191900Z

I meant, it might be such an issue, not sure actually how you implemented it :)

mkvlr 2021-10-12T13:46:00.192100Z

@carsten.behring not running into an issue here on the first try though

2021-10-12T13:46:02.192500Z

I remember this case from Cider, as I tried to configure some "logic", when to cut of the output. The seq of long strings is a difficult case, and it does happen in real life. Text columns of datasets.

mkvlr 2021-10-12T13:46:43.192700Z

as you can see Clerk only gets the first 20 elements (and a preview of 80 chars for each)

mkvlr 2021-10-12T13:47:28.192900Z

for you it crashes the browser?

mkvlr 2021-10-12T13:47:37.193100Z

I see thereโ€™s an issue with lazy loading in this case though

mkvlr 2021-10-12T13:47:48.193300Z

gtg now, will look more into this later

2021-10-12T13:57:39.193500Z

Whats about that:

(repeat 1000
        (zipmap
         (range)
         (apply vector (repeat 100 (apply str (repeat 100 "a"))))))

2021-10-12T13:58:05.193700Z

so a 2d table of 10000 strings of length 100

2021-10-12T13:58:14.193900Z

for me it does not render

2021-10-12T14:00:38.194100Z

on firefox.

2021-10-12T14:00:53.194300Z

just tried opera and it works....

2021-10-12T14:07:39.194500Z

This file and TMD fails always: https://www.dropbox.com/s/qearl4fh0c9eirr/Reviews.csv?dl=0

2021-10-12T14:08:20.194800Z

with this code:

(ns prepare-data

  (:require
   [tablecloth.api :as tc]
   [tech.v3.dataset.impl.dataset :refer [dataset?]]
   [tech.v3.libs.fastexcel]
   [nextjournal.clerk :as clerk]
   [nextjournal.clerk.viewer :as v]
   [camel-snake-kebab.core :as csk]))

(def raw-data-2
  (tc/dataset "/home/carsten/Dropbox/sources/scicloj-data-science-handbook/Reviews.csv"
                {:key-fn csk/->kebab-case-keyword}))
(tc/shape raw-data-2)

(tc/column-names raw-data-2)

2021-10-12T14:11:12.195Z

clojure is fast on reading it: Clerk evaluated 'notebooks/prepare_data.clj' in 5914.30252ms.

2021-10-12T14:13:20.195200Z

But the browser window stays blank forever.

2021-10-12T14:28:46.195400Z

I think TMD has as well some other characteristics and maybe @chris441 can talk about it in detail. While working in the repl, a TMD dataset hardly ever gets "fully realized" So maybe our impression that we can "easely work with it in the repl", is mainly thanks to that. And the "rendering" break that by "realizing it" in some form, and teh teh "cutting" off does not really help to keep performance acceptable. Not sure, if this applies as well to the "Pure loading" of a dataset as I do above.

2021-10-12T14:31:06.195600Z

The large dataset above prints in the repl instantently and even nicely (my pasting here hides this ...) prepare-data> raw-data-2 ;; => /home/carsten/Dropbox/sources/scicloj-data-science-handbook/Reviews.csv [568454 10]: | :id | :product-id | :user-id | :profile-name | :helpfulness-numerator | :helpfulness-denominator | :score | :time | :summary | :text | |----:|-------------|----------------|---------------------------------|-----------------------:|-------------------------:|-------:|-----------:|--------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 | B001E4KFG0 | A3SGXH7AUHU8GW | delmartian | 1 | 1 | 5 | 1303862400 | Good Quality Dog Food | I have bought several of the Vitality canned dog food products and have found them all to be of good quality. The product looks more like a stew than a processed meat and it smells better. My Labrador is finicky and she appreciates this product better than most. | | 2 | B00813GRG4 | A1D87F6ZCVE5NK | dll pa | 0 | 0 | 1 | 1346976000 | Not as Advertised | Product arrived labeled as Jumbo Salted Peanuts...the peanuts were actually small sized unsalted. Not sure if this was an error or if the vendor intended to represent the product as "Jumbo". | | 3 | B000LQOCH0 | ABXLMWJIXXAIN | Nat;; => alia Corres "Natalia Corres" | 1 | 1 | 4 | 1219017600 | "Delight" says it all | This is a confection that has been around a few centuries. It is a light, pillowy citrus gelatin with nuts - in this case Filberts. And it is cut into tiny squares and then liberally coated with powdered sugar. And it is a tiny mouthful of heaven. Not too chewy, and very flavorful. I highly recommend this yummy treat. If you are familiar with the story of C.S. Lewis' "The Lion, The Witch, and The Wardrobe" - this is the treat that seduces Edmund into selling out his Brother and Sisters to the Witch. | | 4 | B000UA0QIQ | A395BORC6FGVXV | Karl | 3 | 3 | 2 | 1307923200 | Cough Medicine | If you are looking for the secret ingredient in Robitussin I believe I have found it. I got this in addition to the Root Beer Extract I ordered (which was good) and made some cherry soda. The flavor is very medicinal. | | 5 | B006K2ZZ7K | A1UQRSCLF8GW1T | Michael D. Bigham "M. Wassir" | 0 | 0 | 5 | 1350777600 | Great taffy | Great taffy at a great price. There was a wide assortment of yummy taffy. Delivery was very quick. If your a taffy lover, this is a deal. | | 6 | B006K2ZZ7K | ADT0SRK1MGOEU | Twoapennything | 0 | 0 | 4 | 1342051200 | Nice Taffy | I got a wild hair for taffy and ordered this five pound bag. The taffy was all very enjoyable with many flavors: watermelon, root beer, melon, peppermint, grape, etc. My only complaint is there was a bit too much red/black licorice-flavored pieces (just not my particular favorites). Between me, my kids, and my husband, this lasted only two weeks! I would recommend this brand of taffy -- it was a delightful treat. | | 7 | B006K2ZZ7K | A1SP2KVKFXXRU1 | David C. Sullivan | 0 | 0 | 5 | 1340150400 | Great! ;; => Just as good as the expensive brands! | This saltwater taffy had great flavors and was very soft and chewy. Each candy was individually wrapped well. None of the candies were stuck together, which did happen in the expensive version, Fralinger's. Would highly recommend this candy! I served it at a beach-themed party and everyone loved it! | | 8 | B006K2ZZ7K | A3JRGQVEQN31IQ | Pamela G. Williams | 0 | 0 | 5 | 1336003200 | Wonderful, tasty taffy | This taffy is so good. It is very soft and chewy. The flavors are amazing. I would definitely recommend you buying it. Very satisfyin ... output truncated to 9.8kB ...

2021-10-12T14:32:12.195800Z

in Emacs, Cider cuts it of as well, it seems. The ... output truncated to 9.8kB ... comes from Cider

2021-10-12T14:39:37.196Z

ahha, we are getting somewhere:

2021-10-12T14:41:35.196200Z

playing with different sizes of the columns and try to print them, I see finally error messages:

๐Ÿ‘€ 1
2021-10-12T14:42:34.196800Z

So I suppose that with a larger text, we can a lot of errors and that makes something crash.

2021-10-12T14:44:27.197Z

at 10000 the browser stops being responsive:

(-> raw-data-2 (tc/head 10000) :text)

mkvlr 2021-10-12T14:51:18.197700Z

will try this later, thanks! ๐Ÿ™

2021-10-12T14:58:04.197900Z

@chris441 At a certain moment, I see as well the internal column metadata, instead of the column values ....

chrisn 2021-10-12T18:04:05.201100Z

The only thing I have to add at this point is that I hope that everyone is aware of https://github.com/cnuernber/tmdjs if they are in fact attempting to ship some subset of their data to the client and manipulate it there. Not sure why you would see metadata at this point.

mkvlr 2021-10-12T20:49:41.201700Z

@chris441 no manipulation, just display a (tiny) subset, i.e. the first 20 rows

mkvlr 2021-10-12T20:50:44.201900Z

@carsten.behring can reproduce the issue now, thanks!

mkvlr 2021-10-12T20:55:55.202100Z

@carsten.behring think I have a fix but will need some more testing. Also you obviously want show this dataset not as nested maps but as a table. Weโ€™re working on an overhaul of our table viewer which is just a prototype currently.

2021-10-12T21:45:13.202500Z

Very nice. Regarding the way to view this: It is fine like it is now, as a ddfault, for a few reasons: 1. Dataset is a map?

2021-10-12T21:45:14.202700Z

2. I never want to view it in "full". It is just a side effect of Clerk, that is shows all defs. So this should be fast and not crash.

2021-10-12T21:45:14.202900Z

3. Maybe a custom viewer would be nice.

Daniel Slutsky 2021-10-12T17:11:30.200200Z

This Friday (8am UTC), @slack.jcpsantiago and I will organize a study session about Clerk. We will look inside, learn a little bit of how it works, and see if we can extend it for our needs. We will also discuss Notespace v4 at that session. This is part of a Scicloj study group called ml-study. More details will follow in a couple of days at the Zulip stream: https://clojurians.zulipchat.com/#narrow/stream/264992-ml-study Please write to me if you are interested.

1
Santiago 2021-10-12T17:11:36.200500Z

@slack.jcpsantiago has joined the channel

๐Ÿ‘‹ 3
๐Ÿ‘‹๐Ÿผ 1