浏览代码

Fix some bugs.

master
YJC 3 年前
父节点
当前提交
009c93780a
共有 5 个文件被更改,包括 21 次插入20 次删除
  1. +0
    -3
      resources/corrplot/bin/corrplot.sh
  2. +6
    -6
      resources/templates/args.json.template
  3. +1
    -0
      resources/tservice-plugin.yaml
  4. +13
    -10
      src/tservice/plugins/corrplot.clj
  5. +1
    -1
      src/tservice/plugins/corrplot/common.clj

+ 0
- 3
resources/corrplot/bin/corrplot.sh 查看文件

@@ -66,9 +66,6 @@ fi
if [ -z "$OUTPUT_FILE" ]; then
echo "-o argument is not specified."
exit 1
elif [ ! -f "$OUTPUT_FILE" ]; then
echo "$OUTPUT_FILE is not a valid file."
exit 1
else
OUTPUT_FILE=$(realpath $OUTPUT_FILE)
fi

+ 6
- 6
resources/templates/args.json.template 查看文件

@@ -1,10 +1,10 @@
{
"datafile": "{{ datafile }}",
"corr_vars": {{ corr_vars }},
"method": "{{ method | default: "square" }}",
"corr_type": "{{ corr_type | default: "full" }}",
"hc_method": "{{ hc_method | default: "complete" }}",
"corr_vars": {{ corr_vars|json|safe }},
"method": "{{ method|default:"square" }}",
"corr_type": "{{ corr_type|default:"full" }}",
"hc_method": "{{ hc_method|default:"complete" }}",
"hc_order": {{ hc_order }},
"sig_level": {{ sig_level | default: 0.05 }},
"title": "{{ title | default: "This is a correlation plot" }}"
"sig_level": {{ sig_level|default:0.05 }},
"title": "{{ title|default:"This is a correlation plot" }}"
}

+ 1
- 0
resources/tservice-plugin.yaml 查看文件

@@ -19,6 +19,7 @@ init:
- step: unpack-env
envname: corrplot
envtype: environment
post-unpack-cmd: chmod a+x {{ ENV_DEST_DIR }}/bin/corrplot.sh
- step: unpack-env
envname: templates
envtype: configuration

+ 13
- 10
src/tservice/plugins/corrplot.clj 查看文件

@@ -20,10 +20,10 @@

(s/def ::corr_vars
(st/spec
{:spec vector?
:type :vector
{:spec (s/coll-of string?)
:type :array
:description "Variables."
:swagger/default []
:swagger/default nil
:reason "The corr_vars must be a vector."}))

(s/def ::method
@@ -54,7 +54,7 @@
(s/def ::hc_order
(st/spec
{:spec #{true false}
:type :boolean
:type :bool
:description "Logical value. If TRUE, correlation matrix will be hc.ordered using hclust function."
:swagger/default true
:reason "The hc_order must be one of true, false."}))
@@ -63,9 +63,9 @@
(st/spec
{:spec #(and (>= % 0) (<= % 1))
:type :float
:description "Logical value. If TRUE, correlation matrix will be hc.ordered using hclust function."
:description "Significant level, greater than 0 and less than 1."
:swagger/default 0.05
:reason "The hc_order must be one of true, false."}))
:reason "The sig_level must be a float."}))

(def corrplot-params-body
"A spec for the body parameters."
@@ -128,13 +128,16 @@
args-template (fs-lib/join-paths template-dir "args.json.template")
output-file (fs-lib/join-paths dest-dir "plotly.json")]
(corrplot/make-args-json! args-template context args-json)
(log/info "Make an argument json file: %s" args-json)
(log/info "Make an argument json file: " args-json)
(update-process! task-id 30)
(let [result (corrplot/call-corrplot! args-json output-file env-dir)
status (:status result)]
status (:status result)
process (if (= status "Success") 100 -1)]
(spit log-path (json/write-str result))
(log/info "The task is finished, result file is %s" output-file)
(update-process! task-id (if (= status "Success") 100 -1)))))
(update-process! task-id process)
(if (= status "Success")
(log/info "The task is finished, result file is " output-file)
(log/error "The task is failed, error msg is located in " log-path)))))

;;; --------------------------------------------------- Lifecycle ----------------------------------------------------
(def events-init

+ 1
- 1
src/tservice/plugins/corrplot/common.clj 查看文件

@@ -18,7 +18,7 @@
(log/info (format "Render Template (%s) with Environment Context: %s" template-file context))
(let [template (slurp template-file)
args-json (parser/render template context)]
(spit output-file (json/write-str args-json))))
(spit output-file args-json)))

(defn call-corrplot!
[input-file output-file plugin-env-dir]

正在加载...
取消
保存