ropensci / taxize

A taxonomic toolbelt for R
https://docs.ropensci.org/taxize
Other
271 stars 61 forks source link

Windows builds #454

Closed sckott closed 9 years ago

sckott commented 9 years ago

@EDiLD the windows builds haven't been passing for a while - i can't figure out exactly why it's happening. I can't duplicate the problem on a windows VM I have - anyway, maybe someone knows the problem.

The appveyor failure https://ci.appveyor.com/project/sckott/taxize-175/build/1.0.664#L269

I believe this is the offending line in taxize https://github.com/ropensci/taxize/blob/af2613d8abeff2bcb340f40bec15f5ce048edc88/R/phylomatic_format.R#L27

eduardszoecs commented 9 years ago

Thanks for pinging - i have an old vista laptop somewhere. Will check if I can find the problem (but will take few days...)

eduardszoecs commented 9 years ago

Update With native Vista, old R (3.1.1) and new taxize (0.6.2.9610) I get:

devtools::test()

Testing taxize
apg* functions : ........
bold_search : ...........1
class2tree : .......
classification : ............................
col_children : .......................
col_downstream : ............
col_search : ...................
comm2sci : ..........
eol_dataobjects : ...
eol_pages : ...
eol_ping : ...
eol_search : ...
gbif_parse : ......
get_boldid : ....
get_colid : ...
get_eolid : ...
get_ids : .........
get_tpsid : ....
get_tsn : .....
get_uid : ...................
gni_details : ..
gni_parse : ...
gni_search : ..
gnr_datasources : 
gnr_resolve : .............
itis : ....
itis_acceptname : ..
itis_downstream : ......
itis_getrecord : ...
itis_hierarchy : .....
itis_kingdomnames : .....
itis_lsid : ........
itis_native : .....
itis_ping : ...
itis_refs : ....
itis_taxrank : ..
itis_terms : ...
iucn_getname : ...
iucn_summary : ...
names_list : ....
ncbi_children : .......
ncbi_get_taxon_summary : .....
phylomatic_format : ..
phylomatic_tree : ..........
ping : ........................
rankagg : ....
sci2comm : ......
synonyms : .....
tax_agg : ........
tax_name : ................
tax_rank : ........
tnrs : ..
tnrs_sources : ..
tp_accnames : ......
tp_dist : ....
tp_refs : .
tp_search : ....
tp_summary : ...
tp_synonyms : .....
vascan_search : .....

1. Error: bold_search is robust to user error ----------------------------------
undefined columns selected
1: withCallingHandlers(eval(code, new_test_environment), error = capture_calls, message = function(c) invokeRestart("muffleMessage"), 
       warning = function(c) invokeRestart("muffleWarning"))
2: eval(code, new_test_environment)
3: eval(expr, envir, enclos)
4: expect_is(bold_search(name = ""), "data.frame") at test-bold_search.R:31
5: expect_that(object, is_a(class), info, label)
6: condition(object)
7: paste0(class(x), collapse = ", ")
8: bold_search(name = "")
9: bold_tax_name(name = name, fuzzy = fuzzy, response = response, ...) at C:\Users\Edi\Documents\GitHub\taxize/R/bold_search.R:65
10: do.call(rbind.fill, Map(process_response, x = tmp, y = name, z = includeTree))
11: Map(process_response, x = tmp, y = name, z = includeTree)
12: mapply(FUN = f, ..., SIMPLIFY = FALSE)
13: (function (x, y, z) 
   {
       tt <- content(x, as = "text")
       out <- fromJSON(tt)
       if (length(out) == 0) {
           data.frame(input = y, stringsAsFactors = FALSE)
       }
       else {
           trynames <- tryCatch(as.numeric(names(out)), warning = function(w) w)
           if (!is(trynames, "simpleWarning")) 
               names(out) <- NULL
           if (!is.null(names(out))) {
               df <- data.frame(out, stringsAsFactors = FALSE)
           }
           else {
               df <- do.call(rbind.fill, lapply(out, data.frame, stringsAsFactors = FALSE))
           }
           row.names(df) <- NULL
           ff <- sort_df(df, "parentid")
           row.names(ff) <- NULL
           data.frame(input = y, ff, stringsAsFactors = FALSE)
       }
   })(x = dots[[1L]][[1L]], y = dots[[2L]][[1L]], z = dots[[3L]][[1L]])
14: sort_df(df, "parentid")
15: data[do.call("order", data[, vars, drop = FALSE]), , drop = FALSE]
16: `[.data.frame`(data, do.call("order", data[, vars, drop = FALSE]), , drop = FALSE)
17: do.call("order", data[, vars, drop = FALSE])
18: data[, vars, drop = FALSE]
19: `[.data.frame`(data, , vars, drop = FALSE)
20: stop("undefined columns selected")
Warning messages:
1: package 'testthat' was built under R version 3.1.3 
2: package 'vegan' was built under R version 3.1.2 
3: package 'permute' was built under R version 3.1.2 

So no problems with phylomatic_format... Will try to update my windoze machine (hope it's smooth - didn't use windows for years...) to current R and report...

sckott commented 9 years ago

arrrggghhh, that's annoying that you can't replicate the problem, but I guess the windows set up in appveyor may be different anyway

eduardszoecs commented 9 years ago

No Problems with native Vista, current R (version 3.2.2 (2015-08-14) -- "Fire Safety") and new taxize (0.6.2.9610):

devtools::test()

