Closed krlmlr closed 6 years ago
A tiny project of mine had this problem too, but then I restarted the R session and it went away. I am struggling to reproduce it.
> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.9 (Santiago)
Matrix products: default
BLAS: /[censored]/R-3.4.0/lib64/R/lib/libRblas.so
LAPACK: /[censored]/R-3.4.0/lib64/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_US LC_NUMERIC=C LC_TIME=en_US
[4] LC_COLLATE=en_US LC_MONETARY=en_US LC_MESSAGES=en_US
[7] LC_PAPER=en_US LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] usethis_1.2.0.9000 testthat_2.0.0 devtools_1.13.4
loaded via a namespace (and not attached):
[1] CodeDepends_0.5-5.2 compiler_3.4.0 backports_1.1.2
[4] magrittr_1.5 R6_2.2.2 rprojroot_1.3-2
[7] withr_2.1.1.9000 memoise_1.1.0 codetools_0.2-15
[10] digest_0.6.15 rlang_0.2.0 XML_3.98-1.10
It fails reproducibly on my machine, Ubuntu 17.10, R 3.4.3.
@krlmlr what version of CodeDepends do you have? I'm unable to recreate that with the latest github version, in either the "dplyr was loaded" or "dplyr was not laoded" cases (which have radically different semantics, as you can see below.
> library(CodeDepends)
> getInputs(quote(filter(x)))
An object of class "ScriptNodeInfo"
Slot "files":
character(0)
Slot "strings":
character(0)
Slot "libraries":
character(0)
Slot "inputs":
[1] "x"
Slot "outputs":
character(0)
Slot "updates":
character(0)
Slot "functions":
filter
NA
Slot "removes":
character(0)
Slot "nsevalVars":
character(0)
Slot "sideEffects":
character(0)
Slot "code":
filter(x)
> thing = readScript(txt = "library(dplyr); filter(df, x)")
> getInputs(thing)
An object of class "ScriptInfo"
[[1]]
An object of class "ScriptNodeInfo"
Slot "files":
character(0)
Slot "strings":
character(0)
Slot "libraries":
[1] "dplyr"
Slot "inputs":
character(0)
Slot "outputs":
character(0)
Slot "updates":
character(0)
Slot "functions":
named logical(0)
Slot "removes":
character(0)
Slot "nsevalVars":
character(0)
Slot "sideEffects":
character(0)
Slot "code":
library(dplyr)
[[2]]
An object of class "ScriptNodeInfo"
Slot "files":
character(0)
Slot "strings":
character(0)
Slot "libraries":
character(0)
Slot "inputs":
[1] "df"
Slot "outputs":
character(0)
Slot "updates":
character(0)
Slot "functions":
filter
FALSE
Slot "removes":
character(0)
**Slot "nsevalVars":
[1] "x"**
Slot "sideEffects":
character(0)
Slot "code":
filter(df, x)
> getInputs(quote(filter(df, x)))
An object of class "ScriptNodeInfo"
Slot "files":
character(0)
Slot "strings":
character(0)
Slot "libraries":
character(0)
**Slot "inputs":
[1] "df" "x"**
Slot "outputs":
character(0)
Slot "updates":
character(0)
Slot "functions":
filter
NA
Slot "removes":
character(0)
Slot "nsevalVars":
character(0)
Slot "sideEffects":
character(0)
Slot "code":
filter(df, x)
Something is definitely amiss with filter()
:
library(drake)
library(tidyverse)
my_filter <- function(x) {
filter(x, cyl == 4)
}
failing_plan <- drake_plan(
new_mtcars = my_filter(mtcars)
)
make(failing_plan) # fails
## cache C:\Users\UrbanDesigner\AppData\Local\Temp\Rtmp2XZhXv\.drake
## connect 2 imports: my_filter, failing_plan
## Error in collector$vars: object of type 'closure' is not subsettable
But dplyr::filter()
works:
library(drake)
library(tidyverse)
my_other_filter <- function(x) {
dplyr::filter(x, cyl == 4)
}
working_plan <- drake_plan(
new_mtcars = my_other_filter(mtcars)
)
make(working_plan) # works
## cache C:\Users\UrbanDesigner\AppData\Local\Temp\Rtmpq6W0mq\.drake
## connect 2 imports: my_other_filter, working_plan
## connect 1 target: new_mtcars
## check 2 items: dplyr::filter, mtcars
## check 1 item: my_other_filter
## check 1 item: new_mtcars
## target new_mtcars
Could CodeDepends
be failing on a filter()
from another package?
CodeDepends does not evaluate any code, even to grab the formals currently, so I'm having trouble how it possibly could be. Worst I can easily imagine happending is that it gets the NSEness of some of the args wrong if it is wrong about which filter you're hitting.
On Feb 20, 2018 8:33 PM, "Will Landau" notifications@github.com wrote:
Could CodeDepends be failing on a filter() from another package?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ropensci/drake/issues/268#issuecomment-367210684, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3dsbGV09csweRIphJjmVLMzxwNymYCks5tW5yjgaJpZM4SMq4A .
Do note they are using an earlier version than the latest on github though. Can anyone reproduce thr problem with the current devel version?
On Feb 20, 2018 9:35 PM, "Gabe Becker" beckerg4@gene.com wrote:
CodeDepends does not evaluate any code, even to grab the formals currently, so I'm having trouble how it possibly could be. Worst I can easily imagine happending is that it gets the NSEness of some of the args wrong if it is wrong about which filter you're hitting.
On Feb 20, 2018 8:33 PM, "Will Landau" notifications@github.com wrote:
Could CodeDepends be failing on a filter() from another package?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ropensci/drake/issues/268#issuecomment-367210684, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3dsbGV09csweRIphJjmVLMzxwNymYCks5tW5yjgaJpZM4SMq4A .
Works for me with the GitHub version. I wasn't aware this package is on GitHub, I looked at its DESCRIPTION
only.
For the record I'll work in getting a new version of CodeDepends onto CRAN this week which will have this fix in it.
I just had the same problem. After updating CodeDepends, it worked. Maybe a minimal version dependency should be declared for CodeDepends
?
What about something a less strict, maybe suggesting a minimal version in this warning message? I hesitate to force a certain version of a package in order to patch an edge case.
I wonder though whether it had to do with filter()
in particular or whether it is a problem for all name space collisions. I think one also has to weight in the complexity that is added in the drake project when considering adding informative warning messages for these kinds of issues. But I mean it's up to you what to do. Just wanted to make sure this is somehow addressed.
@gmbecker: Do you still plan to update CodeDepends on CRAN?
@wlandau: Requiring a minimum package version seems like a viable solution to fix a problem. Packages tend to get better, not worse. Would you be open to a "diagnosis" facility that compares installed vs. suggested package versions?
You know what, I think you guys are right. I am seeing minimal version specs all across the tidyverse, so this is not likely to surprise people. @lorenzwalthert, what version of CodeDepends
worked for you?
I am actually not sure if we are talking about the same thing. Unfortunately, I can't reproduce what I had before updating, but I think I get a different error now if I don't use the package mask.
I.e. this works:
library("drake")
library("magrittr")
drake_plan(
x = dplyr::filter(mtcars, cyl == 4)
) %>%
make()
#> All targets are already up to date.
table(readd(x)$cyl)
#>
#> 4
#> 11
And this gives an error
library("drake")
library("magrittr")
library("dplyr")
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:drake':
#>
#> contains, ends_with, everything, matches, num_range, one_of,
#> starts_with
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
drake_plan(
x = filter(mtcars, cyl == 4)
) %>%
make()
#> Warning: could not resolve implicit dependencies of
#> code:structure(expression(filter(mtcars, cyl == 4)), srcfile =
#> <environment>, wholeSrcref = structure(c(1L, 0L, 2L, 0L, 0L, 0L, 1L, 2L),
#> srcfile = <environment>, class = "srcref"))
#> ...
I also run the code from https://github.com/ropensci/drake/issues/268#issuecomment-367204566, and I get not the same error message as @tiernanmartin got, but the same as in my second example.
I think it's good practice anyways to use the mask for the name space collision so I don't object to the behaviour demonstrated, although the error message could still be more informative.
So maybe the minimal version dependency does not make sense since it is not really a huge benefit we'd get with it, just a different error message. I also tried the GitHub version, but installation fails due a problem in the NAMESPACE file so I can't make a comparison without some work. Sorry for the confusion -.-
I tried opening an issue but it's not possible with forks I just realized. @tiernanmartin maybe it is worth fixing the problem. I get:
Using github PAT from envvar GITHUB_PAT
Downloading GitHub repo gmbecker/CodeDepends@master
* installing *source* package ‘CodeDepends’ ...
** R
Error in parse(outFile) :
/private/var/folders/8l/fhmv3yj12kncddcjqwc19tkr0000gr/T/RtmpDi5lyP/remotes6c9666522534/gmbecker-CodeDepends-d085a4f/R/codeDe:114:18: unexpected '}'
113: inputs <<- unique(c(inputs,
114: }
^
ERROR: unable to collate and parse R files for package ‘CodeDepends’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/CodeDepends’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/CodeDepends’
Warning messages:
1: In utils::install.packages(pkgs = pkgs, lib = lib, repos = myrepos, :
installation of package ‘/var/folders/8l/fhmv3yj12kncddcjqwc19tkr0000gr/T//RtmpDi5lyP/remotes6c9666522534/gmbecker-CodeDepends-d085a4f’ had non-zero exit status
2: In utils::install.packages(pkgs = pkgs, lib = lib, repos = myrepos, :
installation of package ‘/var/folders/8l/fhmv3yj12kncddcjqwc19tkr0000gr/T//RtmpDi5lyP/remotes6c9666522534/gmbecker-CodeDepends-d085a4f’ had non-zero exit status
Probably another devtools::document()
helps, or at least tells you where the problem is.
Well shucks, I thought the filter()
issue in CodeDepends
was already taken care of.
I do agree that drake
should output a more informative warning. The trouble is that the part of drake
that does the code analysis is not aware of the function name or target that the code corresponds to.
@lorenzwalthert The canonical sources for CodeDepends are at duncantl/CodeDepends. I am the maintainer but Duncan is the original author. doing install_github from that repo works correctly without error.
@krlmlr I do plan to update CodeDepends on CRAN. I need to figure out the masking warnings by tightening up the imports, but once I do that the new version should be on CRAN shortly after that. Apologies for the delay on that.
My suspicion is that these folks are running into problems because they are using the CRAN version. I'll try to get an updated version up soon, though I'm a bit buried under the upcoming breaking changes for ggplot2 on another project right this second :-/
Thanks @gmbecker I tried to install the fork, can't recall exactly why. But I also can't install the upstream.
> remotes::install_github("duncantl/CodeDepends")
Using github PAT from envvar GITHUB_PAT
Downloading GitHub repo duncantl/CodeDepends@master
Skipping 1 packages not available: graph
ERROR: dependency ‘graph’ is not available for package ‘CodeDepends’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/CodeDepends’
Warning message:
In i.p(...) :
installation of package ‘/var/folders/8l/fhmv3yj12kncddcjqwc19tkr0000gr/T//RtmpECpFzn/remotes18b01fdcfbad/duncantl-CodeDepends-7b398fe’ had non-zero exit status
You need the graph package, which is publicly available on bioconductor. (note this is true of the CRAN version, and will be true of at least one more CRAN version before it is possibly changed, it's not a function of installing from github).
In an R session do:
source("http://bioconductor.org/biocLite.R")
biocLite("graph")
and you should be all set on that front.
~G
On Thu, May 24, 2018 at 12:14 PM, Lorenz Walthert notifications@github.com wrote:
Thanks @gmbecker https://github.com/gmbecker I tried to install the fork, can't recall exactly why. But I also can't install the upstream.
remotes::install_github("duncantl/CodeDepends") Using github PAT from envvar GITHUB_PAT Downloading GitHub repo duncantl/CodeDepends@master Skipping 1 packages not available: graph ERROR: dependency ‘graph’ is not available for package ‘CodeDepends’
- removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/CodeDepends’ Warning message: In i.p(...) : installation of package ‘/var/folders/8l/fhmv3yj12kncddcjqwc19tkr0000gr/T//RtmpECpFzn/remotes18b01fdcfbad/duncantl-CodeDepends-7b398fe’ had non-zero exit status
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ropensci/drake/issues/268#issuecomment-391827784, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3dsS3N475T6yFIYLrkWAuw1MKGAjMlks5t1waigaJpZM4SMq4A .
-- Gabriel Becker, Ph.D Scientist Bioinformatics and Computational Biology Genentech Research
Only a drake problem because it's now using CodeDepends. @gmbecker: Any idea what's wrong here?
Other function names seem to work fine. The
x
is necessary to trigger the problem.