[ARVADOS] updated: 1.1.1-120-g2d8d861

Git user git at public.curoverse.com
Mon Dec 4 11:11:53 EST 2017


Summary of changes:
 sdk/R/.RData                                     | Bin 94020 -> 136720 bytes
 sdk/R/DESCRIPTION                                |   4 +-
 sdk/R/R/Arvados.R                                |   9 +-
 sdk/R/R/Collection.R                             | 108 +++++++++++++++++++++++
 sdk/R/R/HttpParser.R                             |  17 ++++
 sdk/R/R/arvados_objects.R                        |  74 ----------------
 services/api/app/models/container.rb             |  15 ++++
 services/api/test/unit/container_request_test.rb |  29 ++++++
 8 files changed, 177 insertions(+), 79 deletions(-)
 create mode 100644 sdk/R/R/Collection.R

       via  2d8d861fadc8f3e0e7d5524c78f980dedc56f759 (commit)
       via  eb93b9b3b9d05c566f886b9a46bad4043d0a8534 (commit)
       via  4ea88c89b61931b2f588461d530b4fa7dcf7487d (commit)
       via  bc5d3ce17a0b3672b4ff2c24623febc549bdebe5 (commit)
       via  77a6645f2a8710a22a43909469077122834c93e6 (commit)
       via  8167db395a144238b1702c2bb5a40e4dd7db26ca (commit)
      from  02ce18b74c42b34a86208a713e00dfa0e0fe39de (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 2d8d861fadc8f3e0e7d5524c78f980dedc56f759
Merge: eb93b9b 4ea88c8
Author: Fuad Muhic <fmuhic at capeannenterprises.com>
Date:   Mon Dec 4 17:11:07 2017 +0100

    Merge branch 'master' of git.curoverse.com:arvados into 11876-r-sdk
    
    Arvados-DCO-1.1-Signed-off-by: Fuad Muhic <fmuhic at capeannenterprises.com>


commit eb93b9b3b9d05c566f886b9a46bad4043d0a8534
Author: Fuad Muhic <fmuhic at capeannenterprises.com>
Date:   Mon Dec 4 16:23:29 2017 +0100

    Added a new collection class. Added a method to retrieve list of files
    and folders in a collection.
    Arvados-DCO-1.1-Signed-off-by: Fuad Muhic <fmuhic at capeannenterprises.com>

diff --git a/sdk/R/.RData b/sdk/R/.RData
index 2b5f989..1e0b193 100644
Binary files a/sdk/R/.RData and b/sdk/R/.RData differ
diff --git a/sdk/R/DESCRIPTION b/sdk/R/DESCRIPTION
index c6afbbb..cc46f65 100644
--- a/sdk/R/DESCRIPTION
+++ b/sdk/R/DESCRIPTION
@@ -13,4 +13,6 @@ RoxygenNote: 6.0.1.9000
 Imports:
     httr,
     stringr,
-    jsonlite
+    jsonlite,
+    curl,
+    XML
diff --git a/sdk/R/R/Arvados.R b/sdk/R/R/Arvados.R
index 8b3b40b..d502b8d 100644
--- a/sdk/R/R/Arvados.R
+++ b/sdk/R/R/Arvados.R
@@ -1,5 +1,6 @@
 source("./R/HttpRequest.R")
 source("./R/HttpParser.R")
+source("./R/custom_classes.R")
 
 #' Arvados SDK Object
 #'
@@ -14,16 +15,16 @@ Arvados <- setRefClass(
     "Arvados",
 
     fields = list(
-        token = "character",
-        host  = "character"
+        token = "ANY",
+        host  = "ANY"
     ),
 
     methods = list(
 
-        initialize = function(auth_token, host_name) 
+        initialize = function(auth_token = NULL, host_name = NULL) 
         {
             version <- "v1"
-            #Todo(Fudo): Validate token
+            #Todo(Fudo): Set environment variables
             token <<- auth_token
             host  <<- paste0("https://", host_name, "/arvados/", version, "/")
         }
diff --git a/sdk/R/R/Collection.R b/sdk/R/R/Collection.R
new file mode 100644
index 0000000..037f711
--- /dev/null
+++ b/sdk/R/R/Collection.R
@@ -0,0 +1,108 @@
+source("./R/Arvados.R")
+source("./R/HttpParser.R")
+
+#' Collection Object
+#' 
+#' @details 
+#' Todo: Update description
+#' Collection
+#' 
+#' @param uuid Object ID
+#' @param etag Object version
+#' @param owner_uuid No description
+#' @param created_at No description
+#' @param modified_by_client_uuid No description
+#' @param modified_by_user_uuid No description
+#' @param modified_at No description
+#' @param portable_data_hash No description
+#' @param replication_desired No description
+#' @param replication_confirmed_at No description
+#' @param replication_confirmed No description
+#' @param updated_at No description
+#' @param manifest_text No description
+#' @param name No description
+#' @param description No description
+#' @param properties No description
+#' @param delete_at No description
+#' @param file_names No description
+#' @param trash_at No description
+#' @param is_trashed No description
+#' 
+#' @export
+Collection <- setRefClass(
+
+    "Collection",
+
+    #NOTE(Fudo): Fix types!
+    fields = list(uuid                     = "ANY",
+                  items                    = "ANY",
+                  etag                     = "ANY",
+                  owner_uuid               = "ANY",
+                  created_at               = "ANY",
+                  modified_by_client_uuid  = "ANY",
+                  modified_by_user_uuid    = "ANY",
+                  modified_at              = "ANY",
+                  portable_data_hash       = "ANY",
+                  replication_desired      = "ANY",
+                  replication_confirmed_at = "ANY",
+                  replication_confirmed    = "ANY",
+                  updated_at               = "ANY",
+                  manifest_text            = "ANY",
+                  name                     = "ANY",
+                  description              = "ANY",
+                  properties               = "ANY",
+                  delete_at                = "ANY",
+                  file_names               = "ANY",
+                  trash_at                 = "ANY",
+                  is_trashed               = "ANY",
+                  arvados_api              = "Arvados"
+    ),
+
+    methods = list(
+
+        initialize = function(api, uuid) 
+        {
+            arvados_api <<- api
+            result <- arvados_api$collection_get(uuid)
+            
+            uuid                     <<- result$uuid                               
+            etag                     <<- result$etag                               
+            owner_uuid               <<- result$owner_uuid                         
+            created_at               <<- result$created_at                         
+            modified_by_client_uuid  <<- result$modified_by_client_uuid            
+            modified_by_user_uuid    <<- result$modified_by_user_uuid              
+            modified_at              <<- result$modified_at                        
+            portable_data_hash       <<- result$portable_data_hash                 
+            replication_desired      <<- result$replication_desired                
+            replication_confirmed_at <<- result$replication_confirmed_at           
+            replication_confirmed    <<- result$replication_confirmed              
+            updated_at               <<- result$updated_at                         
+            manifest_text            <<- result$manifest_text                      
+            name                     <<- result$name                               
+            description              <<- result$description                        
+            properties               <<- result$properties                         
+            delete_at                <<- result$delete_at                          
+            file_names               <<- result$file_names                         
+            trash_at                 <<- result$trash_at                           
+            is_trashed               <<- result$is_trashed                         
+
+            items  <<- getCollectionContent()
+        },
+
+        getCollectionContent = function()
+        {
+            #IMPORTANT(Fudo): This url is hardcoded for now. Fix it later.
+            uri <- URLencode("https://collections.4xphq.arvadosapi.com/c=4xphq-4zz18-9d5b0qm4fgijeyi/_/")
+
+            # fetch directory listing via curl and parse XML response
+            h <- curl::new_handle()
+            curl::handle_setopt(h, customrequest = "PROPFIND")
+
+            #IMPORTANT(Fudo): Token is hardcoded as well. Write it properly.
+            curl::handle_setheaders(h, "Authorization" = paste("OAuth2 4invqy35tf70t7hmvdc83ges8ug9cklhgqq1l8gj2cjn18teuq"))
+            response <- curl::curl_fetch_memory(uri, h)
+
+            HttpParser()$parseWebDAVResponse(response, uri)
+        }
+    )
+)
diff --git a/sdk/R/R/HttpParser.R b/sdk/R/R/HttpParser.R
index 09304fc..ebe7d8c 100644
--- a/sdk/R/R/HttpParser.R
+++ b/sdk/R/R/HttpParser.R
@@ -17,6 +17,23 @@ HttpParser <- setRefClass(
             parsed_response <- httr::content(server_response, as = "parsed", type = "application/json")
 
             #Todo(Fudo): Create new Collection object and populate it
+        },
+
+        parseWebDAVResponse = function(response, uri)
+        {
+            #Todo(Fudo): Move this to HttpParser.
+            text <- rawToChar(response$content)
+            doc <- XML::xmlParse(text, asText=TRUE)
+
+            # calculate relative paths
+            base <- paste(paste("/", strsplit(uri, "/")[[1]][-1:-3], sep="", collapse=""), "/", sep="")
+            result <- unlist(
+                XML::xpathApply(doc, "//D:response/D:href", function(node) {
+                    sub(base, "", URLdecode(xmlValue(node)), fixed=TRUE)
+                })
+            )
+            result[result != ""]
         }
+
     )
 )
diff --git a/sdk/R/R/arvados_objects.R b/sdk/R/R/arvados_objects.R
index 88fd515..8b13789 100644
--- a/sdk/R/R/arvados_objects.R
+++ b/sdk/R/R/arvados_objects.R
@@ -1,75 +1 @@
-#' Collection Object
-#' 
-#' @details 
-#' Todo: Update description
-#' Collection
-#' 
-#' @param uuid Object ID
-#' @param etag Object version
-#' @param owner_uuid No description
-#' @param created_at No description
-#' @param modified_by_client_uuid No description
-#' @param modified_by_user_uuid No description
-#' @param modified_at No description
-#' @param portable_data_hash No description
-#' @param replication_desired No description
-#' @param replication_confirmed_at No description
-#' @param replication_confirmed No description
-#' @param updated_at No description
-#' @param manifest_text No description
-#' @param name No description
-#' @param description No description
-#' @param properties No description
-#' @param delete_at No description
-#' @param file_names No description
-#' @param trash_at No description
-#' @param is_trashed No description
-#' 
-#' @return Collection object
-#' 
-#' @family Collection functions
-#' @export
-Collection <- function(uuid                     = NULL,
-                       etag                     = NULL,
-                       owner_uuid               = NULL,
-                       created_at               = NULL,
-                       modified_by_client_uuid  = NULL,
-                       modified_by_user_uuid    = NULL,
-                       modified_at              = NULL,
-                       portable_data_hash       = NULL,
-                       replication_desired      = NULL,
-                       replication_confirmed_at = NULL,
-                       replication_confirmed    = NULL,
-                       updated_at               = NULL,
-                       manifest_text            = NULL,
-                       name                     = NULL,
-                       description              = NULL,
-                       properties               = NULL,
-                       delete_at                = NULL,
-                       file_names               = NULL,
-                       trash_at                 = NULL,
-                       is_trashed               = NULL)
-{
-    structure(list(uuid                     = uuid,
-                   etag                     = etag,
-                   owner_uuid               = owner_uuid,
-                   created_at               = created_at,
-                   modified_by_client_uuid  = modified_by_client_uuid,
-                   modified_by_user_uuid    = modified_by_user_uuid,
-                   modified_at              = modified_at,
-                   portable_data_hash       = portable_data_hash,
-                   replication_desired      = replication_desired,
-                   replication_confirmed_at = replication_confirmed_at,
-                   replication_confirmed    = replication_confirmed,
-                   updated_at               = updated_at,
-                   manifest_text            = manifest_text,
-                   name                     = name,
-                   description              = description,
-                   properties               = properties,
-                   delete_at                = delete_at,
-                   file_names               = file_names,
-                   trash_at                 = trash_at,
-                   is_trashed               = is_trashed),
-              class = "ArvadosCollection")
-}
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list