Skip to end of banner
Go to start of banner

R Client Bootstrap

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

R Client Development

Install the R Client

  1. Follow the instructions to install the current production version of the R client, this will automatically install most dependencies 

    Installation:

    1. If needed, install R from http://cran.r-project.org/
    2. 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

    3. 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’

    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

  2. Install any additional required dependences, from the R prompt
    • install.packages(c("RUnit","rJava"))
  3. Install the developer tools needed for R Developer Tools#R
  4. 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>
      
  5. 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
  6. Build the Sage Bionetworks R package, from the shell
    • Rcmd INSTALL rSynapseClient
  7. If you see a loading error for rJava, include $JAVA_HOME$/jre/bin/server in your PATH.
  8. 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

  1. 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

    1. running the following single integration tests:
      ~/platform/trunk/integration-test>mvn -Dit.test=IT100BackupRestoration verify
      
    2. and then once the database is populated we can restart the local stack in debug mode:
      ~/platform/trunk/integration-test>mvn cargo:run
      
  2. 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

  1. Install StatET: http://www.walware.de/goto/statet
  2. In Eclipse: Window > Open Perspective > Other... > StatET
  3. File > New > R-Project
  4. Type project name: "rSynapseClient"
  5. Unclick 'use default location'
  6. Enter name of folder where you checked out the project from SVN, e.g. ...\eclipse projects\trunk\SynapseClient\
  7. Click 'finish'

You will then have the project in Eclipse.

  • No labels