Pārlūkot izejas kodu

[Improvement] Instead of the custom download-file! function.

master
YJC pirms 3 gadiem
vecāks
revīzija
f67e35b9ab
2 mainītis faili ar 3 papildinājumiem un 26 dzēšanām
  1. +1
    -2
      project.clj
  2. +2
    -24
      src/tservice/plugins/corrplot.clj

+ 1
- 2
project.clj Parādīt failu

@@ -8,8 +8,7 @@

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

:profiles
{:provided

+ 2
- 24
src/tservice/plugins/corrplot.clj Parādīt failu

@@ -2,12 +2,10 @@
(: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]
[clojure.string :as clj-str]
[tservice.lib.fs :as fs-lib]
[clojure.java.io :as io]
[tservice.api.storage.fs :as fs-api]
[tservice.plugins.corrplot.common :as corrplot]
[tservice.api.task :refer [make-routes publish-event! make-events-init create-task! update-process!]]))

@@ -98,26 +96,6 @@
(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
@@ -132,7 +110,7 @@
:as payload}]
(log/info "Make a correlation plot with %s" payload)
(fs-lib/create-directories! workdir)
(let [datafile (download-file datafile (fs-lib/join-paths workdir "data.csv"))
(let [datafile (fs-api/download-file! datafile workdir)
log-path (fs-lib/join-paths workdir "log")
response {:charts [(fs-lib/join-paths workdir "plotly.json")]
:results []

Notiek ielāde…
Atcelt
Saglabāt