boettiger-lab / sarsop

:package: A library for solving POMDPs
GNU General Public License v2.0
10 stars 8 forks source link

Check assert_has_appl() in pomdpsol #40

Open mhahsler opened 3 years ago

mhahsler commented 3 years ago

Hi Carl,

I get on Windows the following:

> pomdpsol(model, output = policy, timeout = 1)
Error in processx::run(path, strsplit(args, " ")[[1]], spinner = spinner,  : 
  System command 'pomdpsol.exe' failed, exit status: -1073741515, stderr empty
Type .Last.error.trace to see where the error occurred

The error message is not very self-explanatory. Maybe you can check assert_has_appl() in pomdpsol and create an error message that points out that the installation had a problem and what most likely needs to be done (I assume installing something on Windows).

Best, -Michael

cboettig commented 3 years ago

Thanks @mhahsler for the report. Can you give a few more details that might help us reproduce? (e.g. sessionInfo() and a reprex maybe?) Guessing this happens with the default example?

Error handling is a bit hacky since we're not actually in R here, processx is calling an external executable which we package separately for Windows because compiling the source is quite challenging (and beyond my skill -- my colleague @jeroen implemented this and also happens to be the current maintainer of the Rtools suite for Windows, maybe he has some suggestions for us?) The native C++ appl source code is also developed upstream, you could attempt an independent install from there? I'm not sure how much I'll be able to do.

We do test on Windows where things still seem to be working ok, so you might just make sure your system is up-to-date matching the configuration shown there?

sorry can't be more helpful.

mhahsler commented 3 years ago

I develop on Linux and everything is fine, but I ran into the problem with tests on Windows, so I installed sarsop on a Windows 10 VM. There seems to be a problem calling the executable.

R version 4.0.5 (2021-03-31) -- "Shake and Throw"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

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.

> install.packages("sarsop")
Installing package into ‘C:/Users/michael/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/sarsop_0.6.8.zip'
Content type 'application/zip' length 2952598 bytes (2.8 MB)
downloaded 2.8 MB

package ‘sarsop’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\michael\AppData\Local\Temp\RtmpETZy4J\downloaded_packages

> library(sarsop)
> assert_has_appl()
[1] FALSE

> # Example from the man page fails with bad error message
> model <- system.file("models", "example.pomdp", package = "sarsop")
> policy <- tempfile(fileext = ".policyx")
> pomdpsol(model, output = policy, timeout = 1)
Error in processx::run(path, strsplit(args, " ")[[1]], spinner = spinner,  : 
  System command 'pomdpsol.exe' failed, exit status: -1073741515, stderr empty
Type .Last.error.trace to see where the error occurred

> #sessionInfo
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] sarsop_0.6.8

loaded via a namespace (and not attached):
 [1] processx_3.5.2  compiler_4.0.5  R6_2.5.0        Matrix_1.3-2    parallel_4.0.5 
 [6] tools_4.0.5     xml2_1.3.2      grid_4.0.5      digest_0.6.27   ps_1.6.0       
[11] lattice_0.20-41
cboettig commented 3 years ago

@mhahsler shot in the dark here since I can't reproduce the error, but can you try installing on Windows from source instead? (Our windows-CI checks install sarsop from the GitHub checkout, maybe something is getting corrupted in the Windows binary build from CRAN? seems unlikely since our Makevars.win basically just copies over the prebuilt binaries but who knows....

mhahsler commented 3 years ago

I know, issues with Windows are almost as difficult as problems with Solaris.

My test code in pomdp calls sarsop::pomdpsol and CRAN came back with this:

package pomdp_0.99.1.tar.gz does not pass the incoming checks automatically, please see the following pre-tests:
Windows: <https://win-builder.r-project.org/incoming_pretest/pomdp_0.99.1_20210513_015520/Windows/00check.log>
Status: 2 ERRORs, 1 NOTE
Debian: <https://win-builder.r-project.org/incoming_pretest/pomdp_0.99.1_20210513_015520/Debian/00check.log>
Status: 1 NOTE

Windows logs

* using log directory 'd:/RCompile/CRANincoming/R-devel/pomdp.Rcheck'
* using R version 4.1.0 RC (2021-05-10 r80288)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* checking for file 'pomdp/DESCRIPTION' ... OK
* this is package 'pomdp' version '0.99.1'
* package encoding: UTF-8
* checking CRAN incoming feasibility ... NOTE
Maintainer: 'Michael Hahsler <mhahsler@lyle.smu.edu>'
...

* checking tests ...
** running tests for arch 'i386' ... [19s] ERROR
  Running 'testthat.R' [19s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > library("testthat")
  >   
  > library("pomdp")
  > test_check("pomdp")
  == Failed tests ================================================================
  -- Error (test-solve_SARSOP.R:8:1): (code run outside of `test_that()`) --------
  Error: System command 'pomdpsol.exe' failed, exit status: -1073741511, stderr empty
  Backtrace:
      x
   1. \-pomdp::solve_SARSOP(Tiger) test-solve_SARSOP.R:8:0
   2.   +-base::do.call(...)
   3.   \-(function (model, output = tempfile(), precision = 0.001, timeout = NULL, ...
   4.     \-sarsop:::exec_program(...)
   5.       \-processx::run(...)
   6.         \-throw(...)

  [ FAIL 1 | WARN 0 | SKIP 0 | PASS 23 ]
  Error: Test failures
  Execution halted
** running tests for arch 'x64' ... [14s] ERROR
  Running 'testthat.R' [14s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
  > library("testthat")
  >   
  > library("pomdp")
  > test_check("pomdp")
  == Failed tests ================================================================
  -- Error (test-solve_SARSOP.R:8:1): (code run outside of `test_that()`) --------
  Error: System command 'pomdpsol.exe' failed, exit status: -1073741511, stderr empty
  Backtrace:
      x
   1. \-pomdp::solve_SARSOP(Tiger) test-solve_SARSOP.R:8:0
   2.   +-base::do.call(...)
   3.   \-(function (model, output = tempfile(), precision = 0.001, timeout = NULL, ...
   4.     \-sarsop:::exec_program(...)
   5.       \-processx::run(...)
   6.         \-throw(...)

  [ FAIL 1 | WARN 0 | SKIP 0 | PASS 23 ]
  Error: Test failures
  Execution halted
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes in 'inst/doc' ... OK
* checking re-building of vignette outputs ... [5s] OK
* checking PDF version of manual ... OK
* checking for detritus in the temp directory ... OK
* DONE
Status: 2 ERRORs, 1 NOTE

I have put if(sarsop::assert_has_appl()) { ... } around the test and now it does not complain anymore. I assume it is because the test is just not performed when sarsop cannot be executed.