Skip to content
Permalink
Browse files

Added enableSuggestions parameter for faster repo_get

  • Loading branch information...
Ciccio
Ciccio committed Dec 3, 2018
1 parent ca078e9 commit 5858340a9bd1493d25656866929935c80419d360
Showing with 33 additions and 15 deletions.
  1. +1 −1 DESCRIPTION
  2. +20 −12 R/repo_public.R
  3. +6 −1 man/repo_get.Rd
  4. +6 −1 tests/testthat/testrepo.R
@@ -1,7 +1,7 @@
Package: repo
Type: Package
Title: A Data-Centered Data Flow Manager
Version: 2.1.3
Version: 2.1.3.1
Date: 2018-5-4
Author: Francesco Napolitano <franapoli@gmail.com>
Maintainer: Francesco Napolitano <franapoli@gmail.com>
@@ -949,6 +949,10 @@ repo_build <- function(name, src=NULL, recursive=T, force=F, env=parent.frame(),
#' Retrieve an item from the repo.
#'
#' @param name An item's name.
#' @param enableSuggestions If set to TRUE (default), enables some
#' checks on \code{name} that are meant to gracefully handle
#' errors and provide suggestions of similar names. If FALSE, the
#' execution will be significantly faster in large repositories.
#' @return The previously stored object, or its file system path for
#' attachments.
#' @examples
@@ -959,21 +963,25 @@ repo_build <- function(name, src=NULL, recursive=T, force=F, env=parent.frame(),
#'
#' ## wiping temporary repo
#' unlink(rp_path, TRUE)
repo_get <- function(name)

repo_get <- function(name, enableSuggestions=T)
{
name <- forkedName(name)
if(checkName(name)){
enames <- sapply(entries, get, x="name")
x <- agrep(name, enames)
if(length(x)>0) {
x <- x[abs(sapply(enames[x],nchar) - nchar(name))<=3]
message(paste0(
"Maybe you were looking for: ",
paste0(enames[x], collapse=", ")
))

if(enableSuggestions) {
if(checkName(name)){
enames <- sapply(entries, get, x="name")
x <- agrep(name, enames)
if(length(x)>0) {
x <- x[abs(sapply(enames[x],nchar) - nchar(name))<=3]
message(paste0(
"Maybe you were looking for: ",
paste0(enames[x], collapse=", ")
))
}
handleErr("ID_NOT_FOUND", name)
return(invisible())
}
handleErr("ID_NOT_FOUND", name)
return(invisible())
}
entry <- getEntry(name)
root <- get("root",thisEnv)

Some generated files are not rendered by default. Learn more.

@@ -1,3 +1,7 @@
## Workflow
## library(devtools)
## library(testthat)

##############
context("global functions")
##############
@@ -76,7 +80,8 @@ test_that("lazydo building and loading", {
expect_equal(rp$get(names(rp$entries())[[2]]), 2*10+80)
expect_message(cached <- rp$lazydo(2*10+80), ".*precomputed.*")
expect_equal(cached, 2*10+80)
expect_message(rp$lazydo(expr, force=T), ".*building.*")
expect_message(rp$lazydo(100), ".*building.*")
expect_message(rp$lazydo(2*10+80, force=T), ".*building.*")
})

wipe_test_repo("repo1")

0 comments on commit 5858340

Please sign in to comment.
You can’t perform that action at this time.