natverse / rcatmaid

R package providing API access to the CATMAID web image annotation tool
https://natverse.github.io/rcatmaid
GNU General Public License v3.0
9 stars 6 forks source link

Examples failing when using catmaid_login() #110

Closed SridharJagannathan closed 5 years ago

SridharJagannathan commented 5 years ago

Scenario:

Add an example to the function catmaid_login() by using roxygen comments like below:

' @examples

' conn=catmaid_login()

Once the R cmd check build is run, this example fails in the linux machine but runs successfully in the mac machine.

Possible rootcause:

I found that using the below code:

' @examples

' Sys.getenv()

' conn=catmaid_login()

The environment variables like catmaid.server, catmaid.authname, catmaid.authpassword, catmaid.token are not reported by the system (only linux the mac machine reports it). It seems that the bash version in linux (4.3.48(1)-release) ignores variables that have periods ('.') in the variable name however the lower version of bash in mac (3.2.57(1)-release) does report the variable names.

Possible solution:

Step 1: Add new environment variables in renviron file replacing the ('.') with ('_') So change catmaid.server etc to catmaid_server Step 2: It seems the function "getenvoroption" uses the prefix as the default option (prefix="catmaid.") gets the default options and hence this needs to be changed. For example check the function "catmaid_connection_getenv" the possiblities for the environmental name include "catmaidenvnames=paste0("catmaid.", varnames)" This could be implemented something like: tempval = Sys.getenv() tempval[grep("^catmaid(.|_)", names(tempval))] Then if the variable with ('.') was available choose it with a higher priority than the one with ('\') to maintain previous functionality.

Possible impacts:

Also take care to change the set side of the function 'catmaid_connection_unsetenv'

jefferis commented 5 years ago

The changes that you discussed clearly make sense after your detective work to discover why catmaid_login() was not picking up the catmaid.* environment variables on the linux desktop.

In terms of the scenario you describe, there are already examples for the catmaid_login function (see http://jefferis.github.io/rcatmaid/reference/catmaid_login.html#examples) but they are marked as dontrun because they depend on authentication credentials that will not be available for most users or on the travis CI test environment.

jefferis commented 5 years ago

PS @SridharJagannathan you might want to review the 3 additional changes I made.