-
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
Conversation
Maybe when we do that followup documentation PR we should write down what the default options are for the different modules since this API no longer surfaces that information. Could also address the loading-old-workloads thing by merging the defaults in twice--once when we write to the DB and once when we submit to Cromwell. Would generally be a no-op the second time but it would provide the backwards compatibility from merging at submit-time. |
Do we want all these options to be made public? This includes service account stuff that's sort of a hack/implementation detail? |
(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)))) |
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.
The create-workload!
implementations for copyfile, wgs and xx are almost identical. In a subsequent change, we could explore reducing this technical debt. This means (in theory) we need to test only once for the "batch" workflows (or instantiate a test suite).
(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])))) |
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.
The implementations for start-workload!
still differ somewhat. This is due to the xx module using (a faked) batch submit to cromwell. In a subsequent change, we could explore moving the other modules onto that endpoint and actually implement it. Given that, maybe we can extract common functionality for these modules (c.f. create-workload!
)
I think it would be helpful for ops to know in order for them to override stuff. Honestly I think if we are doing hacky stuff I think that's all the more reason to surface what on earth we are doing. And again we don't gotta actually return it from the endpoint I guess -- if there's stuff we really don't want to show them then maybe just documenting what we do want to show them is fine. But since they'd be able to override our hacky stuff I don't see much of a harm. |
api/src/wfl/api/workloads.clj
Outdated
(defn saved-before? | ||
"Test if the `_workload` was saved before the `reference` version string." | ||
[reference {:keys [version] :as _workload}] | ||
(letfn [(decode [v] (map util/parse-int (str/split v #"\."))) | ||
(lt? [[x & xs] [y & ys]] | ||
(or (< x y) (and (== x y) (every? some? [xs ys]) (lt? xs ys))))] | ||
(lt? (decode version) (decode reference)))) |
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.
I think this implementation is over-complicated but I'm not sure how to simplify. Suggestions welcome.
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.
Will try.
As an aside - if they don't document if, I don't think we should. (i.e. we document that you can pass workflow options, just not what they are.) |
(update m :workflow_options #(when % (util/parse-json %))))] | ||
(let [keep [:id :finished :status :updated :uuid :options]] | ||
(assoc (select-keys m keep) :inputs (apply dissoc m keep)))) | ||
(load-options [m] (update m :options (fnil util/parse-json "null")))] |
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 the fnil
'ness into parse-json
would make that harder to detect.
api/src/wfl/api/workloads.clj
Outdated
(defn saved-before? | ||
"Test if the `_workload` was saved before the `reference` version string." | ||
[reference {:keys [version] :as _workload}] | ||
(letfn [(decode [v] (map util/parse-int (str/split v #"\."))) | ||
(lt? [[x & xs] [y & ys]] | ||
(or (< x y) (and (== x y) (every? some? [xs ys]) (lt? xs ys))))] | ||
(lt? (decode version) (decode reference)))) |
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.
Will try.
In this change:
WGS
skip-workflow?
to handle bams as well!Database changes:
CromwellWorkflow
tableAPI changes
workflowOptions
andcommon_inputs
into a "common" map:common { :inputs {} :options {}}
, whereoptions
areworkflowOptions
renamed.Serialisation change
Puzzles:
reference_fasta_prefix
and how that should tie in with being able to specify any input.Not included