-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GH-1045] Arbitrary WGS Inputs #218
Changes from all commits
be711c4
e67dc41
3e82e67
7bba5ae
e101bca
41ac192
385432c
d8169e1
392c318
96e35fd
65d7cad
9f5221f
7ccecca
5e1f892
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
(ns wfl.module.copyfile | ||
"A dummy module for smoke testing wfl/cromwell auth." | ||
(:require [clojure.data.json :as json] | ||
[wfl.api.workloads :as workloads] | ||
[wfl.api.workloads :as workloads :refer [defoverload]] | ||
[wfl.jdbc :as jdbc] | ||
[wfl.module.all :as all] | ||
[wfl.module.batch :as batch] | ||
[wfl.service.cromwell :as cromwell] | ||
[wfl.util :as util]) | ||
(:import [java.time OffsetDateTime])) | ||
|
@@ -14,57 +15,68 @@ | |
{:release "copyfile-v1.0" | ||
:top "wdl/copyfile.wdl"}) | ||
|
||
(defn- submit-workflow | ||
(defn ^:private get-cromwell-environment [{:keys [cromwell]}] | ||
(let [envs (all/cromwell-environments #{:gotc-dev :gotc-prod} cromwell)] | ||
(when (not= 1 (count envs)) | ||
(throw (ex-info "no unique environment matching Cromwell URL." | ||
{:cromwell cromwell | ||
:environments envs}))) | ||
(first envs))) | ||
|
||
(defn ^:private submit-workflow | ||
"Submit WORKFLOW to Cromwell in ENVIRONMENT with OPTIONS and LABELS." | ||
[environment workflow options labels] | ||
[environment inputs options labels] | ||
(cromwell/submit-workflow | ||
environment | ||
(util/extract-resource (:top workflow-wdl)) | ||
nil | ||
(-> workflow (select-keys [:src :dst]) (util/prefix-keys pipeline)) | ||
(-> inputs (util/prefix-keys pipeline)) | ||
options | ||
labels)) | ||
|
||
(defn add-copyfile-workload! | ||
"Use transaction TX to add the workload described by WORKLOAD-REQUEST." | ||
[tx {:keys [items] :as _workload-request}] | ||
(let [workflow-options (-> (:cromwell _workload-request) | ||
all/cromwell-environments | ||
first | ||
util/make-options | ||
(util/deep-merge (:workflow_options _workload-request))) | ||
[id table] (all/add-workload-table! tx workflow-wdl _workload-request) | ||
to-row (fn [item] (assoc (:inputs item) | ||
:workflow_options | ||
(json/write-str (util/deep-merge workflow-options (:workflow_options item)))))] | ||
(letfn [(add-id [m id] (assoc m :id id))] | ||
(jdbc/insert-multi! tx table (map add-id (map to-row items) (range)))) | ||
id)) | ||
(defn create-copyfile-workload! | ||
"Use transaction TX to add the workload described by REQUEST." | ||
[tx {:keys [items common] :as request}] | ||
(letfn [(merge-to-json [shared specific] | ||
(json/write-str (util/deep-merge shared specific))) | ||
(serialize [workflow id] | ||
(-> workflow | ||
(assoc :id id) | ||
(update :inputs #(merge-to-json (:inputs common) %)) | ||
(update :options #(merge-to-json (:options common) %))))] | ||
(let [[id table] (batch/add-workload-table! tx workflow-wdl request)] | ||
(jdbc/insert-multi! tx table (map serialize items (range))) | ||
(workloads/load-workload-for-id tx id)))) | ||
Comment on lines
+37
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
(defn start-copyfile-workload! | ||
"Use transaction TX to start _WORKLOAD." | ||
[tx {:keys [cromwell items uuid] :as workload}] | ||
(let [env (first (all/cromwell-environments cromwell))] | ||
(letfn [(submit! [{:keys [id inputs workflow_options]}] | ||
[id (submit-workflow env inputs workflow_options {:workload uuid}) "Submitted"]) | ||
(update! [tx [id uuid status]] | ||
[tx {:keys [items uuid] :as workload}] | ||
(let [env (get-cromwell-environment workload) | ||
default-options (util/make-options env)] | ||
(letfn [(submit! [{:keys [id inputs options]}] | ||
[id (submit-workflow env inputs | ||
(util/deep-merge default-options options) | ||
{:workload uuid})]) | ||
(update! [tx [id uuid]] | ||
(jdbc/update! tx items | ||
{:updated (OffsetDateTime/now) :uuid uuid :status status} | ||
{:updated (OffsetDateTime/now) :uuid uuid :status "Submitted"} | ||
["id = ?" id]))] | ||
(run! (comp (partial update! tx) submit!) (:workflows workload)) | ||
(jdbc/update! tx :workload | ||
{:started (OffsetDateTime/now)} ["uuid = ?" uuid])))) | ||
Comment on lines
51
to
66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The implementations for |
||
|
||
(defmethod workloads/create-workload! | ||
pipeline | ||
[tx request] | ||
(->> | ||
(add-copyfile-workload! tx request) | ||
(workloads/load-workload-for-id tx))) | ||
(defoverload workloads/create-workload! pipeline create-copyfile-workload!) | ||
|
||
(defmethod workloads/start-workload! | ||
pipeline | ||
[tx {:keys [id] :as workload}] | ||
(do | ||
(start-copyfile-workload! tx workload) | ||
(workloads/load-workload-for-id tx id))) | ||
|
||
(defmethod workloads/load-workload-impl | ||
pipeline | ||
[tx workload] | ||
(if (workloads/saved-before? "0.4.0" workload) | ||
(workloads/default-load-workload-impl tx workload) | ||
(batch/load-batch-workload-impl tx workload))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should build that into parse-json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be uses where passing
nil
into this is an error - building thefnil
'ness intoparse-json
would make that harder to detect.