DorisAmoakohene / Researchwork_Rdata.table

0 stars 0 forks source link

issue #3928 #5

Open DorisAmoakohene opened 10 months ago

DorisAmoakohene commented 10 months ago

@tdhock

 Error in git2r::checkout(repo, branch = sha, force = TRUE): 'branch' must be a character vector of length one
 when trying to checkout 4

Kindly assist me in debugging this error. These are the link issues I am trying to reproduce

https://github.com/Rdatatable/data.table/issues/3928

https://github.com/Rdatatable/data.table/issues/3928#issuecomment-651408089

my atime code

atime.list <- atime::atime_versions(
pkg.path=tdir,
pkg.edit.fun=function(old.Package, new.Package, sha, new.pkg.path){
      pkg_find_replace <- function(glob, FIND, REPLACE){
        atime::glob_find_replace(file.path(new.pkg.path, glob), FIND, REPLACE)
      }
      Package_regex <- gsub(".", "_?", old.Package, fixed=TRUE)
      Package_ <- gsub(".", "_", old.Package, fixed=TRUE)
      new.Package_ <- paste0(Package_, "_", sha)
      pkg_find_replace(
        "DESCRIPTION", 
        paste0("Package:\\s+", old.Package),
        paste("Package:", new.Package))
      pkg_find_replace(
        file.path("src","Makevars.*in"),
        Package_regex,
        new.Package_)
      pkg_find_replace(
        file.path("R", "onLoad.R"),
        Package_regex,
        new.Package_)
      pkg_find_replace(
        file.path("R", "onLoad.R"),
        sprintf('packageVersion\\("%s"\\)', old.Package),
        sprintf('packageVersion\\("%s"\\)', new.Package))
      pkg_find_replace(
        file.path("src", "init.c"),
        paste0("R_init_", Package_regex),
        paste0("R_init_", gsub("[.]", "_", new.Package_)))
      pkg_find_replace(
        "NAMESPACE",
        sprintf('useDynLib\\("?%s"?', Package_regex),
        paste0('useDynLib(', new.Package_))
    },
  N=10^seq(3,8),
setDTthreads(2L),
  setup={ 
    set.seed(108)
    n2 = 1:N
    n1 = sample(n2, N)
    d1=data.table(id1=paste0("id",sample(n1)), id2=paste0("id",sample(n1)), v1=n1)
    d2=data.table(id1=paste0("id",sample(n2)), id2=paste0("id",sample(n2)), v2=n2)
  },
  expr=data.table:::`[.data.table`(d2(d1, v1 := i.v1, on=c("id1","id2"))),
  "Before"="8b201fd28f5d4afcc4be026a5d9eb4bb6dd62955",#https://github.com/Rdatatable/data.table/commit/8b201fd28f5d4afcc4be026a5d9eb4bb6dd62955
  "Regression"="e0140eafa07ad39a7ac9d67737cc43c4c95ca935")

the setup code

library(data.table)
setDTthreads(2L)
set.seed(108)
n2 = 1:366000
n1 = sample(n2, 30000)
d1=data.table(id1=paste0("id",sample(n1)), id2=paste0("id",sample(n1)), v1=n1)
d2=data.table(id1=paste0("id",sample(n2)), id2=paste0("id",sample(n2)), v2=n2)
system.time(d2[d1, v1 := i.v1, on=c("id1","id2")])

Traceback

9: stop(e, " when trying to checkout ", sha)
8: value[[3L]](cond)
7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
6: tryCatchList(expr, classes, parentenv, handlers)
5: tryCatch(git2r::checkout(repo, branch = sha, force = TRUE), error = function(e) stop(e, 
       " when trying to checkout ", sha))
4: atime_versions_install(Package, pkg.path, new.Package.vec, SHA.vec, 
       verbose, pkg.edit.fun)
