Skip to content

Commit 33a6e80

Browse files
authored
Merge pull request #308 from vimc/vimc-3823
2 parents da6bd5d + 9fd642d commit 33a6e80

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: orderly
22
Title: Lightweight Reproducible Reporting
3-
Version: 1.4.4
3+
Version: 1.4.5
44
Description: Order, create and store reports from R. By defining a
55
lightweight interface around the inputs and outputs of an
66
analysis, a lot of the repetitive work for reproducible research

R/deduplicate.R

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ orderly_deduplicate <- function(root = NULL, locate = TRUE, dry_run = TRUE,
6868

6969

7070
orderly_deduplicate_info <- function(config) {
71+
report_metadata <- list.files(path_metadata(config$root))
72+
if (length(report_metadata) > 0) {
73+
stop(paste("Cannot deduplicate archive reports have been pulled from",
74+
"remote with recursive = FALSE."))
75+
}
7176
con <- orderly_db("destination", config)
7277
on.exit(DBI::dbDisconnect(con))
7378

@@ -98,8 +103,13 @@ orderly_deduplicate_info <- function(config) {
98103
unname(tapply(files$inode, files$hash, function(x) x[[1L]]))[i]
99104

100105
## Quick check:
101-
stopifnot(all(vlapply(split(files, files$hash), function(x)
102-
all(x$inode_first == x$inode[[1]]))))
106+
can_deduplicate <- all(vlapply(split(files, files$hash), function(x) {
107+
isTRUE(all(x$inode_first == x$inode[[1]]))
108+
}))
109+
if (!can_deduplicate) {
110+
stop(paste("Cannot deduplicate archive as database references files",
111+
"which don't exist."))
112+
}
103113

104114
## Classify the files into different states
105115
files$state <- rep("distinct", nrow(files))

docker/build_website

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ DB_NAME=orderly
2222
SCHEMASPY_NAME=vimc/orderly-schemaspy
2323

2424
DOCS_DIR=$PACKAGE_ROOT/docs
25+
VIGNETTES_DIR=$PACKAGE_ROOT/vignettes
2526

2627
docker build \
2728
--build-arg ORDERLY_BASE=$ORDERLY_BASE \
@@ -65,6 +66,7 @@ docker run --rm \
6566
--network=$DB_NW \
6667
-w /orderly \
6768
-v $DOCS_DIR:/orderly/docs \
69+
-v $VIGNETTES_DIR:/orderly/vignettes \
6870
--user "$USER_STR" \
6971
$ORDERLY_DEV \
7072
Rscript -e 'pkgdown::build_site(document = FALSE)'

tests/testthat/test-deduplicate.R

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,32 @@ test_that("relink error handling", {
172172
expect_error(relink(from, to), "Some error linking")
173173
expect_true(all(fs::file_info(c(from, to))$inode == info))
174174
})
175+
176+
177+
test_that("deduplicate fails if file is missing", {
178+
skip_on_cran()
179+
path <- orderly_example("demo")
180+
id1 <- orderly_run("minimal", root = path, echo = FALSE)
181+
id2 <- orderly_run("minimal", root = path, echo = FALSE)
182+
orderly_commit(id1, root = path)
183+
orderly_commit(id2, root = path)
184+
185+
unlink(file.path(path, "archive", "minimal", id1, "script.R"))
186+
187+
expect_error(orderly_deduplicate_info(orderly_config(path)), paste(
188+
"Cannot deduplicate archive as database references files",
189+
"which don't exist."))
190+
})
191+
192+
test_that("deduplicate fails if report pulled from remote recursive FALSE", {
193+
skip_on_cran()
194+
dat <- prepare_orderly_remote_example()
195+
id3 <- orderly_run("depend", root = dat$path_remote, echo = FALSE)
196+
orderly_commit(id3, root = dat$path_remote)
197+
198+
orderly_pull_archive("depend", root = dat$config, remote = dat$remote,
199+
recursive = FALSE)
200+
expect_error(orderly_deduplicate_info(dat$config), paste(
201+
"Cannot deduplicate archive reports have been pulled from",
202+
"remote with recursive = FALSE."))
203+
})

0 commit comments

Comments
 (0)