R Client Development
Install the R Client
- Follow the instructions to install the current prod version of the R client, this will automagically install most dependencies
Installation:
- If needed, install R from http://cran.r-project.org/
From the R command prompt, install the following packages:
source('http://depot.sagebase.org/CRAN.R') pkgInstall("synapseClient") # If you plan to use a private SFTP server for hosting data, install the optional Rsftp library: pkgInstall("Rsftp")
At a later date, we anticipate that these packages will be available via Bioconductor or CRAN
Also possibly need to install these:
pkgInstall("RCurl") pkgInstall("rjson") pkgInstall("digest") pkgInstall("RUnit")
Supported Platforms:
- Windows
- Mac OSX
- Any Linux/Unix platform will use the source of the package and compile/install as-needed
Common Installation Problems
RCurl package cannot be installed
If you see an error like:
- installing source package ‘RCurl’ ...
- package ‘RCurl’ correctement décompressé et sommes MD5 vérifiées
checking for curl-config... no
Cannot find curl-config
ERROR: configuration failed for package ‘RCurl’
- package ‘RCurl’ correctement décompressé et sommes MD5 vérifiées
then there are missing dependencies for the RCurl package, upon which the Synapse R client depends. For information on resolving these missing dependencies, please see: http://www.omegahat.org/RCurl/FAQ.html
- Install any additional required dependences, from the R prompt
install.packages(c("RUnit","rJava"))
- Install the developer tools needed for R Developer Tools#R
- Make sure your maven settings file is pointing to the 64bit version of R
Mac OSX
<properties> <local.r.path>/usr/bin/r</local.r.path> ... </properties>
Windows
<properties> <local.r.path>C:\Program Files\R\R-2.13.0\bin\x64\R.exe</local.r.path> ... </properties>
- You now need to checkout and build the entire Synapse code tree since the R client now depends upon the Java client, Get the Maven Build working
- Build the Sage Bionetworks R package, from the shell
- R CMD INSTALL rSynapseClient
- Now you are ready to use it, from the R prompt
library (synapseClient)
Note that every time you change the Java Synapse Client and want to pick up those changes in the R client, you'll need to do an mvn install
in each.
How to run the R unit tests
How to run the installed R unit tests
> synapseAuthServiceEndpoint("https://auth-staging.sagebase.org/auth/v1") > synapseRepoServiceEndpoint("https://repo-staging.sagebase.org/repo/v1") > synapseClient:::.test() RUNIT TEST PROTOCOL -- Wed May 25 15:24:15 2011 *********************************************** Number of test functions: 1 Number of errors: 0 Number of failures: 0 1 Test Suite : synapseClient RUnit Tests - 1 test function, 0 errors, 0 failures Number of test functions: 1 Number of errors: 0 Number of failures: 0
How to run your local copy of the R unit tests
> synapseAuthServiceEndpoint("https://auth-staging.sagebase.org/auth/v1") > synapseRepoServiceEndpoint("https://repo-staging.sagebase.org/repo/v1") > synapseClient:::.test('/Users/deflaux/platform/trunk/client/rSynapseClient/inst/unitTests') Error: object '*tmp*' not found Timing stopped at: 0 0 0 Error in func() : could not find function "synapseQuery" RUNIT TEST PROTOCOL -- Wed May 25 15:16:24 2011 *********************************************** Number of test functions: 5 Number of errors: 1 Number of failures: 0 1 Test Suite : synapseClient RUnit Tests - 5 test functions, 1 error, 0 failures ERROR in unitTestJsonCorretlyParsed: Error in func() : could not find function "synapseQuery" Test files with failing tests test_synapseQuery.R unitTestJsonCorretlyParsed Error in synapseClient:::.test("/Users/deflaux/platform/trunk/client/rSynapseClient/inst/unitTests") : unit tests failed for package synapseClient >
How to run the R integration tests
How to run the installed integration tests
> synapseAuthServiceEndpoint("https://auth-staging.sagebase.org/auth/v1") > synapseRepoServiceEndpoint("https://repo-staging.sagebase.org/repo/v1") > synapseLogin("YourUsername", "YourPassword") > synapseClient:::.integrationTest() Error: attempt to apply non-function Error: attempt to apply non-function Error: attempt to apply non-function Error: attempt to apply non-function RUNIT TEST PROTOCOL -- Wed May 25 15:25:52 2011 *********************************************** Number of test functions: 4 Number of errors: 0 Number of failures: 0 1 Test Suite : synapseClient RUnit Tests - 4 test functions, 0 errors, 0 failures Number of test functions: 4 Number of errors: 0 Number of failures: 0 >
How to run your local copy of the R integration tests
> synapseAuthServiceEndpoint("https://auth-staging.sagebase.org/auth/v1") > synapseRepoServiceEndpoint("https://repo-staging.sagebase.org/repo/v1") > synapseLogin("YourUsername", "YourPassword") > synapseClient:::.integrationTest('/Users/deflaux/platform/trunk/client/rSynapseClient/inst/integrationTests') Error: attempt to apply non-function Error: attempt to apply non-function Error in parse(n = -1, file = file) : 27:84: unexpected ')' 26: integrationTestPaging <- function() { 27: firstPagePackets <- synapseQuery('select * from dataset where limit=20 offset=1')) ^ RUNIT TEST PROTOCOL -- Wed May 25 15:27:38 2011 *********************************************** Number of test functions: 5 Number of errors: 1 Number of failures: 0 1 Test Suite : synapseClient RUnit Tests - 5 test functions, 1 error, 0 failures ERROR in /Users/deflaux/platform/trunk/client/rSynapseClient/inst/integrationTests/test_synapseQuery.R: Error while sourcing /Users/deflaux/platform/trunk/client/rSynapseClient/inst/integrationTests/test_synapseQuery.R : Error in parse(n = -1, file = file) : 27:84: unexpected ')' 26: integrationTestPaging <- function() { 27: firstPagePackets <- synapseQuery('select * from dataset where limit=20 offset=1')) ^ Test files with failing tests test_synapseQuery.R /Users/deflaux/platform/trunk/client/rSynapseClient/inst/integrationTests/test_synapseQuery.R Error in synapseClient:::.integrationTest("/Users/deflaux/platform/trunk/client/rSynapseClient/inst/integrationTests") : integration tests failed for package synapseClient >
How to run the R integration tests against your local stack
The wiki generator and several of our integration tests expect a subset of prod SageBioCurated data to exist in the service. To populate a local stack with that data, do this by
- running the following single integration tests:
~/platform/trunk/integration-test>mvn -Dit.test=IT100BackupRestoration verify
- and then once the database is populated we can restart the local stack in debug mode:
~/platform/trunk/integration-test>mvn cargo:run
- running the following single integration tests:
Run the R unit and/or integration tests interactively. Remember to tell R to hit your local stack and use the integration test user account:
library(synapseClient) synapseAuthServiceEndpoint(endpoint='http://localhost:8080/services-authentication-0.10-SNAPSHOT/auth/v1') synapseRepoServiceEndpoint(endpoint='http://localhost:8080/services-repository-0.10-SNAPSHOT/repo/v1') synapseLogin(username='devUser1@sagebase.org', password='password')
How to enable verbose mode
Some what verbose:
synapseClient:::.setCache("debug", TRUE)
Really, really verbose:
synapseClient:::.setCache("debug", TRUE) synapseClient:::.setCache("curlOpts", list(ssl.verifypeer = FALSE, verbose = TRUE))
How to import the project into Eclipse
- Install StatET: http://www.walware.de/goto/statet
- In Eclipse: Window > Open Perspective > Other... > StatET
- File > New > R-Project
- Type project name: "rSynapseClient"
- Unclick 'use default location'
- Enter name of folder where you checked out the project from SVN, e.g. ...\eclipse projects\trunk\SynapseClient\
- Click 'finish'
You will then have the project in Eclipse.