data-science

wcohen 2024-03-25T17:29:05.249619Z

Hi all --very basic Clay question (copying the organization of a basic scicloj notebook to kick the tires on it, with a dev ns that generates an HTML): • My namespace code appears, but no code below it is either shown or evaluated (either defs of local things to input or analyze, or defns of analysis functions). The only stuff below the ns declaration are some random commented out code lines for WIP functions. • I've got clay, kind, and kindly all in my require. • I did cargo cult copy the following just to see if this enabled making the code appear, to no avail.

^:kindly/hide-code
(def md (comp kindly/hide-code kind/md)
Is there somewhere else that's now a common VSCode/Calva default that would normally hide stuff? I haven't otherwise set any kindly advice anywhere. My goal is to see all my definitions in a notebook and work interactively with it

wcohen 2024-04-02T15:40:55.478709Z

okey dokey. i still have no idea why the old clj-new project i shoved clay into wasn't working, but i successfully just made a smaller clay-only project with a notebook alongside, and am just shifting my data analysis in there. i feel like it's something about the project setup or namespace organization or something, rather than having a "notebook" where i separately work through things. though i have no evidence to back that up.

wcohen 2024-04-02T15:41:20.976809Z

but it's working at least. if it breaks at some point i will let you know what conclusively did it. it works in vs code / emacs too

Daniel Slutsky 2024-04-02T16:26:05.470749Z

many thanks for these efforts, @wcohen.

wcohen 2024-03-26T20:04:38.144699Z

Update -- also doesn't work on mac. I thought maybe it was local dependencies but removing those didn't seem to matter. Back to thinking it's something about a kindly advice setting hiding all the code.

wcohen 2024-03-26T20:05:02.149319Z

(At first I was thinking I could just switch to clerk in the mean time, but that idea of a leaflet map is just so enticing...)

Daniel Slutsky 2024-03-26T20:07:03.093849Z

Interesting

Daniel Slutsky 2024-03-26T20:08:05.650719Z

Do you see any errors in the browser console?

Daniel Slutsky 2024-03-26T20:08:37.491969Z

Or the REPL?

wcohen 2024-03-26T20:08:57.192689Z

neither

wcohen 2024-03-26T20:09:19.053779Z

is there a place i can override the hide settings to like, an empty set?

wcohen 2024-03-26T20:09:41.518539Z

ie :kindly/options {:kinds-that-hide-code #{:kind/md :kind/hiccup}}

wcohen 2024-03-26T20:10:33.466379Z

ah -- found it in config

wcohen 2024-03-26T20:15:38.385579Z

(didn't seem to do anything)

Daniel Slutsky 2024-03-26T20:17:49.876399Z

🤔

wcohen 2024-03-26T20:18:19.367659Z

will keep poking. what NS actually generates this stuff in clay?

wcohen 2024-03-26T20:21:06.812699Z

(also -- not a big deal, but just as a note, the pom.xml for clay has https://github.com/org.scicloj/clay as the url, which means that the link from clojars to the repo is broken)

Daniel Slutsky 2024-03-26T20:21:23.555099Z

Thanks!

Daniel Slutsky 2024-03-26T20:22:21.878349Z

The 'make' ns is the main entry point. I suggest I'll share a minimal example with you, and we start debugging from there.

wcohen 2024-03-26T20:22:52.780329Z

again, no hurry!! i'll just keep plodding along with clerk re work output for now

Daniel Slutsky 2024-03-26T20:30:30.827109Z

mkdir test1

cd test1

mkdir notebooks

cat > notebooks/scratch.clj
(ns scratch)
(+ 1 2)
^D

clj -Sdeps '{:deps {org.scicloj/clay {:mvn/version "2-alpha87"}}}'

(require '[scicloj.clay.v2.api :as clay])

(clay/make! {:source-path "notebooks/scratch.clj"})

Daniel Slutsky 2024-03-26T20:30:38.114249Z

Could you try this?

wcohen 2024-03-26T20:33:41.635759Z

it works! okay. i'll build up from this and see where i get stuck

Daniel Slutsky 2024-03-26T20:35:25.982479Z

nice, let us think what might be the difference. maybe the next step could be something similar to the code we tried yesterday, but from the shell, without any editor involved.

wcohen 2024-03-26T20:35:36.164189Z

totally

Daniel Slutsky 2024-03-26T21:27:53.984919Z

If you use VSCode Calva, when you start the REPL (Jack In), the corresponding Clojure command appears in the Terminal window. In my environment, it looks like:

pushd /path/to/your/project ; clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}' -M -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" ; popd
Maybe we'll learn something from what we see in your Calva environment. In Emacs CIDER, there is something similar in the *Messages* buffer. In my environment, it looks like:
[nREPL] Starting server via /usr/local/bin/clojure  -J-XX:-OmitStackTraceInFastThrow -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0"} cider/cider-nrepl {:mvn/version "0.28.5"} refactor-nrepl/refactor-nrepl {:mvn/version "3.5.2"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl

Daniel Slutsky 2024-03-25T17:51:55.610349Z

Hi. Do you see any error at the REPL?

Daniel Slutsky 2024-03-25T17:54:21.978099Z

The Calva setup described here is supposed to work (except for changes in the demonstrated Noj library, but this is unrelated). https://scicloj.github.io/clojure-data-scrapbook/projects/visual-tools/clay-calva-demo-20231216 https://github.com/scicloj/clojure-data-scrapbook/tree/main/projects/visual-tools/clay-calva-demo-20231216

Daniel Slutsky 2024-03-25T17:56:06.670309Z

Would you like to share your deps.edn, clay.edn (if any), and namespace? And what actions do you do in VSCode to render the page?

wcohen 2024-03-25T17:58:18.651679Z

clay.edn is nonexistent in a clay.clj I run

(clay/make! {:format [:html]
             :base-source-path "src/boston/"
             :source-path ["parcel_analysis.clj"]
             :base-target-path "docs"
             :clean-up-target-dir true})
and my deps is still pretty boring and from clj-new, basically:
{:paths ["src" "resources"]
 :deps {org.clojure/clojure {:mvn/version "1.12.0-alpha5"}
        org.clojure/data.csv {:mvn/version "1.1.0"}
        ovid/ovid {:local/root "../ovid"}
        Factual/geo {:local/root "../geo"}
        aurelius/aurelius {:local/root "../aurelius"}
        org.locationtech.jts.io/jts-io-common {:mvn/version "1.20.0-SNAPSHOT"}
        org.locationtech.jts/jts-core {:mvn/version "1.20.0-SNAPSHOT"}
        org.wololo/jts2geojson {:mvn/version "0.18.1"}
        scicloj/tablecloth {:mvn/version "7.021"}
        org.scicloj/clay {:mvn/version "2-alpha87"}
        org.babashka/http-client {:mvn/version "0.3.11"}}
 :aliases
 {:run-m {:main-opts ["-m" "foo.parcel-analysis"]}
  :run-x {:ns-default foo.parcel-analysis
          :exec-fn greet
          :exec-args {:name "Clojure"}}
  :build {:deps {io.github.clojure/tools.build
                 {:mvn/version "0.9.6"}} 
          :ns-default build}
  :test {:extra-paths ["test"]
         :extra-deps {org.clojure/test.check {:mvn/version "1.1.1"}
                      io.github.cognitect-labs/test-runner
                      {:git/tag "v0.5.1" :git/sha "dfb30dd"}}}}
 :mvn/repos {"jts-snapshots" {:url ""
                              :releases {:enabled false}
                              :snapshots {:enabled true
                                          :update :always
                                          :checksum :warn}}
             "releases" {:url ""},
             "snapshots" {:url ""}}}
the ns def:
(ns foo.parcel-analysis
  (:require [clojure.string :as clojure.string]
            [clojure.tools.logging :as log]
            [ovid.io :as oio]
            [geo.crs :as gcrs]
            [geo.jts :as gjts]
            [geo.io :as gio]
            [ovid.feature :as of]
            [aurelius.jts :as ajts]
            [tech.v3.dataset.io.csv :as csv]
            [tech.v3.dataset :as ds]
            [portal.api :as p]
            [clojure.java.io :as io]
            [tablecloth.api :as tc]
            [babashka.http-client :as http]
            [charred.api :as charred]
            [charred.bulk :as bulk]
            [scicloj.kindly.v4.kind :as kind]
            [scicloj.kindly.v4.api :as kindly])
  (:import (org.locationtech.jts.geom GeometryFactory
                                      Geometry
                                      LineString
                                      PrecisionModel)
           (org.locationtech.jts.algorithm MinimumAreaRectangle MinimumDiameter)
           (org.locationtech.jts.operation.linemerge LineMerger)
           (org.locationtech.jts.operation.buffer BufferParameters
                                                  OffsetCurveBuilder)))

wcohen 2024-03-25T17:58:47.113799Z

all just a bunch of GIS kitchen sink stuff for now as I get to playing around

Daniel Slutsky 2024-03-25T17:59:08.408739Z

Thanks! That is very helpful. I'll try to reproduce in my environment.

wcohen 2024-03-25T17:59:30.760169Z

I'm sorry I'm dumping a bunch of junk at you

Daniel Slutsky 2024-03-25T18:00:01.526599Z

It is great help to get real-world examples, especially those which break unexpectedly.

wcohen 2024-03-25T18:00:22.234489Z

The only thing I can currently imagine is that many of these def'd things are geojsons weighing hundreds of MB -- there's nothing specific to display, but maybe it's crossing some kind of threshold

👍 1
wcohen 2024-03-25T18:01:01.804639Z

(also as you can see I'm basically trying to wean myself off of the previous transducer based stuff and work toward using TMD for gis stuff, as discussed in zulip)

🆒 1
Daniel Slutsky 2024-03-25T18:03:12.083139Z

(I'm renaming the namespace foo.parcel-analysis to boston.parcel-analysis, assuming it is intended to match the file path.)

wcohen 2024-03-25T18:04:29.578719Z

yep, sorry

wcohen 2024-03-25T18:04:32.351919Z

was trying to keep things generic

wcohen 2024-03-25T18:04:35.253469Z

missed one

wcohen 2024-03-25T18:04:47.286549Z

but you know where i live!

🙃 1
Daniel Slutsky 2024-03-25T18:04:47.999019Z

(and I'll use the Clojars versions of Ovid and Geo, assuming this is not a relevant difference)

wcohen 2024-03-25T18:04:54.612849Z

totally irrelevant

wcohen 2024-03-25T18:05:35.934349Z

you might have to use a github sha, i never posted ovid to clojars

wcohen 2024-03-25T18:05:43.047759Z

or maybe i did but it's vestigial

Daniel Slutsky 2024-03-25T18:05:52.115569Z

👍

wcohen 2024-03-25T18:06:17.919059Z

it's all going to be irrelevant if i'm putting a tmd dataset as a base case, so i'm going to need a new base gis library

Daniel Slutsky 2024-03-25T18:13:20.610749Z

Ok, so a page with the ns definition is rendered.

Daniel Slutsky 2024-03-25T18:13:37.501699Z

Is it what you see too?

wcohen 2024-03-25T18:15:51.414719Z

hold on -- making a new empty ns to try to diagnose alongside

wcohen 2024-03-25T18:22:21.142039Z

oh my goodness. it's totally my fault. i'm so used to having to put all my pieces of info as defs to avoid massive repl output that i'm realizing that i wasn't actually sticking anything to stdout

wcohen 2024-03-25T18:22:22.797649Z

i'm so sorry.

wcohen 2024-03-25T18:23:07.194789Z

oh wait, no that's not the problem. let me simplify:

👍 1
wcohen 2024-03-25T18:27:47.719919Z

(ns boston.parcel-analysis
  (:require [clojure.string :as clojure.string]
            [clojure.tools.logging :as log]
            [ :as oio]
            [geo.crs :as gcrs]
            [geo.jts :as gjts]
            [ :as gio]
            [ovid.feature :as of]
            [aurelius.jts :as ajts]
            [tech.v3.dataset.io.csv :as csv]
            [tech.v3.dataset :as ds]
            [ :as io]
            [tablecloth.api :as tc]
            [babashka.http-client :as http]
            [charred.api :as charred]
            [charred.bulk :as bulk]
            [scicloj.kindly.v4.kind :as kind]
            [scicloj.kindly.v4.api :as kindly])
  (:import (org.locationtech.jts.geom GeometryFactory
                                      Geometry
                                      LineString
                                      PrecisionModel)
           (org.locationtech.jts.algorithm MinimumAreaRectangle MinimumDiameter)
           (org.locationtech.jts.operation.linemerge LineMerger)
           (org.locationtech.jts.operation.buffer BufferParameters
                                                  OffsetCurveBuilder)))

(def t (gcrs/create-transform 4326 2249))

(+ 1 1)
with (added quarto in just to be safe)
(clay/make! {:format [:quarto :html]
             :base-source-path "src/boston/"
             :source-path ["parcel_analysis.clj"]
             :base-target-path "docs"
             :clean-up-target-dir true})
yields

wcohen 2024-03-25T18:28:04.835369Z

(sorry, as you can see i made a parcel_analysis2.clj to avoid deleting my other junk but that shouldn't matter)

Daniel Slutsky 2024-03-25T18:30:00.106069Z

Interesting

wcohen 2024-03-25T18:30:13.333409Z

in fact:

wcohen 2024-03-25T18:30:17.600519Z

deps have nothing to do with it

wcohen 2024-03-25T18:30:22.279619Z

it's a vs code or windows or something problem

Daniel Slutsky 2024-03-25T18:31:35.032019Z

I get the following:

Daniel Slutsky 2024-03-25T18:31:47.740849Z

which is probably what you hoped to see.

wcohen 2024-03-25T18:32:05.302559Z

are you emacs, intellij, or calva?

wcohen 2024-03-25T18:32:15.188509Z

i guess that shouldn't matter

wcohen 2024-03-25T18:32:17.978949Z

windows?

Daniel Slutsky 2024-03-25T18:32:19.928979Z

Emacs, but it should not matter.

Daniel Slutsky 2024-03-25T18:32:34.887229Z

I haven't tested it in Windows so much.

wcohen 2024-03-25T18:32:41.586959Z

right, sorry -- was also poking around with portal so i forget what's dev environment dependent

Daniel Slutsky 2024-03-25T18:32:43.093799Z

That could make a difference

wcohen 2024-03-25T18:32:50.298779Z

lovely. will check mac tonight

wcohen 2024-03-25T18:32:58.312789Z

sorry for the bother!

Daniel Slutsky 2024-03-25T18:33:13.746079Z

This is amazing help @wcohen!

Daniel Slutsky 2024-03-25T18:33:32.862729Z

Any user surprise is the best insight I could hope for.

Daniel Slutsky 2024-03-25T18:34:26.491549Z

You are encouraging me to test it on Windows, hopefully later this week. I was not so careful in making file management generic enough, etc.

Daniel Slutsky 2024-03-25T18:36:01.123789Z

Do you use https://learn.microsoft.com/en-us/windows/wsl/about? I think I know another person with WSL who seems to be fine.

wcohen 2024-03-25T18:36:11.714749Z

no wsl unfortunately. it's a new world for me too

wcohen 2024-03-25T18:36:32.021969Z

i haven't had to do windows only in like a decade. the more i think about it it's GOTTA be that

Daniel Slutsky 2024-03-25T18:37:05.166529Z

It should be solvable, but probably not today.

wcohen 2024-03-25T18:37:26.651129Z

no hurry at all. i can just do it on my mac for now and poke around on my windows installation as time allows

Daniel Slutsky 2024-03-25T18:37:45.345619Z

thanks

Daniel Slutsky 2024-03-25T18:37:53.747899Z

(leaving the keyboard for a while)

wcohen 2024-03-25T18:38:09.764279Z

thank YOU! i know it's way late for you

Daniel Slutsky 2024-03-25T18:38:37.447379Z

perfect timing actually 🙏