Skip to content
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-1125] Don't finish unstarted workloads #296

Merged
merged 3 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions api/src/wfl/service/postgres.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@
(defn update-workload-status!
"Use `tx` to mark `workload` finished when all `workflows` are finished."
[tx {:keys [id items] :as _workload}]
(let [query (format "SELECT id FROM %%s WHERE status NOT IN %s"
(let [query (format "SELECT id FROM %%s WHERE status IS NULL OR status NOT IN %s"
jack-r-warren marked this conversation as resolved.
Show resolved Hide resolved
(util/to-quoted-comma-separated-list finished?))]
(when (empty? (jdbc/query tx (format query items)))
(jdbc/update! tx :workload
{:finished (OffsetDateTime/now)} ["id = ?" id]))))

(defn update-workload!
"Use transaction TX to update WORKLOAD statuses."
"Use transaction TX to update WORKLOAD statuses if it has been started."
[tx workload]
(do
(update-workflow-statuses! tx workload)
(update-workload-status! tx workload)))
(if (and (:started workload) (not (:finished workload)))
(do
(update-workflow-statuses! tx workload)
(update-workload-status! tx workload))))
7 changes: 7 additions & 0 deletions api/test/wfl/integration/modules/aou_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
(is (s/valid? :wfl.api.spec/append-to-aou-response response))
(is (empty? response)))))))

(deftest test-update-unstarted
(let [workload (->> (make-aou-workload-request)
workloads/create-workload!
workloads/update-workload!)]
(is (nil? (:finished workload)))
(is (nil? (:submitted workload)))))

(deftest test-append-to-aou-not-started
(with-redefs-fn {#'aou/submit-aou-workflow mock-submit-workload}
#(is
Expand Down
7 changes: 7 additions & 0 deletions api/test/wfl/integration/modules/arrays_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
workloads/create-workload!)]
(run! check-inputs (:workflows workload))))

(deftest test-update-unstarted
(let [workload (->> (make-arrays-workload-request)
workloads/create-workload!
workloads/update-workload!)]
(is (nil? (:finished workload)))
(is (nil? (:submitted workload)))))

(deftest test-start-arrays-workload!
(with-redefs-fn {#'terra/create-submission mock-terra-create-submission}
#(let [workload (-> (make-arrays-workload-request)
Expand Down
7 changes: 7 additions & 0 deletions api/test/wfl/integration/modules/copyfile_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
(jdbc/update! tx :workload {:version "0.3.8"} ["id = ?" id])
id))))

(deftest test-update-unstarted
(let [workload (->> (make-copyfile-workload-request "gs://fake/input" "gs://fake/output")
workloads/create-workload!
workloads/update-workload!)]
(is (nil? (:finished workload)))
(is (nil? (:submitted workload)))))

(deftest test-loading-old-copyfile-workload
(let [id (old-create-copyfile-workload!)
workload (workloads/load-workload-for-id id)]
Expand Down
7 changes: 7 additions & 0 deletions api/test/wfl/integration/modules/sg_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
(testing "single-sample workload-request"
(go! (make-sg-workload-request)))))

(deftest test-update-unstarted
(let [workload (->> (make-sg-workload-request)
workloads/create-workload!
workloads/update-workload!)]
(is (nil? (:finished workload)))
(is (nil? (:submitted workload)))))

(deftest test-create-workload-with-common-inputs
(let [common-inputs {:biobambam_bamtofastq.max_retries 2
:ref_pac "gs://fake-location/temp_references/gdc/GRCh38.d1.vd1.fa.pac"}]
Expand Down
7 changes: 7 additions & 0 deletions api/test/wfl/integration/modules/wgs_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@
"Inputs are not at the top-level"))]
(run! check-nesting (:workflows workload))))))

(deftest test-update-unstarted
(let [workload (->> (make-wgs-workload-request)
workloads/create-workload!
workloads/update-workload!)]
(is (nil? (:finished workload)))
(is (nil? (:submitted workload)))))

(defn ^:private old-create-wgs-workload! []
(let [request (make-wgs-workload-request)]
(jdbc/with-db-transaction [tx (fixtures/testing-db-config)]
Expand Down
7 changes: 7 additions & 0 deletions api/test/wfl/integration/modules/xx_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@
workloads/update-workload!)]
(is (:finished workload))))

(deftest test-update-unstarted
(let [workload (->> (make-xx-workload-request)
workloads/create-workload!
workloads/update-workload!)]
(is (nil? (:finished workload)))
(is (nil? (:submitted workload)))))

(deftest test-submitted-workflow-inputs
(letfn [(prefixed? [prefix key] (str/starts-with? (str key) (str prefix)))
(strip-prefix [[k v]]
Expand Down