Skip to content

Commit

Permalink
clj-service dep bumps (it was a breaking change)
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Jun 30, 2024
1 parent cea44a2 commit 72ed9e7
Show file tree
Hide file tree
Showing 22 changed files with 218 additions and 178 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- clone this repo
```
cd demo
clj -X:nbeval
clj -X:webly:npm-install
clj -X:webly:compile
clj -X:webly:run
Expand All @@ -31,10 +31,7 @@ The devtools config we use (in goldly-docs)
```

```
(reval.config/set-config!
{:storage-root "demo/rdocument/"
:url-root "/api/rdocument/file/"})
```
By default storage root is "/tmp/rdocument/".
Expand Down
2 changes: 1 addition & 1 deletion demo/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:deps
{org.pinkgorilla/reval {:local/root "../reval" :deps/manifest :deps}
org.pinkgorilla/reval-ui {:local/root "../reval-ui" :deps/manifest :deps}
org.pinkgorilla/webly {:mvn/version "0.5.683"}
org.pinkgorilla/webly {:mvn/version "0.7.693"}
; ui modules for demo notebooks:
org.pinkgorilla/ui-highcharts {:mvn/version "0.0.29"}
}
Expand Down
19 changes: 14 additions & 5 deletions demo/resources/reval/demo-services.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@
{:config {:start (modular.config/load-config! (:config #ref [:modular]))}
:exts {:start (extension/discover)}

:permission {:start (modular.permission.core/start-permissions
{} ; empty users, as we dont use oauth2 here for identity / user managmenet
)}

:clj-service {:start (clj-service.core/start-clj-services
(clip/ref :permission)
(clip/ref :exts))}

:reval {:start (reval.core/start-reval
{:config (:reval (deref (clip/ref :config)))
:clj (clip/ref :clj-service)
:reval-role nil})}

:webly {:start (webly.app.app/start-webly
(clip/ref :exts)
(deref (clip/ref :config))
(:profile #ref [:modular]))
:stop (webly.app.app/stop-webly this)}

:clj-service {:start (goldly.service/start-clj-services
(clip/ref :exts))}

:reval {:start (reval.config/set-config!
(:reval (deref (clip/ref :config))))}


;
Expand Down
6 changes: 4 additions & 2 deletions demo/resources/reval/task-services.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
{:config {:start (modular.config/load-config! (:config #ref [:modular]))}
:exts {:start (extension/discover)}

:reval {:start (reval.config/set-config!
(:reval (deref (clip/ref :config))))}
:reval {:start (reval.core/start-reval
{:config (:reval (deref (clip/ref :config)))
:clj nil
:reval-role nil})}

;
}}
2 changes: 1 addition & 1 deletion reval-ui/build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
))

(def lib 'org.pinkgorilla/reval)
(def version (format "0.6.%s" (b/git-count-revs nil)))
(def version (format "0.7.%s" (b/git-count-revs nil)))

(defn jar "build the JAR" [opts]
(println "Building the JAR")
Expand Down
10 changes: 5 additions & 5 deletions reval-ui/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
{org.pinkgorilla/reval {:local/root "../reval" :deps/manifest :deps}
; deps to ui extensions used in reval
org.pinkgorilla/pinkie {:mvn/version "0.5.232"} ; error boundary
org.pinkgorilla/ui-repl {:mvn/version "0.1.104"} ; reagent
org.pinkgorilla/ui-input {:mvn/version "0.2.45"} ; spaces
org.pinkgorilla/ui-repl {:mvn/version "0.1.105"} ; reagent
org.pinkgorilla/ui-input {:mvn/version "0.2.47"} ; spaces
org.pinkgorilla/ui-codemirror {:mvn/version "0.1.48"}
org.pinkgorilla/ui-highlightjs {:mvn/version "0.1.17"}
org.pinkgorilla/clj-service {:mvn/version "0.2.9"}}
org.pinkgorilla/ui-highlightjs {:mvn/version "0.1.19"}
org.pinkgorilla/clj-service {:mvn/version "0.3.18"}}

:aliases
{; github ci MULTI-DEPS VERSION
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.6"}
slipset/deps-deploy {:mvn/version "0.2.1"}
io.github.seancorfield/build-clj {:git/tag "v0.5.4" :git/sha "bc9c0cc"}
babashka/fs {:mvn/version "0.0.5"}
org.pinkgorilla/modular {:mvn/version "0.0.40"} ; modular.date
;org.pinkgorilla/modular {:mvn/version "0.2.56"} ; modular.date
}
:ns-default build
:jvm-opts ["-Dmaven.wagon.rto=90000"]}
Expand Down
18 changes: 5 additions & 13 deletions reval-ui/resources/ext/reval-ui.edn
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,12 @@
'reval.notebook-ui.editor {'block-for reval.notebook-ui.editor/block-for}}

; run
:api-routes {"rdocument/" {"ns" reval.document-handler/wrapped-get-ns-list
"files" reval.document-handler/wrapped-get-ns-files
["file/" :ns "/" :name] reval.document-handler/wrapped-ns-file-handler}}
;:api-routes {"rdocument/" {"ns" reval.document-handler/wrapped-get-ns-list
; "files" reval.document-handler/wrapped-get-ns-files
; ["file/" :ns "/" :name] reval.document-handler/wrapped-ns-file-handler}}
:cljs-routes {"reval/" {"viewer" reval.page.viewer/viewer-page
"repl" reval.page.repl/repl-page}}

:clj-services {:name "reval"
:permission #{:dev}
:symbols [reval.viz.eval/viz-eval-blocking
reval.document.collection/nb-collections
reval.save/save-code
; used in repl:
reval.document.notebook/load-src
reval.document.notebook/load-notebook
reval.document.notebook/eval-notebook
reval.document.notebook/save-notebook]}}
;
}

21 changes: 16 additions & 5 deletions reval-ui/src/reval/helper/url_loader.cljs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
(ns reval.helper.url-loader
(:require
[reagent.core :as r]
[promesa.core :as p]
[taoensso.timbre :refer [debug info warnf error]]
[pinkie.ui.core :refer [error-boundary]]
[goldly.service.core :as service]
[goldly.service.core :refer [clj]]
[pinkgorilla.repl.cljs.http :refer [get-str get-edn]]))

(def show-loader-debug-ui false)
Expand All @@ -12,6 +13,17 @@

;http://localhost:8000/api/viewer/file/demo.playground.cljplot/1.txt

(defn clj->atom [a fun args]
(let [args (or args [])
rp (apply clj {:timeout 120000} fun args)]
(-> rp
(p/then (fn [res]
(println "clj success: " res)
(swap! a assoc :data res)))
(p/catch (fn [err]
(println "clj error: " err))))
nil))

(defn load-url [fmt url a arg-fetch args-fetch]
(let [comparator? (or url arg-fetch args-fetch)
comparator [url arg-fetch args-fetch]]
Expand All @@ -23,11 +35,10 @@
:txt (get-str url a [:data])
:edn (get-edn url a [:data])
:clj (if arg-fetch
(service/run-a a [:data] url arg-fetch)
(clj->atom a url arg-fetch)
(if args-fetch
(apply service/run-a a [:data] url args-fetch)
(service/run-a a [:data] url))))

(clj->atom a url args-fetch)
(clj->atom a url []))))
nil)
(swap! a assoc :data nil))))

