Skip to content

Commit

Permalink
template/show-result
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Apr 24, 2024
1 parent 77d2be5 commit dda3a24
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/interact/src/ta/interact/template.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns ta.interact.template
(:require
[de.otto.nom.core :as nom]
[taoensso.timbre :as log :refer [tracef debug debugf info infof warn error errorf]]
[com.rpl.specter :as specter]))

Expand Down Expand Up @@ -87,6 +88,28 @@
(warn "full template: " template)
template))

(defn- get-fn [fun]
(if (symbol? fun)
(requiring-resolve fun)
fun))

(defn show-result [template result viz-mode]
(let [{:keys [viz viz-options]} (get template viz-mode)
viz-fn (get-fn viz)]
(if viz-fn
(if (nom/anomaly? result)
result
(try
(let [r (if viz-options
(viz-fn viz-options result)
(viz-fn result))]
r)
(catch Exception ex
(error "viz calc exception: " ex)
(nom/fail ::algo-calc {:message "algo viz exception!"
:location :visualize}))))
(nom/fail ::unknown-viz {:message (str "algo viz not found: " viz-mode)}))))

(comment
(load-template :juan-fx)
(get-options :juan-fx)
Expand Down

0 comments on commit dda3a24

Please sign in to comment.