Loading taxize
Testing taxize
apg* functions : ........
bold_search : ..............
class2tree : .......
classification : ............................
col_children : .......................
col_downstream : ............
col_search : ...................
comm2sci : ..........
eol_dataobjects : ...
eol_pages : ...
eol_ping : ...
eol_search : ...
gbif_parse : ......
get_boldid : ....
get_colid : ...
get_eolid : ...
get_ids : .........
get_tpsid : ....
get_tsn : .....
get_uid : ...................
gni_details : ..
gni_parse : ...
gni_search : ..
gnr_datasources : 
gnr_resolve : .............
itis : ....
itis_acceptname : ..
itis_downstream : ......
itis_getrecord : ...
itis_hierarchy : .....
itis_kingdomnames : .....
itis_lsid : ........
itis_native : .....
itis_ping : ...
itis_refs : ....
itis_taxrank : ..
itis_terms : ...
iucn_getname : ...
iucn_summary : ...
names_list : ....
ncbi_children : .......
ncbi_get_taxon_summary : .....
phylomatic_format : ..
phylomatic_tree : ..........
ping : ........................
rankagg : ....
sci2comm : ......
synonyms : .....
tax_agg : ........
tax_name : ................
tax_rank : ........
tnrs : ..
tnrs_sources : ..
tp_accnames : ......
tp_dist : ....
tp_refs : .
tp_search : ....
tp_summary : ...
tp_synonyms : .....
vascan_search : .....

DONE 

Will now try R-devel....

eduardszoecs commented 9 years ago

Update Can reproduce the error with native Vista, R-devel ( 2015-08-20 r69138 -- "Unsuffered Consequences") and current taxize:

devtools::test()

Loading taxize
Testing taxize
apg* functions : ........
bold_search : ..............
class2tree : .......
classification : ............................
col_children : .......................
col_downstream : .........Error in curl::curl_fetch_memory(url, handle = handle) : 
  Timeout was reached
...
col_search : ...................
comm2sci : ..........
eol_dataobjects : ...
eol_pages : ...
eol_ping : ...
eol_search : ...
gbif_parse : ......
get_boldid : ....
get_colid : ...
get_eolid : ...
get_ids : .........
get_tpsid : ....
get_tsn : .....
get_uid : ...................
gni_details : ..
gni_parse : ...
gni_search : ..
gnr_datasources : 
gnr_resolve : .............
itis : ....
itis_acceptname : ..
itis_downstream : ......
itis_getrecord : ...
itis_hierarchy : .....
itis_kingdomnames : .....
itis_lsid : ........
itis_native : .....
itis_ping : ...
itis_refs : ....
itis_taxrank : ..
itis_terms : ...
iucn_getname : ...
iucn_summary : ...
names_list : ....
ncbi_children : .......
ncbi_get_taxon_summary : .....
phylomatic_format : ..
phylomatic_tree : Error in if (nchar(as.character(dd$that)) == 0) { : 
  missing value where TRUE/FALSE needed
Calls: <Anonymous> ... <Anonymous> -> lapply -> FUN -> sys.source2 -> eval -> eval
In addition: Warning message:
In is.na(object) : is.na() applied to non-(list or vector) of type 'NULL'
Execution halted

Exited with status 1.

Will now check and try to fix (tomorrow or so...)!

eduardszoecs commented 9 years ago

\ More Info***

It fails because the genus is not in theplantlist$genus. This returns NA:

taxa_genus <- "Lapsanastrum"
theplantlist[ match(taxa_genus, theplantlist$genus), "family" ]

and causes downstream problems. Still don't know what the difference between linux and/or current-R....

eduardszoecs commented 9 years ago

On windows (Rdevel):

> x <- "Lapsanastrum takasei"
> phylomatic_format(x, format = 'isubit', db = 'apg')
 Hide Traceback

 Rerun with Debug
 Error in if (nchar(as.character(dd$that)) == 0) { : 
  missing value where TRUE/FALSE needed 
4 FUN(X[[i]], ...) 
3 lapply(X = X, FUN = FUN, ...) 
2 sapply(taxa, foo, USE.NAMES = FALSE) at phylomatic_format.R#43
1 phylomatic_format(x, format = "isubit", db = "apg") 
eduardszoecs commented 9 years ago

On Linux with current R:

> x <- 'Lapsanastrum takasei'
> phylomatic_format(x, format = 'isubmit', db = 'apg')
[1] "NA/lapsanastrum/lapsanastrum_takasei"

Go to sleep now, will further investigate...

sckott commented 9 years ago

thanks for investigating

eduardszoecs commented 9 years ago

Got it!

I happens with R-devel (no matter if Linux or windows), because of this:

Current R on Linux

nchar(as.character(NA))
[1] 2

R devel on Linux

nchar(as.character(NA))
[1] NA

Which is because of this change in R-devel (from R-News):

‘nchar(x, *)’ and ‘nzchar(x)’ gain a new argument ‘keepNA’ which governs how the result for ‘NA’s in ‘x’ is determined. For the R 3.2.x series, the default remains ‘FALSE’ which is fully back compatible. From R 3.3.0, the default will change to ‘keepNA = NA’ and you are advised to consider this for code portability.

So this works in R devel

nchar(as.character(NA), keepNA = FALSE)
[1] 2
eduardszoecs commented 9 years ago

Should be fixed now.

sckott commented 9 years ago

great! nice work

eduardszoecs commented 9 years ago

Note, that I also changed the travis-ci yaml, to also test against r-devel (using the metacran builder). Now there are 2 builds - current R dan r devel for each travis-ci build. appveyor already tests against r-devel.

sckott commented 9 years ago

good idea