Expand Down
10 changes: 3 additions & 7 deletions reval-ui/src/reval/notebook_ui/editor.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[ui.codemirror.theme :as theme]
[ui.codemirror.api :as api]
[ui.codemirror.codemirror :refer [codemirror get-editor]]
[goldly.service.core :as service]
[goldly.service.core :refer [clj]]
[reval.notebook-ui.rewrite :refer [block-for]]))

(defonce editor-id (r/atom 27))
Expand All @@ -20,12 +20,8 @@

(defn save-code [path]
(let [code (cm-get-code)]
(service/run-cb {:fun 'reval.save/save-code
:args [{:code code :path path}]
:timeout 1000
:cb (fn [[_s {:keys [_result]}]]
;(println "result: " result)
)})))
(clj {:timeout 1000}
'reval.save/save-code {:code code :path path})))

(def cm-opts {:lineWrapping false})

Expand Down
4 changes: 2 additions & 2 deletions reval/deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
org.clojure/data.codec {:mvn/version "0.1.1"} ; image base64 encoding
rewrite-clj/rewrite-clj {:mvn/version "1.1.47"}
org.pinkgorilla/modular {:mvn/version "0.2.56"}
org.pinkgorilla/timbre {:mvn/version "0.0.6"}
org.pinkgorilla/timbre {:mvn/version "0.0.7"}
funcool/promesa {:mvn/version "11.0.674"}}

