[ARVADOS] updated: 1.1.2-112-g7f2de2e

Git user git at public.curoverse.com
Thu Jan 11 17:03:36 EST 2018


Summary of changes:
 sdk/R/R/Arvados.R     | 52 +++++++++++++++++++++++++--------------------------
 sdk/R/R/ArvadosFile.R | 33 ++++++++++++++++++++++++--------
 sdk/R/README          | 19 +++++++++++++++++--
 3 files changed, 68 insertions(+), 36 deletions(-)

       via  7f2de2ec1d52c8e5984b610c5930f2d9629bd357 (commit)
       via  67b46a6c360a18fee84846d75622539220eca211 (commit)
      from  937c64f38ff59f11616ea8932b24116530f2e60f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 7f2de2ec1d52c8e5984b610c5930f2d9629bd357
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date:   Thu Jan 11 17:02:12 2018 -0500

    11876: Add ArvadosFile$connection and $flush
    
    Convenience functions for working with standard R functions like
    read.table() and write.table().
    
    Update documentation
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>

diff --git a/sdk/R/R/ArvadosFile.R b/sdk/R/R/ArvadosFile.R
index 8c2e9e2..2da3db3 100644
--- a/sdk/R/R/ArvadosFile.R
+++ b/sdk/R/R/ArvadosFile.R
@@ -88,18 +88,18 @@ ArvadosFile <- R6::R6Class(
 
             if(length > 0)
                 range = paste0(range, offset + length - 1)
-            
+
             fileURL = paste0(private$collection$api$getWebDavHostName(),
                              "c=", private$collection$uuid, "/", self$getRelativePath());
 
             if(offset == 0 && length == 0)
             {
                 headers <- list(Authorization = paste("OAuth2",
-                                                      private$collection$api$getToken())) 
+                                                      private$collection$api$getToken()))
             }
             else
             {
-                headers <- list(Authorization = paste("OAuth2", private$collection$api$getToken()), 
+                headers <- list(Authorization = paste("OAuth2", private$collection$api$getToken()),
                                 Range = range)
             }
 
@@ -111,15 +111,31 @@ ArvadosFile <- R6::R6Class(
             parsedServerResponse <- httr::content(serverResponse, contentType)
             parsedServerResponse
         },
-        
+
+	connection = function(rw)
+	{
+	  if (rw == "r") {
+	    return(textConnection(self$read("text")))
+	  } else if (rw == "w") {
+	    private$buffer <- textConnection(NULL, "w")
+	    return(private$buffer)
+	  }
+	},
+
+	flush = function() {
+	  v <- textConnectionValue(private$buffer)
+	  close(private$buffer)
+	  self$write(paste(v, collapse='\n'))
+	},
+
         write = function(content, contentType = "text/html")
         {
             if(is.null(private$collection))
                 stop("ArvadosFile doesn't belong to any collection.")
 
-            fileURL = paste0(private$collection$api$getWebDavHostName(), 
+            fileURL = paste0(private$collection$api$getWebDavHostName(),
                              "c=", private$collection$uuid, "/", self$getRelativePath());
-            headers <- list(Authorization = paste("OAuth2", private$collection$api$getToken()), 
+            headers <- list(Authorization = paste("OAuth2", private$collection$api$getToken()),
                             "Content-Type" = contentType)
             body <- content
 
@@ -193,8 +209,9 @@ ArvadosFile <- R6::R6Class(
         parent     = NULL,
         collection = NULL,
         http       = NULL,
-        httpParser = NULL
+        httpParser = NULL,
+        buffer     = NULL
     ),
-    
+
     cloneable = FALSE
 )
diff --git a/sdk/R/README b/sdk/R/README
index 2e1a4df..7f984fe 100644
--- a/sdk/R/README
+++ b/sdk/R/README
@@ -72,9 +72,9 @@ collection <- Collection$new(arv, "uuid")
 
 --------------------------------------------------------------------------------------------------------------------------------
 
-#Get file/folder content as character vector
+#Get list of files
 
-collection$getFileContent()
+collection$getFileListing()
 
 --------------------------------------------------------------------------------------------------------------------------------
 
@@ -88,6 +88,21 @@ arvadosSubcollection <- collection$get("location/to/my/directory/")
 
 --------------------------------------------------------------------------------------------------------------------------------
 
+#Read a table
+
+arvadosFile <- collection$get("myinput.txt")
+arvConnection <- arvadosFile$connection("r")
+mytable <- read.table(arvConnection)
+
+#Write a table
+
+arvadosFile <- collection$create("myoutput.txt")
+arvConnection <- arvadosFile$connection("w")
+write.table(mytable, arvConnection)
+arvadosFile$flush()
+
+--------------------------------------------------------------------------------------------------------------------------------
+
 #Read whole file or just a portion of it.
 
 fileContent <- arvadosFile$read()

commit 67b46a6c360a18fee84846d75622539220eca211
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date:   Thu Jan 11 14:45:43 2018 -0500

    11876: Fix bug using Arvados$new with no parameters
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>

diff --git a/sdk/R/R/Arvados.R b/sdk/R/R/Arvados.R
index 0317266..d7f52e2 100644
--- a/sdk/R/R/Arvados.R
+++ b/sdk/R/R/Arvados.R
@@ -15,7 +15,7 @@ Arvados <- R6::R6Class(
 
     public = list(
 
-        initialize = function(auth_token = NULL, host_name = NULL) 
+        initialize = function(auth_token = NULL, host_name = NULL)
         {
             if(!is.null(host_name))
                Sys.setenv(ARVADOS_API_HOST  = host_name)
@@ -23,16 +23,16 @@ Arvados <- R6::R6Class(
             if(!is.null(auth_token))
                 Sys.setenv(ARVADOS_API_TOKEN = auth_token)
 
-            host  <- Sys.getenv("ARVADOS_API_HOST");
+            host_name  <- Sys.getenv("ARVADOS_API_HOST");
             token <- Sys.getenv("ARVADOS_API_TOKEN");
 
-            if(host == "" | token == "")
+            if(host_name == "" | token == "")
                 stop(paste0("Please provide host name and authentification token",
                             " or set ARVADOS_API_HOST and ARVADOS_API_TOKEN",
                             " environmental variables."))
 
             version <- "v1"
-            host  <- paste0("https://", host, "/arvados/", version, "/")
+            host  <- paste0("https://", host_name, "/arvados/", version, "/")
 
             private$http       <- HttpRequest$new()
             private$httpParser <- HttpParser$new()
@@ -71,7 +71,7 @@ Arvados <- R6::R6Class(
             private$webDavHostName
         },
 
-        getCollection = function(uuid) 
+        getCollection = function(uuid)
         {
             collectionURL <- paste0(private$host, "collections/", uuid)
             headers <- list(Authorization = paste("OAuth2", private$token))
@@ -81,12 +81,12 @@ Arvados <- R6::R6Class(
             collection <- private$httpParser$parseJSONResponse(serverResponse)
 
             if(!is.null(collection$errors))
-                stop(collection$errors)       
+                stop(collection$errors)
 
             collection
         },
 
-        listCollections = function(filters = NULL, limit = 100, offset = 0) 
+        listCollections = function(filters = NULL, limit = 100, offset = 0)
         {
             collectionURL <- paste0(private$host, "collections")
             headers <- list(Authorization = paste("OAuth2", private$token))
@@ -100,7 +100,7 @@ Arvados <- R6::R6Class(
             collections <- private$httpParser$parseJSONResponse(serverResponse)
 
             if(!is.null(collections$errors))
-                stop(collections$errors)       
+                stop(collections$errors)
 
             collections
         },
@@ -114,7 +114,7 @@ Arvados <- R6::R6Class(
             private$fetchAllItems(collectionURL, filters)
         },
 
-        deleteCollection = function(uuid) 
+        deleteCollection = function(uuid)
         {
             collectionURL <- paste0(private$host, "collections/", uuid)
             headers <- list("Authorization" = paste("OAuth2", private$token),
@@ -125,12 +125,12 @@ Arvados <- R6::R6Class(
             collection <- private$httpParser$parseJSONResponse(serverResponse)
 
             if(!is.null(collection$errors))
-                stop(collection$errors)       
+                stop(collection$errors)
 
             collection
         },
 
-        updateCollection = function(uuid, newContent) 
+        updateCollection = function(uuid, newContent)
         {
             collectionURL <- paste0(private$host, "collections/", uuid)
             headers <- list("Authorization" = paste("OAuth2", private$token),
@@ -148,12 +148,12 @@ Arvados <- R6::R6Class(
             collection <- private$httpParser$parseJSONResponse(serverResponse)
 
             if(!is.null(collection$errors))
-                stop(collection$errors)       
+                stop(collection$errors)
 
             collection
         },
 
-        createCollection = function(content) 
+        createCollection = function(content)
         {
             collectionURL <- paste0(private$host, "collections")
             headers <- list("Authorization" = paste("OAuth2", private$token),
@@ -170,7 +170,7 @@ Arvados <- R6::R6Class(
             collection <- private$httpParser$parseJSONResponse(serverResponse)
 
             if(!is.null(collection$errors))
-                stop(collection$errors)       
+                stop(collection$errors)
 
             collection
         },
@@ -185,12 +185,12 @@ Arvados <- R6::R6Class(
             project <- private$httpParser$parseJSONResponse(serverResponse)
 
             if(!is.null(project$errors))
-                stop(project$errors)       
+                stop(project$errors)
 
             project
         },
 
-        createProject = function(content) 
+        createProject = function(content)
         {
             projectURL <- paste0(private$host, "groups")
             headers <- list("Authorization" = paste("OAuth2", private$token),
@@ -206,12 +206,12 @@ Arvados <- R6::R6Class(
             project <- private$httpParser$parseJSONResponse(serverResponse)
 
             if(!is.null(project$errors))
-                stop(project$errors)       
+                stop(project$errors)
 
             project
         },
 
-        updateProject = function(uuid, newContent) 
+        updateProject = function(uuid, newContent)
         {
             projectURL <- paste0(private$host, "groups/", uuid)
             headers <- list("Authorization" = paste("OAuth2", private$token),
@@ -227,12 +227,12 @@ Arvados <- R6::R6Class(
             project <- private$httpParser$parseJSONResponse(serverResponse)
 
             if(!is.null(project$errors))
-                stop(project$errors)       
+                stop(project$errors)
 
             project
         },
 
-        listProjects = function(filters = NULL, limit = 100, offset = 0) 
+        listProjects = function(filters = NULL, limit = 100, offset = 0)
         {
             projectURL <- paste0(private$host, "groups")
             headers <- list(Authorization = paste("OAuth2", private$token))
@@ -248,7 +248,7 @@ Arvados <- R6::R6Class(
             projects <- private$httpParser$parseJSONResponse(serverResponse)
 
             if(!is.null(projects$errors))
-                stop(projects$errors)       
+                stop(projects$errors)
 
             projects
         },
@@ -265,7 +265,7 @@ Arvados <- R6::R6Class(
             private$fetchAllItems(projectURL, filters)
         },
 
-        deleteProject = function(uuid) 
+        deleteProject = function(uuid)
         {
             projectURL <- paste0(private$host, "groups/", uuid)
             headers <- list("Authorization" = paste("OAuth2", private$token),
@@ -276,12 +276,12 @@ Arvados <- R6::R6Class(
             project <- private$httpParser$parseJSONResponse(serverResponse)
 
             if(!is.null(project$errors))
-                stop(project$errors)       
+                stop(project$errors)
 
             project
         }
     ),
-    
+
     private = list(
 
         token          = NULL,
@@ -309,7 +309,7 @@ Arvados <- R6::R6Class(
                 parsedResponse <- private$httpParser$parseJSONResponse(serverResponse)
 
                 if(!is.null(parsedResponse$errors))
-                    stop(parsedResponse$errors)       
+                    stop(parsedResponse$errors)
 
                 items          <- c(items, parsedResponse$items)
                 offset         <- length(items)
@@ -319,6 +319,6 @@ Arvados <- R6::R6Class(
             items
         }
     ),
-    
+
     cloneable = FALSE
 )

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list