Skip to content
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: orderly
Title: Lightweight Reproducible Reporting
Version: 1.4.4
Version: 1.4.5
Description: Order, create and store reports from R. By defining a
lightweight interface around the inputs and outputs of an
analysis, a lot of the repetitive work for reproducible research
Expand Down
14 changes: 12 additions & 2 deletions R/deduplicate.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ orderly_deduplicate <- function(root = NULL, locate = TRUE, dry_run = TRUE,


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

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

## Quick check:
stopifnot(all(vlapply(split(files, files$hash), function(x)
all(x$inode_first == x$inode[[1]]))))
can_deduplicate <- all(vlapply(split(files, files$hash), function(x) {
isTRUE(all(x$inode_first == x$inode[[1]]))
}))
if (!can_deduplicate) {
stop(paste("Cannot deduplicate archive as database references files",
"which don't exist."))
}

## Classify the files into different states
files$state <- rep("distinct", nrow(files))
Expand Down
2 changes: 2 additions & 0 deletions docker/build_website
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ DB_NAME=orderly
SCHEMASPY_NAME=vimc/orderly-schemaspy

DOCS_DIR=$PACKAGE_ROOT/docs
VIGNETTES_DIR=$PACKAGE_ROOT/vignettes

docker build \
--build-arg ORDERLY_BASE=$ORDERLY_BASE \
Expand Down Expand Up @@ -65,6 +66,7 @@ docker run --rm \
--network=$DB_NW \
-w /orderly \
-v $DOCS_DIR:/orderly/docs \
-v $VIGNETTES_DIR:/orderly/vignettes \
--user "$USER_STR" \
$ORDERLY_DEV \
Rscript -e 'pkgdown::build_site(document = FALSE)'
Expand Down
29 changes: 29 additions & 0 deletions tests/testthat/test-deduplicate.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,32 @@ test_that("relink error handling", {
expect_error(relink(from, to), "Some error linking")
expect_true(all(fs::file_info(c(from, to))$inode == info))
})


test_that("deduplicate fails if file is missing", {
skip_on_cran()
path <- orderly_example("demo")
id1 <- orderly_run("minimal", root = path, echo = FALSE)
id2 <- orderly_run("minimal", root = path, echo = FALSE)
orderly_commit(id1, root = path)
orderly_commit(id2, root = path)

unlink(file.path(path, "archive", "minimal", id1, "script.R"))

expect_error(orderly_deduplicate_info(orderly_config(path)), paste(
"Cannot deduplicate archive as database references files",
"which don't exist."))
})

test_that("deduplicate fails if report pulled from remote recursive FALSE", {
skip_on_cran()
dat <- prepare_orderly_remote_example()
id3 <- orderly_run("depend", root = dat$path_remote, echo = FALSE)
orderly_commit(id3, root = dat$path_remote)

orderly_pull_archive("depend", root = dat$config, remote = dat$remote,
recursive = FALSE)
expect_error(orderly_deduplicate_info(dat$config), paste(
"Cannot deduplicate archive reports have been pulled from",
"remote with recursive = FALSE."))
})