Parcourir la source

Improve ui schema.

master
YJC il y a 3 ans
Parent
révision
2b3e818fa4
2 fichiers modifiés avec 84 ajouts et 23 suppressions
  1. +43
    -2
      resources/templates/plugin-schema.handlebars.json
  2. +41
    -21
      src/tservice/plugins/corrplot.clj

+ 43
- 2
resources/templates/plugin-schema.handlebars.json Voir le fichier

@@ -1,12 +1,44 @@
{
"fields": [
{
"key": "name",
"dataIndex": "name",
"valueType": "text",
"title": "Name",
"tooltip": "The name of the corrplot chart.",
"formItemProps": {
"initialValue": "corrplot",
"rules": [
{
"required": true,
"message": "Please enter the name."
}
]
}
},
{
"key": "datafile",
"dataIndex": "datafile",
"valueType": "select",
"title": "Data File",
"tooltip": "Where is the data?",
"valueEnum": "#{{{toselect datafile }}}#",
"formItemProps": {
"rules": [
{
"required": true,
"message": "Please load file firstly."
}
]
}
},
{
"key": "corr_vars",
"dataIndex": "corr_vars",
"valueType": "select",
"title": "Correlation Variables",
"tooltip": "Which variables do you want to analyze?",
"valueEnum": "{{{tojson columns }}}",
"valueEnum": "#{{{tojson columns }}}#",
"fieldProps": {
"mode": "multiple"
},
@@ -116,10 +148,19 @@
"formItemProps": {
"initialValue": 0.05
}
},
{
"key": "description",
"dataIndex": "description",
"valueType": "textarea",
"title": "Description",
"tooltip": "The description of the corrplot chart.",
"formItemProps": {
"initialValue": "Make a correlation plot."
}
}
],
"dataKey": {
"annoData": "Anno",
"data": "Data"
},
"examples": [

+ 41
- 21
src/tservice/plugins/corrplot.clj Voir le fichier

@@ -10,6 +10,22 @@
[tservice.api.task :refer [make-routes publish-event! make-events-init create-task! update-process!]]))

;;; ------------------------------------------------ Event Specs ------------------------------------------------
(s/def ::name
(st/spec
{:spec string?
:type :string
:description "A name for the corrplot task."
:swagger/default (str "corrplot" (u/datetime))
:reason "The name must be string."}))

(s/def ::description
(st/spec
{:spec string?
:type :string
:description "A description for the corrplot task."
:swagger/default "Make a correlation plot."
:reason "The description must be string."}))

(s/def ::datafile
(st/spec
{:spec string?
@@ -76,31 +92,35 @@
;;; ------------------------------------------------ Event Metadata ------------------------------------------------
;; Handlers
(defn get-handler
[{{:keys [config-dir]} :plugin-env}]
[{{:keys [config-dir]} :plugin-context}]
(let [plugin-schema (fs-lib/join-paths config-dir "templates/plugin-schema.handlebars.json")]
{:schema (json/read-str (slurp plugin-schema))}))

(defn post-handler
[{:keys [datafile corr_vars sig_level hc_order hc_method corr_type method plugin-env]
:or {sig_level 0.05
hc_order true
hc_method "complete"
corr_type "full"
method "square"}
[{:keys [datafile corr_vars sig_level hc_order
hc_method corr_type method plugin-context
uuid workdir owner name description]
:or {sig_level 0.05
hc_order true
hc_method "complete"
corr_type "full"
method "square"
name (str "corrplot" (u/datetime))
description "Make a correlation plot."}
:as payload}]
(log/info "Make a correlation plot with %s" payload)
(let [workdir (ff/get-workdir)
log-path (fs-lib/join-paths workdir "log")
response {:files [(fs-lib/join-paths workdir "plotly.json")
(fs-lib/join-paths workdir "result.md")]
:log log-path
:response-type :data2files}
task-id (create-task! {:name (str "corrplot" (u/datetime))
:description "Make a correlation plot."
(let [log-path (fs-lib/join-paths workdir "log")
response {:data {:charts [(fs-lib/join-paths workdir "plotly.json")]
:results []}
:log log-path}
task-id (create-task! {:id uuid
:name name
:description description
:payload payload
:plugin-name (:plugin-name plugin-env)
:plugin-type (:plugin-type plugin-env)
:plugin-version (:plugin-version plugin-env)
:owner owner
:plugin-name (:plugin-name plugin-context)
:plugin-type (:plugin-type plugin-context)
:plugin-version (:plugin-version plugin-context)
:response response})]
(fs-lib/create-directories! workdir)
(spit log-path (json/write-str {:status "Running" :msg ""}))
@@ -114,8 +134,8 @@
:corr_type corr_type
:method method
:title "Correlation Plot"}
:template-dir (fs-lib/join-paths (:config-dir plugin-env) "templates")
:env-dir (:env-dir plugin-env)
:template-dir (fs-lib/join-paths (:config-dir plugin-context) "templates")
:env-dir (:env-dir plugin-context)
:dest-dir workdir
:task-id task-id})
(merge response {:task-id task-id})))
@@ -133,7 +153,7 @@
:summary "It is used to investigate the dependence between multiple variables at the same time and to highlight the most correlated variables in a data table."
:body-schema corrplot-params-body
:handler post-handler
:response-type :data2files}))
:response-type :data2charts}))

;;; ------------------------------------------------ Event Processing ------------------------------------------------
(defn- corrplot!

Chargement…
Annuler
Enregistrer