ATFutures / upthat

Urban planning and transport health assessment tool
4 stars 1 forks source link

No need for <<- as far as I can tell, reverted to = #30

Closed Robinlovelace closed 4 years ago

Robinlovelace commented 4 years ago

Heads-up @mpadge I've tested with the more conventional assignment operator and it seems to work. Putting as a PR as I'm unsure why you set it to <<- and want to ensure I'm not missing anything.

mpadge commented 4 years ago

I put it there because without it, and with this PR in current form, I get

Warning: Error in observeEventHandler: object 'net' not found
  [No stack trace available]

For me locally at least, the only way for the observeEvent handlers to process the net object is with the global assignment operator. Does it really work for you without it?

Robinlovelace commented 4 years ago

Yes I can reproduce that issue now:

remotes::install_github("atfutures/upthat", "no<<-")
#> Skipping install of 'upthat' from a github remote, the SHA1 (325e50c2) has not changed since last install.
#>   Use `force = TRUE` to force installation
upthat::runUpthat()
#> Loading required package: shiny
#> 
#> Listening on http://127.0.0.1:3507
#> Reading this matching file: /home/robin/R/x86_64-pc-linux-gnu-library/3.6/upthat/net.Rds
#> Registered S3 method overwritten by 'jsonify':
#>   method     from    
#>   print.json jsonlite
#> Warning: Error in observeEventHandler: object 'net' not found