3: (function (pkg.path, expr, sha.vec = NULL, verbose = FALSE, pkg.edit.fun = pkg.edit.default, 
       ...) 
   {
       formal.names <- names(formals())
       mc.args <- as.list(match.call()[-1])
       dots.vec <- mc.args[!names(mc.args) %in% formal.names]
       SHA.vec <- c(dots.vec, sha.vec)
       if (length(SHA.vec) == 0) {
           stop("need to specify at least one git SHA, in either sha.vec, or ...")
       }
       pkg.DESC <- file.path(pkg.path, "DESCRIPTION")
       DESC.mat <- read.dcf(pkg.DESC)
       Package <- DESC.mat[, "Package"]
       new.Package.vec <- paste0(Package, ifelse(SHA.vec == "", 
           "", "."), SHA.vec)
       atime_versions_install(Package, pkg.path, new.Package.vec, 
           SHA.vec, verbose, pkg.edit.fun)
       a.args <- list()
       for (commit.i in seq_along(SHA.vec)) {
           sha <- SHA.vec[[commit.i]]
    ...
2: do.call(atime_versions_exprs, ver.args)
1: atime::atime_versions(pkg.path = tdir, pkg.edit.fun = function(old.Package, 
       new.Package, sha, new.pkg.path) {
       pkg_find_replace <- function(glob, FIND, REPLACE) {
           atime::glob_find_replace(file.path(new.pkg.path, glob), 
               FIND, REPLACE)
       }
       Package_regex <- gsub(".", "_?", old.Package, fixed = TRUE)
       Package_ <- gsub(".", "_", old.Package, fixed = TRUE)
       new.Package_ <- paste0(Package_, "_", sha)
       pkg_find_replace("DESCRIPTION", paste0("Package:\\s+", old.Package), 
           paste("Package:", new.Package))
       pkg_find_replace(file.path("src", "Makevars.*in"), Package_regex, 
           new.Package_)
       pkg_find_replace(file.path("R", "onLoad.R"), Package_regex, 
           new.Package_)
       pkg_find_replace(file.path("R", "onLoad.R"), sprintf("packageVersion\\(\"%s\"\\)", 
           old.Package), sprintf("packageVersion\\(\"%s\"\\)", new.Package))
       pkg_find_replace(file.path("src", "init.c"), paste0("R_init_", 
           Package_regex), paste0("R_init_", gsub("[.]", "_", new.Package_)))
       pkg_find_replace("NAMESPACE", sprintf("useDynLib\\(\"?%s\"?", 
    ...
tdhock commented 10 months ago

it looks like one of the arguments that should be a version, evaluates to 4. Can you please show me the prompt, command, and output from the R terminal? (you did not show me the prompt and command prior to the error, so it is difficult for me to understand what code gives that error.

> command()
output

An easy way to do this is using https://reprex.tidyverse.org/ which I have told you about many times, so can you please do that?

tdhock commented 10 months ago

it looks like your issue may be that setDTthreads(2L) is being provided as an argument to atime_versions, so that may be interpreted as a version?

tdhock commented 10 months ago

I get an error message with most recent version of atime,

> atime.list <- atime::atime_versions(
+ pkg.path="~/R/data.table",
+ pkg.edit.fun=function(old.Package, new.Package, sha, new.pkg.path){
+ pkg_find_replace <- function(glob, FIND, REPLACE){
+ atime::glob_find_replace(file.path(new.pkg.path, glob), FIND, REPLACE)
+ }
+ Package_regex <- gsub(".", "_?", old.Package, fixed=TRUE)
+ Package_ <- gsub(".", "_", old.Package, fixed=TRUE)
+ new.Package_ <- paste0(Package_, "_", sha)
+ pkg_find_replace(
+ "DESCRIPTION",
+ paste0("Package:\\s+", old.Package),
+ paste("Package:", new.Package))
+ pkg_find_replace(
+ file.path("src","Makevars.*in"),
+ Package_regex,
+ new.Package_)
+ pkg_find_replace(
+ file.path("R", "onLoad.R"),
+ Package_regex,
+ new.Package_)
+ pkg_find_replace(
+ file.path("R", "onLoad.R"),
+ sprintf('packageVersion\\("%s"\\)', old.Package),
+ sprintf('packageVersion\\("%s"\\)', new.Package))
+ pkg_find_replace(
+ file.path("src", "init.c"),
+ paste0("R_init_", Package_regex),
+ paste0("R_init_", gsub("[.]", "_", new.Package_)))
+ pkg_find_replace(
+ "NAMESPACE",
+ sprintf('useDynLib\\("?%s"?', Package_regex),
+ paste0('useDynLib(', new.Package_))
+ },
+ N=10^seq(3,8),
+ setDTthreads(2L),
+ setup={
+ set.seed(108)
+ n2 = 1:N
+ n1 = sample(n2, N)
+ d1=data.table(id1=paste0("id",sample(n1)), id2=paste0("id",sample(n1)), v1=n1)
+ d2=data.table(id1=paste0("id",sample(n2)), id2=paste0("id",sample(n2)), v2=n2)
+ },
+ expr=data.table:::`[.data.table`(d2(d1, v1 := i.v1, on=c("id1","id2"))),
+ "Before"="8b201fd28f5d4afcc4be026a5d9eb4bb6dd62955",#https://github.com/Rdatatable/data.table/commit/8b201fd28f5d4afcc4be026a5d9eb4bb6dd62955
+ "Regression"="e0140eafa07ad39a7ac9d67737cc43c4c95ca935")
Erreur dans get_sha_vec(sha.vec, dots.vec) : 
  each ... argument and sha.vec element must be named
> packageVersion("atime")
[1] ‘2023.11.11’
DorisAmoakohene commented 10 months ago

ret

  "``` r"                                                                                                                                              
   atime.list <- atime::atime_versions("                                                                                                             
 pkg.path=tdir,"                                                                                                                                     
  "pkg.edit.fun=function(old.Package, new.Package, sha, new.pkg.path){"                                                                                
  pkg_find_replace <- function(glob, FIND, REPLACE){"                                                                                           
 atime::glob_find_replace(file.path(new.pkg.path, glob), FIND, REPLACE)"                                                                     
  "      }"                                                                                                                                            
 "      Package_regex <- gsub(\".\", \"_?\", old.Package, fixed=TRUE)"                                                                                
  "      Package_ <- gsub(\".\", \"_\", old.Package, fixed=TRUE)"                                                                                      
new.Package_ <- paste0(Package_, \"_\", sha)"                                                                                                 
pkg_find_replace("                                                                                                                            
\"DESCRIPTION\", "                                                                                                                          
paste0(\"Package:\\\\s+\", old.Package),"                                                                                                   
paste(\"Package:\", new.Package))"                                                                                                          
pkg_find_replace("                                                                                                                            
file.path(\"src\",\"Makevars.*in\"),"                                                                                                       
 Package_regex,"                                                                                                                             
new.Package_)"                                                                                                                              
pkg_find_replace("                                                                                                                            
file.path(\"R\", \"onLoad.R\"),"                                                                                                            
Package_regex,"                                                                                                                             
new.Package_)"                                                                                                                              
pkg_find_replace("                                                                                                                            
file.path(\"R\", \"onLoad.R\"),"                                                                                                            
sprintf('packageVersion\\\\(\"%s\"\\\\)', old.Package),"                                                                                    
sprintf('packageVersion\\\\(\"%s\"\\\\)', new.Package))"                                                                                    
pkg_find_replace("                                                                                                                            
file.path(\"src\", \"init.c\"),"                                                                                                            
paste0(\"R_init_\", Package_regex),"                                                                                                        
paste0(\"R_init_\", gsub(\"[.]\", \"_\", new.Package_)))"                                                                                   
pkg_find_replace("                                                                                                                            
 \"NAMESPACE\","                                                                                                                             
sprintf('useDynLib\\\\(\"?%s\"?', Package_regex),"                                                                                          
paste0('useDynLib(', new.Package_))"                                                                                                        
},"                                                                                                                                             
N=10^seq(3,8),"                                                                                                                                   
"setDTthreads(2L),"                                                                                                                                  
 setup={ "                                                                                                                                         
set.seed(108)"                                                                                                                                  
 n2 = 1:N"                                                                                                                                       
n1 = sample(n2, N)"                                                                                                                             
d1=data.table(id1=paste0(\"id\",sample(n1)), id2=paste0(\"id\",sample(n1)), v1=n1)"                                                             
d2=data.table(id1=paste0(\"id\",sample(n2)), id2=paste0(\"id\",sample(n2)), v2=n2)"                                                             
"  },"                                                                                                                                               
expr=data.table:::`[.data.table`(d2(d1, v1 := i.v1, on=c(\"id1\",\"id2\"))),"                                                                     
 \"Before\"=\"8b201fd28f5d4afcc4be026a5d9eb4bb6dd62955\",#https://github.com/Rdatatable/data.table/commit/8b201fd28f5d4afcc4be026a5d9eb4bb6dd62955"
\"Regression\"=\"e0140eafa07ad39a7ac9d67737cc43c4c95ca935\")"                                                                                     
#> Error in eval(expr, envir, enclos): object 'tdir' not found"                                                                                     
 "```"                                                                                                                                                
""                                                                                                                                                   
 <sup>Created on 2023-11-17 with [reprex v2.0.2.9000](https://reprex.tidyverse.org)</sup>"  
tdhock commented 10 months ago

hi, can you please make sure the code and output are formatted correctly? it looks like your code is incomplete (tdir not found) but it is difficult to read because you did not format it correctly.

tdhock commented 10 months ago
plot(1:10, xlab = stop("problem"))
#> Error in plot.default(1:10, xlab = stop("problem")): problem

Created on 2023-11-21 with reprex v2.0.2

tdhock commented 10 months ago
plot(1:10, xlab = stop("another problem"))
#> Error in plot.default(1:10, xlab = stop("another problem")): another problem

Created on 2023-11-21 with reprex v2.0.2