Procházet zdrojové kódy

Support datafile from http server.

master
YJC před 3 roky
rodič
revize
21ed06bdd1
3 změnil soubory, kde provedl 31 přidání a 7 odebrání
  1. +4
    -3
      project.clj
  2. +1
    -1
      resources/templates/plugin-schema.handlebars.json
  3. +26
    -3
      src/tservice/plugins/corrplot.clj

+ 4
- 3
project.clj Zobrazit soubor

@@ -8,15 +8,16 @@

:dependencies
[[org.clojure/tools.logging "1.1.0"]
[selmer "1.12.27"]]
[selmer "1.12.27"]
[babashka/babashka.curl "0.0.3"]]

:profiles
{:provided
{:dependencies
[[org.clojure/clojure "1.10.1"]
[org.clojars.yjcyxky/tservice "0.6.0"]]}
:uberjar
:uberjar
{:auto-clean true
:aot :all
:omit-source true

+ 1
- 1
resources/templates/plugin-schema.handlebars.json Zobrazit soubor

@@ -139,7 +139,7 @@
{
"key": "sig_level",
"dataIndex": "sig_level",
"valueType": "switch",
"valueType": "digit",
"title": "Significant Level",
"tooltip": "Significant level, greater than 0 and less than 1.",
"fieldProps": {

+ 26
- 3
src/tservice/plugins/corrplot.clj Zobrazit soubor

@@ -2,10 +2,12 @@
(:require [clojure.data.json :as json]
[clojure.spec.alpha :as s]
[clojure.tools.logging :as log]
[babashka.curl :as curl]
[spec-tools.core :as st]
[tservice.util :as u]
[tservice.lib.files :as ff]
[clojure.string :as clj-str]
[tservice.lib.fs :as fs-lib]
[clojure.java.io :as io]
[tservice.plugins.corrplot.common :as corrplot]
[tservice.api.task :refer [make-routes publish-event! make-events-init create-task! update-process!]]))

@@ -96,6 +98,26 @@
(let [plugin-schema (fs-lib/join-paths config-dir "templates/plugin-schema.handlebars.json")]
{:schema (json/read-str (slurp plugin-schema))}))

(defn download-file
[datafile dest-file]
(cond
(re-matches #"^oss:\/\/\/.*" datafile)
(comment "Download by oss client")

(re-matches #"^minio:\/\/\..*" datafile)
(comment "Download by minio client")

(re-matches #"^file:\/\/.*" datafile)
(clj-str/replace datafile #"^file:\/\/" "")

(re-matches #"^https?:\/\/.*" datafile)
(or (-> (curl/get datafile {:as :stream})
(:body)
(io/copy (io/file dest-file)))
dest-file)

:else datafile))

(defn post-handler
[{:keys [datafile corr_vars sig_level hc_order
hc_method corr_type method plugin-context
@@ -109,7 +131,9 @@
description "Make a correlation plot."}
:as payload}]
(log/info "Make a correlation plot with %s" payload)
(let [log-path (fs-lib/join-paths workdir "log")
(fs-lib/create-directories! workdir)
(let [datafile (download-file datafile (fs-lib/join-paths workdir "data.csv"))
log-path (fs-lib/join-paths workdir "log")
response {:charts [(fs-lib/join-paths workdir "plotly.json")]
:results []
:log log-path
@@ -124,7 +148,6 @@
: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 ""}))
(update-process! uuid 0)
(publish-event! "corrplot"

Načítá se…
Zrušit
Uložit