Fork me on GitHub
#data-science
<
2019-07-16
>
yuhan03:07:17

I'm trying out clojupyter with @jlmr's awesome parinfer plugin above, does anyone know how to start a kernel from within an existing deps.edn project?

yuhan03:07:03

The guides and examples seem to be oriented towards standalone notebooks with interactively added dependencies, but I'm thinking more of using it as a persistent graphical REPL / interface to my library, if that makes sense

jlmr06:07:22

@qythium, I don’t know if clojupyter supports this. Personally I use the IClojure kernel: https://github.com/HCADatalab/IClojure. It has a special form /cp that you can use to add dependencies to the classpath in the form of the :deps key from deps.edn. You could use this to first read in your deps.edn file and then do something like /cp (:deps your-parsed-edn-file).

jlmr06:07:01

But maybe someone with more experience with clojupyter knows of another way?

yuhan06:07:22

Thanks for the pointer - I'm still unclear what the practical difference is between IClojure and Clojupyter kernels, just went with the latter because it's nREPL-based and supports hiccup HTML display out of the box, but I'm not strongly attached to either one.

yuhan06:07:58

@jlmr I installed IClojure and tried out /cp (:deps (read-string (slurp "deps.edn"))) as suggested, but that didn't work - looks like it's a macro which expects a map literal instead of an expression to eval

jlmr07:07:13

Also make sure you use clojure.edn/read-string as opposed to clojure.core/read-string?

yuhan06:07:57

besides, I don't think that would add the namespaces in my local library's src/ folder to the classpath?

yuhan06:07:10

Ideally I'd like to be able to "jack in" to my project and start a REPL server from the command line, then connect to it from Jupyter and have access to the same interactive state, just like a REPL with rich display capabilities - not sure if such a workflow exists?

jlmr06:07:19

@qythium strange that this (`/cp (:deps (read-string (slurp "deps.edn")))`) doesn’t work. The documentation specifically states that /cp (form that evaluates to a deps.edn map) this should work. Maybe drop the :deps key and put in the whole map?

jlmr06:07:43

I’m afraid I can’t help you further, I usually use notebooks for seperate projects to quickly visualize something. However, there is also this: https://github.com/clojupyter/lein-jupyter. It think it works with leiningen, but you could take a look at how it works.

yuhan07:07:42

yeah, looks like /cp {org.clojure/core.match {:mvn/version "0.3.0"}} works, but /cp (hash-map 'org.clojure/core.match {:mvn/version "0.3.0"}) throws an exception in the terminal

yuhan07:07:47

might look into it further and open an issue on the IClojure repo

yuhan07:07:14

I'll check out lein-jupyter and see if it can be ported over to tools.deps projects, thanks! Just checking to see if anyone else has done this before 🙂