Closed joelfiddes closed 6 years ago
just to add, I guess the dependencies (ie. gui related packages) are called on package load ie. this is done regardless of how the gui switch is set. I dont know so much about packaging, but if this is the case is there an easy way to remove this dependency (at least in a local "hacked " version of the code)? I guess this might be a more widely relevant use case though for automated jobs and therefore worth looking at more thoroughly (if I'm right!)
Hi. Thanks for signaling this. I'll have a look ASAP.
Hi,
I checked, and verified that no "GUI related" function should be loaded when gui = FALSE. Therefore, I guess you are right and "Imports" are accessed on package load irrespective of that.
A possible workaround could be to move gWidgets and gWidgetsRGtk2 from "Imports" to "Suggests" and see if it solves the issue. I created a new branch that does that. Could you try installing it and see if it solves the problem ?
devtools::install_github("lbusett/MODIStsp", ref = "headless")
Thanks for looking into this. That should have done it - but unfortunately not... I can't quite understand why. I installed the headless branch and then connected without X11 to simulate the problem ie ssh user@server. library fails to load. Below is tail of DESCRIPTIONS to show we are trying to load the "headless" branch and then results of failed package load. I have verified that the package loads ok with ssh -X user@server
> packageDescription('MODIStsp')
Package: MODIStsp
Title: A Tool for Automating Download and Preprocessing of MODIS Land
Products Data
Type: Package
Version: 1.3.3.1
Authors@R: c(person("Lorenzo", "Busetto", email = "lbusett@gmail.com",
role = c("aut", "cre")), person("Luigi", "Ranghetti", email =
"ranghetti.l@irea.cnr.it", role = c("aut")))
Description: Allows automating the creation of time series of rasters
derived from MODIS Satellite Land Products data. It performs
several typical preprocessing steps such as download,
mosaicking, reprojection and resize of data acquired on a
specified time period. All processing parameters can be set
using a user-friendly GUI. Users can select which layers of the
original MODIS HDF files they want to process, which additional
Quality Indicators should be extracted from aggregated MODIS
Quality Assurance layers and, in the case of Surface
Reflectance products , which Spectral Indexes should be
computed from the original reflectance bands. For each output
layer, outputs are saved as single-band raster files
corresponding to each available acquisition date. Virtual files
allowing access to the entire time series as a single file are
also created. Command-line execution exploiting a previously
saved processing options file is also possible, allowing to
automatically update time series related to a MODIS product
whenever a new image is available.
License: GPL-3
Depends: R (>= 3.1.3)
Imports: bitops (>= 1.0-6), data.table (>= 1.9.6), gdalUtils (>=
2.0.1.7), hash (>= 2.2.6), httr (>= 1.1.0), pacman, plyr (>=
1.8.3), raster (>= 2.5-2), RCurl (>= 1.95-4.8), rgdal (>=
1.0-3), rgeos (>= 0.3-8), RJSONIO (>= 1.3.0), sp (>= 1.2-2),
stringr (>= 1.0.0), xts (>= 0.9-7), XML (>= 3.98-1.1), parallel
Suggests: knitr, rmarkdown, png, grid, testthat, covr, gWidgets (>=
0.0-54), gWidgetsRGtk2 (>= 0.0-83),
SystemRequirements: Cairo >= 1.0.0, ATK (>= 1.10.0), Pango (>= 1.10.0),
GTK+ (>= 2.8.0), GLib (>= 2.8.0), Curl, GDAL (>= 1.6.3), PROJ.4
(>= 4.4.9)
URL: https://github.com/lbusett/MODIStsp
BugReports: https://github.com/lbusett/MODIStsp/issues
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 6.0.1
Roxygen: list(markdown = TRUE)
Author: Lorenzo Busetto [aut, cre], Luigi Ranghetti [aut]
Maintainer: Lorenzo Busetto <lbusett@gmail.com>
Built: R 3.4.1; ; 2017-11-06 10:11:50 UTC; unix
RemoteType: github
RemoteHost: https://api.github.com
RemoteRepo: MODIStsp
RemoteUsername: lbusett
RemoteRef: headless
RemoteSha: d98facb80588a1ab45531fd0c8dafad337be2b7a
GithubRepo: MODIStsp
GithubUsername: lbusett
GithubRef: headless
GithubSHA1: d98facb80588a1ab45531fd0c8dafad337be2b7a
-- File: /uio/kant/geo-gjest-u1/fiddes/R/x86_64-redhat-linux-gnu-library/3.4/MODIStsp/Meta/package.rds
> library(MODIStsp)
R session is headless; GTK+ not initialized.
(R:7230): Gtk-WARNING **: gtk_disable_setlocale() must be called before gtk_init()
Error: package or namespace load failed for ‘MODIStsp’:
.onLoad failed in loadNamespace() for 'cairoDevice', details:
call: fun(libname, pkgname)
error: GDK display not found - please make sure X11 is running
> packageDescription('MODIStsp')
Package: MODIStsp
Title: A Tool for Automating Download and Preprocessing of MODIS Land
Products Data
Type: Package
Version: 1.3.3.1
Authors@R: c(person("Lorenzo", "Busetto", email = "lbusett@gmail.com",
role = c("aut", "cre")), person("Luigi", "Ranghetti", email =
"ranghetti.l@irea.cnr.it", role = c("aut")))
Description: Allows automating the creation of time series of rasters
derived from MODIS Satellite Land Products data. It performs
several typical preprocessing steps such as download,
mosaicking, reprojection and resize of data acquired on a
specified time period. All processing parameters can be set
using a user-friendly GUI. Users can select which layers of the
original MODIS HDF files they want to process, which additional
Quality Indicators should be extracted from aggregated MODIS
Quality Assurance layers and, in the case of Surface
Reflectance products , which Spectral Indexes should be
computed from the original reflectance bands. For each output
layer, outputs are saved as single-band raster files
corresponding to each available acquisition date. Virtual files
allowing access to the entire time series as a single file are
also created. Command-line execution exploiting a previously
saved processing options file is also possible, allowing to
automatically update time series related to a MODIS product
whenever a new image is available.
License: GPL-3
Depends: R (>= 3.1.3)
Imports: bitops (>= 1.0-6), data.table (>= 1.9.6), gdalUtils (>=
2.0.1.7), hash (>= 2.2.6), httr (>= 1.1.0), pacman, plyr (>=
1.8.3), raster (>= 2.5-2), RCurl (>= 1.95-4.8), rgdal (>=
1.0-3), rgeos (>= 0.3-8), RJSONIO (>= 1.3.0), sp (>= 1.2-2),
stringr (>= 1.0.0), xts (>= 0.9-7), XML (>= 3.98-1.1), parallel
Suggests: knitr, rmarkdown, png, grid, testthat, covr, gWidgets (>=
0.0-54), gWidgetsRGtk2 (>= 0.0-83),
SystemRequirements: Cairo >= 1.0.0, ATK (>= 1.10.0), Pango (>= 1.10.0),
GTK+ (>= 2.8.0), GLib (>= 2.8.0), Curl, GDAL (>= 1.6.3), PROJ.4
(>= 4.4.9)
URL: https://github.com/lbusett/MODIStsp
BugReports: https://github.com/lbusett/MODIStsp/issues
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 6.0.1
Roxygen: list(markdown = TRUE)
Author: Lorenzo Busetto [aut, cre], Luigi Ranghetti [aut]
Maintainer: Lorenzo Busetto <lbusett@gmail.com>
Built: R 3.4.1; ; 2017-11-06 10:11:50 UTC; unix
RemoteType: github
RemoteHost: https://api.github.com
RemoteRepo: MODIStsp
RemoteUsername: lbusett
RemoteRef: headless
RemoteSha: d98facb80588a1ab45531fd0c8dafad337be2b7a
GithubRepo: MODIStsp
GithubUsername: lbusett
GithubRef: headless
GithubSHA1: d98facb80588a1ab45531fd0c8dafad337be2b7a
-- File: /uio/kant/geo-gjest-u1/fiddes/R/x86_64-redhat-linux-gnu-library/3.4/MODIStsp/Meta/package.rds
> library(MODIStsp)
>
mmm... then maybe the issue is with SystemRequirements: GTK+ (>= 2.8.0).
I tried to remove also that: can you try again?
Also, I remember that in order for the build to "pass" on Travis-CI (which uses a headless system), I had to add this two lines to the "configuration" of the build:
don't know if it may help in some way....
also fails - can we remove cairo as well?
License: GPL-3
Depends: R (>= 3.1.3)
Imports: bitops (>= 1.0-6), data.table (>= 1.9.6), gdalUtils (>=
2.0.1.7), hash (>= 2.2.6), httr (>= 1.1.0), pacman, plyr (>=
1.8.3), raster (>= 2.5-2), RCurl (>= 1.95-4.8), rgdal (>=
1.0-3), rgeos (>= 0.3-8), RJSONIO (>= 1.3.0), sp (>= 1.2-2),
stringr (>= 1.0.0), xts (>= 0.9-7), XML (>= 3.98-1.1), parallel
Suggests: knitr, rmarkdown, png, grid, testthat, covr, gWidgets (>=
0.0-54), gWidgetsRGtk2 (>= 0.0-83),
SystemRequirements: Cairo >= 1.0.0, ATK (>= 1.10.0), Pango (>= 1.10.0),
GLib (>= 2.8.0), Curl, GDAL (>= 1.6.3), PROJ.4 (>= 4.4.9)
URL: https://github.com/lbusett/MODIStsp
BugReports: https://github.com/lbusett/MODIStsp/issues
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 6.0.1
Roxygen: list(markdown = TRUE)
Author: Lorenzo Busetto [aut, cre], Luigi Ranghetti [aut]
Maintainer: Lorenzo Busetto <lbusett@gmail.com>
Built: R 3.4.1; ; 2017-11-06 10:54:13 UTC; unix
RemoteType: github
RemoteHost: https://api.github.com
RemoteRepo: MODIStsp
RemoteUsername: lbusett
RemoteRef: headless
RemoteSha: e87a572f1edd5ac1c6987b95d0c9c4be68fba655
GithubRepo: MODIStsp
GithubUsername: lbusett
GithubRef: headless
GithubSHA1: e87a572f1edd5ac1c6987b95d0c9c4be68fba655
-- File: /uio/kant/geo-gjest-u1/fiddes/R/x86_64-redhat-linux-gnu-library/3.4/MODIStsp/Meta/package.rds
> library(MODIStsp)
(R:32597): Gtk-WARNING **: gtk_disable_setlocale() must be called before gtk_init()
Error: package or namespace load failed for ‘MODIStsp’:
.onLoad failed in loadNamespace() for 'cairoDevice', details:
call: fun(libname, pkgname)
error: GDK display not found - please make sure X11 is running
yup. Tried to remove almost everything.... Let's try again !
failed again! I saw this as a possible workaround - will try. https://superuser.com/questions/542738/error-onload-failed-in-loadnamespace-for-cairodevice-on-a-linux-machine
Your mention of the DISPLAY variable could be important. I came across this when investigating yesterday. Although I did try this and didn't solve it. https://askubuntu.com/questions/9920/x11-forwarding-over-gnu-screen-is-it-possible
I just saw this also: https://github.com/r-hub/rhub/issues/56 But with Cairo removed as a dependency shouldnt matter (plus seemed to be resolved).
Depends: R (>= 3.1.3)
Imports: bitops (>= 1.0-6), data.table (>= 1.9.6), gdalUtils (>=
2.0.1.7), hash (>= 2.2.6), httr (>= 1.1.0), pacman, plyr (>=
1.8.3), raster (>= 2.5-2), RCurl (>= 1.95-4.8), rgdal (>=
1.0-3), rgeos (>= 0.3-8), RJSONIO (>= 1.3.0), sp (>= 1.2-2),
stringr (>= 1.0.0), xts (>= 0.9-7), XML (>= 3.98-1.1), parallel
Suggests: knitr, rmarkdown, png, grid, testthat, covr, gWidgets (>=
0.0-54), gWidgetsRGtk2 (>= 0.0-83),
SystemRequirements: Curl, GDAL (>= 1.6.3), PROJ.4 (>= 4.4.9)
URL: https://github.com/lbusett/MODIStsp
BugReports: https://github.com/lbusett/MODIStsp/issues
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 6.0.1
Roxygen: list(markdown = TRUE)
Author: Lorenzo Busetto [aut, cre], Luigi Ranghetti [aut]
Maintainer: Lorenzo Busetto <lbusett@gmail.com>
Built: R 3.4.1; ; 2017-11-06 11:10:33 UTC; unix
RemoteType: github
RemoteHost: https://api.github.com
RemoteRepo: MODIStsp
RemoteUsername: lbusett
RemoteRef: headless
RemoteSha: e7e714a559c275c7953eada14d2936ebc30c7694
GithubRepo: MODIStsp
GithubUsername: lbusett
GithubRef: headless
GithubSHA1: e7e714a559c275c7953eada14d2936ebc30c7694
-- File: /uio/kant/geo-gjest-u1/fiddes/R/x86_64-redhat-linux-gnu-library/3.4/MODIStsp/Meta/package.rds
> library(MODIStsp)
(R:32597): Gtk-WARNING **: gtk_disable_setlocale() must be called before gtk_init()
Error: package or namespace load failed for ‘MODIStsp’:
.onLoad failed in loadNamespace() for 'cairoDevice', details:
call: fun(libname, pkgname)
error: GDK display not found - please make sure X11 is running
heres the full doc: http://elementalselenium.com/tips/38-headless
Its what you did to pass Travis I think.
testing now...
Hi there
I wasn't able (no sudo) to install xvfb on the machine and sys admin asked me to try x2go which roughly does the same thing ie. redirects x11 output and allows disconnection from the session. This workaround seems to work albeit with a failure:
Loading required package: MODIStsp
[Mon Nov 6 15:12:15 2017]Welcome to MODIStsp!
We will now search for a valid GDAL installation - please wait
(this will happen only once)
Scanning for GDAL installations...
Checking Sys.which...
GDAL version 2.1.3
GDAL version in use: 1.11.4
Waiting while reading the MODIS products list...
Error in new("hash", new.env(hash = TRUE, parent = emptyenv())) :
could not find function "new"
Calls: MODIStsp -> MODIStsp_read_xml -> hash
Execution halted
If I fire up R in the same session, the package "hash and function "new" are available:
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> require(hash)
Loading required package: hash
hash-2.2.6 provided by Decision Patterns
> new
function (Class, ...)
{
ClassDef <- getClass(Class, where = topenv(parent.frame()))
value <- .Call(C_new_object, ClassDef)
initialize(value, ...)
}
<bytecode: 0x275a440>
<environment: namespace:methods>
>
shall I open a new ticket for that or any quick ideas?
I guess in an ideal world would be nice to know why we can't get around these dependencies. I read this from Hadley Wickham:
You can also list things that your package needs outside of R in the SystemRequirements field. But this is just a plain text field and is not automatically checked. Think of it as a quick reference; you’ll also need to include detailed system requirements (and how to install them) in your README.
here: http://r-pkgs.had.co.nz/description.html
This suggests that the system requirements are checked elsewhere and not necessarily controlled by what is entered in this field.
thanks again for all your investigations!
All seems to be running fine now, with main release version and x2go workaround (no idea what changed wrt to the hash issue mentioned above). Happy to consider this closed unless you want to pursue the dependency question further.
Concerning the "hash" issue, I probably have a missing dependency in the NAMESPACE in the "devel" branch. Will check that later.
Concerning the other issue: would you mind to explain me in some detail what "passages" were required on your machine to have it working (e.g., you installed x2go, but then, what else did you have to "tweak" (?if any ). I was thinking to add that to the MODIStsp FAQ.
Sure is that OK? There is the tutorial I used and a brief paragraph specifying why x2go was a reasonable solution.
x2go solution: http://www.mn.uio.no/geo/english/services/it/help/using-linux/x2go.html
X2go enables an X11 session to a remote machine from a Linux, Windows or Mac local machine. It's an alternative to Xwin32, XQuartz or ssh -X, with some nice features. It allows an X11 connection to be made to a headless server and then suspended. In this way, it replaces the functionality of something like screen plus does not drop X11 once the session is detached. Applications with x11 dependencies will continue to run. In this respect, it serves as an alternative to xvfb.
Software is required on both local and remote machine as detailed in the HOWTO above.
Thanks ! In practice:
1) You install x2g0; 2) access the headless server using x2go; 3) Launch MODIStsp (with or without GUI) 4) close the x2g0 session and leave MODIStsp running
correct ?
yes thats right, x2go is a client/server tool - so needs to be installed on server too.
Perfect, thanks ! Closing this now. Will update the FAQ in the coming days!
perfect!
Hi there again,
The basic usecase addressed here is running MODIStsp(gui=FALSE) on a remote headless server.
I am running MODIStsp(gui=FALSE) on a remote headless linux redhat server. I connect to the server with X11 as "ssh -X user@server" and run the package in a screen session. All is well while my ssh session is connected and MODIStsp() runs as expected. If I disconnect from the ssh session and leave the code to run in my screen session (as is a common usecase) I get the following error and failure of MODIStsp to load:
I assume this is because X11 is no longer activated as I have disconnected from my ssh session. This may be a workaround to keep x11 alive: https://askubuntu.com/questions/817082/how-to-keep-a-remote-x11-app-running-after-disconnecting-ssh, I will experiment.
However, I guess the question is why is X11 required if gui=FALSE switch is set? All the errors are related to gui packages, no?
Thanks again for the hard work and a great package! Joel