Created on 2019-11-28 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 3.6.1 (2019-07-05) #> os Ubuntu 18.04.3 LTS #> system x86_64, linux-gnu #> ui X11 #> language en_GB:en #> collate en_GB.UTF-8 #> ctype en_GB.UTF-8 #> tz Europe/London #> date 2019-11-28 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [2] CRAN (R 3.6.0) #> backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.1) #> callr 3.3.2 2019-09-22 [1] CRAN (R 3.6.1) #> class 7.3-15 2019-01-01 [2] standard (@7.3-15) #> classInt 0.4-2 2019-10-29 [1] Github (r-spatial/classInt@935c088) #> cli 1.1.0 2019-03-19 [2] CRAN (R 3.5.3) #> codetools 0.2-16 2018-12-24 [4] CRAN (R 3.5.2) #> colourvalues 0.3.1 2019-11-15 [1] CRAN (R 3.6.1) #> crayon 1.3.4 2017-09-16 [2] standard (@1.3.4) #> crosstalk 1.0.0 2016-12-21 [2] CRAN (R 3.5.2) #> curl 4.2 2019-09-24 [1] CRAN (R 3.6.1) #> DBI 1.0.0 2018-05-02 [2] CRAN (R 3.5.2) #> desc 1.2.0 2018-05-01 [2] standard (@1.2.0) #> devtools 2.2.1 2019-09-24 [1] CRAN (R 3.6.1) #> dichromat 2.0-0 2013-01-24 [2] CRAN (R 3.5.2) #> digest 0.6.23 2019-11-23 [1] CRAN (R 3.6.1) #> e1071 1.7-3 2019-11-26 [2] CRAN (R 3.6.1) #> ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.1) #> evaluate 0.14 2019-05-28 [2] CRAN (R 3.6.0) #> fastmap 1.0.1 2019-10-08 [2] CRAN (R 3.6.1) #> fs 1.3.1 2019-05-06 [2] CRAN (R 3.6.0) #> glue 1.3.1 2019-03-12 [2] CRAN (R 3.5.3) #> highr 0.8 2019-03-20 [3] CRAN (R 3.5.3) #> htmltools 0.4.0 2019-10-04 [3] CRAN (R 3.6.1) #> htmlwidgets 1.5.1 2019-10-08 [2] CRAN (R 3.6.1) #> httpuv 1.5.2 2019-09-11 [2] CRAN (R 3.6.1) #> httr 1.4.1 2019-08-05 [2] CRAN (R 3.6.1) #> jsonify 1.0.0 2019-11-03 [1] CRAN (R 3.6.1) #> jsonlite 1.6 2018-12-07 [2] standard (@1.6) #> KernSmooth 2.23-16 2019-10-15 [4] CRAN (R 3.6.1) #> knitr 1.26 2019-11-12 [1] CRAN (R 3.6.1) #> later 1.0.0 2019-10-04 [2] CRAN (R 3.6.1) #> lattice 0.20-38 2018-11-04 [2] standard (@0.20-38) #> leaflet 2.0.3 2019-11-16 [1] CRAN (R 3.6.1) #> leafsync 0.1.0 2019-03-05 [1] CRAN (R 3.6.0) #> lwgeom 0.1-7 2019-05-06 [2] CRAN (R 3.6.0) #> magrittr 1.5 2014-11-22 [2] CRAN (R 3.5.2) #> mapdeck 0.2.1007 2019-11-25 [1] Github (symbolixAU/mapdeck@87a84b9) #> memoise 1.1.0 2017-04-21 [3] CRAN (R 3.5.0) #> mime 0.7 2019-06-11 [1] CRAN (R 3.6.0) #> pkgbuild 1.0.6 2019-10-09 [2] CRAN (R 3.6.1) #> pkgload 1.0.2 2018-10-29 [3] CRAN (R 3.5.1) #> prettyunits 1.0.2 2015-07-13 [2] CRAN (R 3.5.3) #> processx 3.4.1 2019-07-18 [2] CRAN (R 3.6.1) #> promises 1.1.0 2019-10-04 [2] CRAN (R 3.6.1) #> ps 1.3.0 2018-12-21 [2] CRAN (R 3.5.3) #> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.1) #> raster 3.0-7 2019-09-24 [1] CRAN (R 3.6.1) #> RColorBrewer 1.1-2 2014-12-07 [3] CRAN (R 3.5.0) #> Rcpp 1.0.3 2019-11-08 [1] CRAN (R 3.6.1) #> remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.1) #> rgdal 1.4-8 2019-11-27 [1] CRAN (R 3.6.1) #> rgeos 0.5-2 2019-10-03 [1] CRAN (R 3.6.1) #> rlang 0.4.2 2019-11-23 [1] CRAN (R 3.6.1) #> rmarkdown 1.18 2019-11-27 [1] CRAN (R 3.6.1) #> rprojroot 1.3-2 2018-01-03 [2] CRAN (R 3.5.3) #> sessioninfo 1.1.1 2018-11-05 [3] CRAN (R 3.5.1) #> sf 0.8-0 2019-09-17 [1] CRAN (R 3.6.1) #> shiny * 1.4.0 2019-10-10 [2] CRAN (R 3.6.1) #> sp 1.3-2 2019-11-07 [1] CRAN (R 3.6.1) #> stringi 1.4.3 2019-03-12 [2] CRAN (R 3.5.3) #> stringr 1.4.0 2019-02-10 [2] standard (@1.4.0) #> testthat 2.3.0 2019-11-05 [2] CRAN (R 3.6.1) #> tmap 2.3-1 2019-11-11 [1] Github (mtennekes/tmap@804eafd) #> tmaptools 2.0-2 2019-07-18 [2] CRAN (R 3.6.1) #> units 0.6-5 2019-10-08 [1] CRAN (R 3.6.1) #> upthat 0.1.0 2019-11-28 [1] Github (atfutures/upthat@325e50c) #> usethis 1.5.1 2019-07-04 [1] CRAN (R 3.6.1) #> viridisLite 0.3.0 2018-02-01 [3] CRAN (R 3.5.0) #> webshot 0.5.2 2019-11-22 [2] CRAN (R 3.6.1) #> withr 2.1.2 2018-03-15 [2] CRAN (R 3.5.3) #> xfun 0.11 2019-11-12 [1] CRAN (R 3.6.1) #> XML 3.98-1.20 2019-06-06 [2] CRAN (R 3.6.0) #> xml2 1.2.2 2019-08-09 [3] CRAN (R 3.6.1) #> xtable 1.8-4 2019-04-21 [2] CRAN (R 3.6.0) #> yaml 2.2.0 2018-07-25 [3] CRAN (R 3.5.1) #> #> [1] /home/robin/R/x86_64-pc-linux-gnu-library/3.6 #> [2] /usr/local/lib/R/site-library #> [3] /usr/lib/R/site-library #> [4] /usr/lib/R/library ```
Robinlovelace commented 4 years ago

Fixed on latest commit: please try to reproduce the reprex above @mpadge, I'm pretty sure it's fixed now.

mpadge commented 4 years ago

Ha, interesting - just discovered that no<<- is not really a valid branch name - I can't check it out locally. But the code doesn't seem right, alas :disappointed: for 2 reasons:

  1. The first if clause does nothing in the following, because matching_file is then simply ignored from the point on:
    if (length(matching_file) > 1) {
    matching_file = matching_file[1]
    } else if (length(matching_file) == 1) {
    ...
    net = readRDS(matching_file)
    }
  2. net is not updated at all, but remains as the initially loaded version, which is the demo data for Kathmandu. The new data are read on input$city, but those data are not passed beyond the observeEvent environment, and so are not updated on the output. This was the original reason why I tried replacing = with <<-, which seemed at that time to work, and would still appear from my perspective to be necessary here.

Sorry to be the bearer of bad news there ...

Robinlovelace commented 4 years ago

Ha, interesting - just discovered that no<<- is not really a valid branch name - I can't check it out locally. But the code doesn't seem right, alas disappointed for 2 reasons:

It is. Try

git checkout 'no<<-'
Robinlovelace commented 4 years ago

But you're right about it never changing...

mpadge commented 4 years ago

ah, okay, thanks: 'no<<' works, but no<<- fails. file for future reference!