Skip to content

Commit 9f3e15a

Browse files
author
Myron Ahn
committed
Temp targets #88 address all of Aaron's code review items
#106 Standardize on name "temp targets" Use -> for cleaner code Add comments for ramifications of error when deleting temp target Also: made sure temp target testing is in the regtest suite
1 parent 5359d4e commit 9f3e15a

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

resources/regtest/run-all.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ if ($(dirname $0)/regtest_fs.sh &&
88
$(dirname $0)/regtest_inputs_outputs.sh &&
99
$(dirname $0)/regtest_methods.sh &&
1010
$(dirname $0)/regtest_protocol_eval.sh &&
11-
$(dirname $0)/regtest_s3.sh); then
11+
$(dirname $0)/regtest_s3.sh &&
12+
$(dirname $0)/regtest_temp.sh); then
1213
echo "run-all: ALL TESTS PASSED"
1314
else
1415
echo "run-all: SOME TESTS FAILED"

src/drake/core.clj

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@
183183
temp-outputs (step :temp-outputs)
184184
temp-input-map-lookup (parse-tree :temp-input-map-lookup)
185185
[existing-temp-outputs empty-temp-outputs] (split-with data-in? temp-outputs)
186-
empty-temp-output-step-deps (map (comp temp-input-map-lookup normalized-path) empty-temp-outputs)
187-
empty-temp-output-step-deps (flatten empty-temp-output-step-deps)
188-
empty-temp-output-step-deps (filter step-set empty-temp-output-step-deps)
189-
expanded-temp-outputs (map (comp (partial expand-outputs parse-tree step-list) steps)
190-
empty-temp-output-step-deps)
191-
expanded-temp-outputs (flatten expanded-temp-outputs)
192-
]
186+
empty-temp-output-step-deps (->> empty-temp-outputs
187+
(map (comp temp-input-map-lookup normalized-path))
188+
flatten
189+
(filter step-set))
190+
expanded-temp-outputs (->> empty-temp-output-step-deps
191+
(map (comp (partial expand-outputs parse-tree step-list) steps))
192+
flatten)]
193193
(trace "expand-outputs step:" step)
194194
(trace "expand-outputs step-list:" step-list)
195195
(trace "expand-outputs existing-temp-outputs:" existing-temp-outputs)
@@ -617,22 +617,26 @@
617617
(when (not (empty? trimmed-deps))
618618
(future
619619
(try
620-
(trace "Running future for file" file "deps" trimmed-deps)
620+
(trace "Running future to delete target:" file "dependencies:" trimmed-deps)
621621
(let [successful-deps-count (reduce +
622622
(map (fn [i]
623623
@((steps-map i) :promise))
624624
trimmed-deps))]
625-
(trace "Finished waiting for dependents of file"
625+
(trace "Finished waiting for dependents of target:"
626626
file
627-
"deps"
627+
"dependencies:"
628628
trimmed-deps
629-
"successful-count"
629+
"successful-count:"
630630
successful-deps-count)
631631
(when (= successful-deps-count (count trimmed-deps))
632-
(info "Deleting temp file:" file)
632+
(info "Deleting temp target:" file)
633633
(fs di/rm file)))
634634
(catch Exception e
635-
(error e "Future for file" file "Caught exception")))))))))
635+
; Likely to happen if there is some problem with deleting the file.
636+
; Catch the exception and inform the user of the problem,
637+
; but do not hald execution as deletion of the file is probably not
638+
; critical to the workflow.
639+
(error e "Exception deleting temp target:" file)))))))))
636640

637641
(defn- run-steps-async
638642
"Runs steps asynchronously.
@@ -662,7 +666,7 @@
662666
assoc-promise
663667
(assoc-function parse-tree))]
664668

665-
(when (not (:keep-temp-files *options*))
669+
(when (not (:keep-temp-targets *options*))
666670
(setup-temp-deleting-futures parse-tree steps-future))
667671

668672
(post event-bus (EventWorkflowBegin steps-data))
@@ -995,8 +999,8 @@
995999
"Turn on even more verbose debugging output.")
9961000
(no-arg version
9971001
"Show version information.")
998-
(no-arg keep-temp-files
999-
"Do not auto-delete temp files")
1002+
(no-arg keep-temp-targets
1003+
"Do not auto-delete temp targets")
10001004
(with-arg tmpdir
10011005
"Specifies the temporary directory for Drake files (by default, .drake/ in the same directory the main workflow file is located)."
10021006
:type :str

0 commit comments

Comments
 (0)