Skip to content

Commit b55b172

Browse files
committed
Fix #1345
1 parent 7954fdd commit b55b172

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Description: Pipeline tools coordinate the pieces of computationally
1212
The methodology in this package
1313
borrows from GNU 'Make' (2015, ISBN:978-9881443519)
1414
and 'drake' (2018, <doi:10.21105/joss.00550>).
15-
Version: 1.8.0.9002
15+
Version: 1.8.0.9003
1616
License: MIT + file LICENSE
1717
URL: https://docs.ropensci.org/targets/, https://github.com/ropensci/targets
1818
BugReports: https://github.com/ropensci/targets/issues

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# targets 1.8.0.9002 (development)
1+
# targets 1.8.0.9003 (development)
22

33
* Un-break workflows that use `format = "file_fast"` (#1339, @koefoeden).
44
* Fix deadlock in `error = "trim"` (#1340, @koefoeden).
55
* Remove tailored debugging message (#1341, @koefoeden).
6+
* Store warnings while writing to storage (#1345, @Aariq).
67

78
# targets 1.8.0
89

R/class_builder.R

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ target_conclude.tar_builder <- function(target, pipeline, scheduler, meta) {
189189
on.exit(builder_unset_tar_runtime())
190190
builder_set_tar_runtime(target, NULL)
191191
target_update_queue(target, scheduler)
192-
builder_handle_warnings(target, scheduler)
193192
builder_ensure_workspace(
194193
target = target,
195194
pipeline = pipeline,
@@ -198,6 +197,7 @@ target_conclude.tar_builder <- function(target, pipeline, scheduler, meta) {
198197
)
199198
builder_ensure_object(target, "main")
200199
builder_ensure_correct_hash(target)
200+
builder_handle_warnings(target, scheduler)
201201
switch(
202202
metrics_outcome(target$metrics),
203203
cancel = builder_cancel(target, pipeline, scheduler, meta),
@@ -453,7 +453,19 @@ builder_update_object <- function(target) {
453453
on.exit(builder_unload_value(target))
454454
file_validate_path(target$store$file$path)
455455
if (!identical(target$settings$storage, "none")) {
456-
store_write_object(target$store, target$value$object)
456+
withCallingHandlers(
457+
store_write_object(target$store, target$value$object),
458+
warning = function(condition) {
459+
if (length(target$metrics$warnings) < 51L) {
460+
target$metrics$warnings <- paste(
461+
c(target$metrics$warnings, build_message(condition)),
462+
collapse = ". "
463+
)
464+
}
465+
warning(as_immediate_condition(condition))
466+
invokeRestart("muffleWarning")
467+
}
468+
)
457469
}
458470
store_hash_late(target$store)
459471
store_upload_object(target$store)

tests/testthat/test-class_builder.R

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,3 +706,34 @@ tar_test("error = \"trim\" on a dynamic branch", {
706706
progress <- tar_progress(names = tidyselect::any_of(names))
707707
expect_equal(unique(progress$progress), "skipped")
708708
})
709+
710+
tar_test("capture storage warnings", {
711+
skip_cran()
712+
tar_script(
713+
list(
714+
tar_target(
715+
x, {
716+
warning("run_warning")
717+
123L
718+
},
719+
format = tar_format(
720+
read = function(path) {
721+
readRDS(path)
722+
},
723+
write = function(object, path) {
724+
warning("storage_warning")
725+
saveRDS(object, path)
726+
}
727+
)
728+
)
729+
)
730+
)
731+
suppressWarnings(
732+
expect_warning(
733+
tar_make(callr_function = NULL),
734+
class = "tar_condition_run"
735+
)
736+
)
737+
expect_equal(tar_read(x), 123L)
738+
expect_equal(tar_meta(x)$warnings, "run_warning. storage_warning")
739+
})

0 commit comments

Comments
 (0)