:aliases
Expand Down Expand Up @@ -34,7 +34,7 @@
:extra-deps {io.github.cognitect-labs/test-runner
{:git/url "https://github.com/cognitect-labs/test-runner.git"
:sha "dd6da11611eeb87f08780a30ac8ea6012d4c05ce"}
org.pinkgorilla/timbre {:mvn/version "0.0.6"}}
org.pinkgorilla/timbre {:mvn/version "0.0.7"}}
:exec-fn cognitect.test-runner.api/test
:main-opts ["-m" "cognitect.test-runner"]}

Expand Down
File renamed without changes.
21 changes: 0 additions & 21 deletions reval/src/reval/config.clj

This file was deleted.

41 changes: 41 additions & 0 deletions reval/src/reval/core.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
(ns reval.core
(:require
[taoensso.timbre :as timbre :refer [debug info infof error]]
[clj-service.core :refer [expose-functions]]
[reval.default] ; side effects to include all default converters
))

(def default-reval-config
{:rdocument {:storage-root "/tmp/rdocument/"
:url-root "/api/rdocument/file/"}
:collections {:user [:clj "user/notebook/"]
:demo [:clj "demo/notebook/"]
:demo-cljs [:cljs "demo/notebook/"]}})

(defn sanitize-config [reval-config]
{:rdocument (or (:rdocument reval-config)
(:rdocument default-reval-config))
:collections (or (:collections reval-config)
(:collections default-reval-config))})

(defn start-reval [{:keys [config clj reval-role] :as this}]
(info "starting reval service..")
(let [config (sanitize-config config)]
(when clj
(expose-functions clj
{:name "reval"
:symbols ['reval.viz.eval/viz-eval-blocking
'reval.save/save-code
'reval.document.notebook/load-src]
:permission reval-role
:fixed-args []})
(expose-functions clj
{:name "reval"
:symbols ['reval.document.collection/nb-collections ; this
'reval.document.notebook/load-notebook ; this
'reval.document.notebook/eval-notebook ; this
'reval.document.notebook/save-notebook] ; this
:permission reval-role
:fixed-args [this]}))
{:config config}))

27 changes: 16 additions & 11 deletions reval/src/reval/document/collection.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
[clojure.java.io :as io]
[modular.resource.explore :refer [describe-files]]
[reval.document.path :refer [split-ext is-format? ext-is-format? filename->ns]]
[reval.document.notebook :refer [eval-notebook]]
[reval.config :refer [get-in-reval-config]]))
[reval.document.notebook :refer [eval-notebook]]))

; this does not work. meta-data cannot be assoced to a string
#_(defn name-with-meta [{:keys [name path] :as entry}]
Expand Down Expand Up @@ -52,18 +51,18 @@
[k [(first v) (get-nss-list (first v) (rest v))]]) spec)
(into {})))

(defn eval-collection [[name [t ns-list]]]
(defn eval-collection [this [name [t ns-list]]]
(doall
(map #(eval-notebook (:nbns %)) ns-list)))
(map #(eval-notebook this (:nbns %)) ns-list)))

(defn eval-collections [colls]
(defn eval-collections [this colls]
; {:demo [:clj []]
; :user [:clj ["test.notebook.apple"]]}
(doall
(map eval-collection colls)))
(map (partial eval-collection this) colls)))

(defn nb-collections []
(get-collections (get-in-reval-config [:collections])))
(defn nb-collections [this]
(get-collections (get-in this [:config :collections])))

(comment

Expand Down Expand Up @@ -113,10 +112,16 @@
{:test5 [:clj "notebook/test27/"]
:study [:clj "notebook/study/"]})

(nb-collections)
(def this {:config {:rdocument {:storage-root "/tmp/rdocument/"
:url-root "/api/rdocument/file/"}
:collections {:user [:clj "user/notebook/"]
:demo [:clj "demo/notebook/"]
:demo-cljs [:cljs "demo/notebook/"]}}})

(-> (nb-collections)
eval-collections)
(nb-collections this)

(->> (nb-collections this)
(eval-collections this))

;
)
Expand Down
Loading

0 comments on commit 72ed9e7

Please sign in to comment.