uptake / pkgnet

R package for analyzing other R packages via graph representations of their dependencies
https://uptake.github.io/pkgnet/
Other
155 stars 37 forks source link

DependencyReporter$graph_viz() is broken #244

Closed jameslamb closed 5 years ago

jameslamb commented 5 years ago

I think DependencyReporter$graph_viz() is broken.

library(pkgnet)

reporter <- DependencyReporter$new()

# Seed it with a package
reporter$set_package("ggplot2")

# plot it up
reporter$graph_viz()

Results in

INFO [2019-09-23 22:23:04] Plotting graph visualization...
INFO [2019-09-23 22:23:04] Using igraph layout: layout_as_tree
INFO [2019-09-23 22:23:04] Constructing dependency network for ggplot2
INFO [2019-09-23 22:23:04] ...done constructing dependency network.
INFO [2019-09-23 22:23:04] ...done plotting visualization.
Error: attempt to apply non-function

That last line of log comes from AbstractGraphReporter$plot_network(). and I don't see any other functions called after that.

Session Info

``` R version 3.5.0 (2018-04-23) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS 10.14.6 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods [7] base other attached packages: [1] pkgnet_0.4.0.9999 testthat_2.2.1 loaded via a namespace (and not attached): [1] Rcpp_1.0.0.1 compiler_3.5.0 formatR_1.5 [4] futile.logger_1.4.3 prettyunits_1.0.2 futile.options_1.0.1 [7] remotes_2.1.0 tools_3.5.0 digest_0.6.18 [10] pkgbuild_1.0.4 pkgload_1.0.2 jsonlite_1.6 [13] evaluate_0.13 memoise_1.1.0 pkgconfig_2.0.2 [16] rlang_0.4.0.9002 rex_1.1.2 igraph_1.2.2 [19] cli_1.1.0 rstudioapi_0.7 xfun_0.7 [22] knitr_1.23 withr_2.1.2.9000 desc_1.2.0 [25] fs_1.3.1 htmlwidgets_1.2 devtools_2.1.0 [28] rprojroot_1.3-2 DT_0.4 glue_1.3.1 [31] data.table_1.12.2 R6_2.3.0.9000 processx_3.4.1 [34] rmarkdown_1.12 sessioninfo_1.1.1 callr_3.3.1 [37] lambda.r_1.2.3 magrittr_1.5 covr_3.2.1 [40] backports_1.1.2 ps_1.3.0 htmltools_0.3.6 [43] usethis_1.5.1 assertthat_0.2.1 visNetwork_2.0.8 [46] lazyeval_0.2.1 crayon_1.3.4 ```

agnesbao commented 5 years ago

I don't think it's a bug? graph_viz is not a method but a field, so call reporter$graph_viz shows the graph

jameslamb commented 5 years ago

Ah thank you! Maybe that would explain it? It's still quite weird...a lot of code runs before I get that error. reporter$graph_viz triggers private$plot_network(), which from the logs appears to have happened.

It gets all the way to here (https://github.com/uptake/pkgnet/blob/master/R/AbstractGraphReporter.R#L431) and then dies.

Anyway, seems you are correct. I just re-ran my example code with reporter$graph_viz() changed to reporter$graph_viz and it totally worked. Thanks @agnesbao !

jayqi commented 5 years ago

Huh, it is pretty weird that it makes it all the way there before failing. I guess that's active bindings for you.