[ARVADOS] updated: 1.1.1-308-g790a912

Git user git at public.curoverse.com
Tue Dec 19 09:37:09 EST 2017


Summary of changes:
 .../app/assets/javascripts/work_unit_log.js        |   5 +-
 apps/workbench/app/views/layouts/body.html.erb     |   9 +-
 apps/workbench/config/application.default.yml      |   5 +
 apps/workbench/test/integration/work_units_test.rb |   2 +-
 sdk/R/.RData                                       | Bin 189909 -> 0 bytes
 sdk/R/DESCRIPTION                                  |   1 +
 sdk/R/NAMESPACE                                    |   1 -
 sdk/R/R/ArvadosFile.R                              |  35 +++++
 sdk/R/R/CTest.R                                    | 173 ---------------------
 sdk/R/R/Collection.R                               |  38 ++++-
 sdk/R/R/CollectionTree.R                           |   6 +-
 sdk/R/R/HttpRequest.R                              |   9 ++
 sdk/R/R/Subcollection.R                            |  41 ++++-
 sdk/R/man/CTest.Rd                                 |  17 --
 sdk/R/man/Collection.Rd                            |   2 +-
 sdk/go/arvadostest/fixtures.go                     |   3 +
 .../test/fixtures/api_client_authorizations.yml    |  11 ++
 .../crunch-dispatch-slurm/crunch-dispatch-slurm.go |   7 +-
 services/keep-web/handler.go                       |   5 +-
 services/keep-web/webdav.go                        |  18 +++
 services/keepproxy/keepproxy.go                    |  30 ++--
 services/keepproxy/keepproxy_test.go               |  99 ++++++------
 22 files changed, 251 insertions(+), 266 deletions(-)
 delete mode 100644 sdk/R/.RData
 delete mode 100644 sdk/R/R/CTest.R
 delete mode 100644 sdk/R/man/CTest.Rd

       via  790a912ff48b90cba284a0a6b5b4e34db7b22078 (commit)
       via  9d633e1cc0f3842edf6cef1a9f6d7f4724ab81bf (commit)
       via  48c12133f505655cfec109d4b3af4297f3e08aee (commit)
       via  5512f001241c17152087ed5b5a28f94a9c629541 (commit)
       via  dd8e2deab16cfdf261c45e139be38b756f8bb324 (commit)
       via  0ed6f60c51ad94240cfd811e65cdb788a8f4e80e (commit)
       via  da18d58d7902789f20be448971b194ba4a5cc9db (commit)
       via  0c835b7d7710ef6ecb08c2d54802951f137f0cb2 (commit)
       via  7aa1bc6eaf4d340d6e45226003b776d521309d69 (commit)
       via  737f7d618ffc18152c5d09416884910bd180d890 (commit)
       via  e112475459e4cab53cac0121606bc895efeb5ae5 (commit)
       via  484246ac0d582f08f924b5a347f66135c939c6f6 (commit)
      from  11b903121f9c9505e529bb4b8965d56c1f8f96e0 (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 790a912ff48b90cba284a0a6b5b4e34db7b22078
Merge: 9d633e1 48c1213
Author: Fuad Muhic <fmuhic at capeannenterprises.com>
Date:   Tue Dec 19 15:36:46 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 9d633e1cc0f3842edf6cef1a9f6d7f4724ab81bf
Author: Fuad Muhic <fmuhic at capeannenterprises.com>
Date:   Tue Dec 19 15:34:44 2017 +0100

    Added feature to move File-like object inside collection.
    
    Arvados-DCO-1.1-Signed-off-by: Fuad Muhic <fmuhic at capeannenterprises.com>

diff --git a/sdk/R/.RData b/sdk/R/.RData
deleted file mode 100644
index 1344e2a..0000000
Binary files a/sdk/R/.RData and /dev/null differ
diff --git a/sdk/R/DESCRIPTION b/sdk/R/DESCRIPTION
index 7eb152f..0e586e9 100644
--- a/sdk/R/DESCRIPTION
+++ b/sdk/R/DESCRIPTION
@@ -1,6 +1,7 @@
 Package: ArvadosR
 Type: Package
 Title: Arvados R SDK
+Version: 0.0.1
 Author: Fuad Muhic
 Maintainer: Ward Vandewege <wvandewege at veritasgenetics.com>
 Description: This is the Arvados R SDK
diff --git a/sdk/R/NAMESPACE b/sdk/R/NAMESPACE
index 8b2f567..1c94e71 100644
--- a/sdk/R/NAMESPACE
+++ b/sdk/R/NAMESPACE
@@ -2,7 +2,6 @@
 
 export(Arvados)
 export(ArvadosFile)
-export(CTest)
 export(Collection)
 export(CollectionTree)
 export(Subcollection)
diff --git a/sdk/R/R/ArvadosFile.R b/sdk/R/R/ArvadosFile.R
index c8950c6..85d11c7 100644
--- a/sdk/R/R/ArvadosFile.R
+++ b/sdk/R/R/ArvadosFile.R
@@ -104,6 +104,35 @@ ArvadosFile <- R6::R6Class(
 
             parsedServerResponse <- httr::content(serverResponse, "text")
             parsedServerResponse
+        },
+
+        move = function(newLocation)
+        {
+            if(endsWith(newLocation, paste0(private$name, "/")))
+            {
+                newLocation <- substr(newLocation, 0, nchar(newLocation) - nchar(paste0(private$name, "/")))
+            }
+            else if(endsWith(newLocation, private$name))
+            {
+                newLocation <- substr(newLocation, 0, nchar(newLocation) - nchar(private$name))
+            }
+            else
+            {
+                stop("Destination path is not valid.")
+            }
+
+            newParent <- private$collection$get(newLocation)
+
+            if(is.null(newParent))
+            {
+                stop("Unable to get destination subcollectin")
+            }
+
+            status <- private$collection$.__enclos_env__$private$moveOnRest(self$getRelativePath(), paste0(newParent$getRelativePath(), "/", self$getName()))
+
+            private$attachToParent(newParent)
+
+            paste("Status code :", status$status_code)
         }
     ),
 
@@ -138,6 +167,12 @@ ArvadosFile <- R6::R6Class(
                 private$parent$.__enclos_env__$private$removeChild(private$name)
                 private$parent <- NULL
             }
+        },
+
+        attachToParent = function(parent)
+        {
+            parent$.__enclos_env__$private$children <- c(parent$.__enclos_env__$private$children, self)
+            private$parent <- parent
         }
     ),
     
diff --git a/sdk/R/R/CTest.R b/sdk/R/R/CTest.R
deleted file mode 100644
index bdef950..0000000
--- a/sdk/R/R/CTest.R
+++ /dev/null
@@ -1,173 +0,0 @@
-source("./R/Subcollection.R")
-source("./R/ArvadosFile.R")
-source("./R/HttpRequest.R")
-source("./R/HttpParser.R")
-
-#' Arvados Collection Object
-#'
-#' Update description
-#'
-#' @examples arv = Collection$new(api, uuid)
-#' @export Collection
-Collection <- R6::R6Class(
-
-    "Collection",
-
-    public = list(
-
-        api  = NULL,
-        uuid = NULL,
-
-        initialize = function(api, uuid)
-        {
-            self$api <- api
-            private$http <- HttpRequest$new()
-            private$httpParser <- HttpParser$new()
-
-            self$uuid <- uuid
-            collection <- self$api$getCollection(uuid)
-
-            private$fileContent <- private$getCollectionContent()
-            private$tree <- CollectionTree$new(private$fileContent, self)
-        },
-
-        add = function(content, relativePath = "")
-        {
-            if(relativePath == "" ||
-               relativePath == "." ||
-               relativePath == "./")
-            {
-                subcollection <- private$tree$.__enclos_env__$private$tree
-            }
-            else
-            {
-                if(endsWith(relativePath, "/") && nchar(relativePath) > 0)
-                    relativePath <- substr(relativePath, 1, nchar(relativePath) - 1)
-
-                subcollection <- self$get(relativePath)
-            }
-
-            if(is.null(subcollection))
-                stop(paste("Subcollection", relativePath, "doesn't exist."))
-
-            if(is.character(content))
-            {
-                sapply(content, function(fileName)
-                {
-                    subcollection$add(ArvadosFile$new(fileName))
-                })
-            }
-            else if("ArvadosFile"   %in% class(content) ||
-                    "Subcollection" %in% class(content))
-            {
-                subcollection$add(content)
-            }
-        },
-
-        remove = function(content)
-        {
-            if(is.character(content))
-            {
-                sapply(content, function(filePath)
-                {
-                    if(endsWith(filePath, "/") && nchar(filePath) > 0)
-                        filePath <- substr(filePath, 1, nchar(filePath) - 1)
-
-                    file <- self$get(filePath)
-
-                    if(is.null(file))
-                        stop(paste("File", filePath, "doesn't exist."))
-
-                    file$removeFromCollection()
-                })
-            }
-            else if("ArvadosFile"   %in% class(content) ||
-                    "Subcollection" %in% class(content))
-            {
-                if(is.null(content$.__enclos_env__$private$collection) || 
-                   content$.__enclos_env__$private$collection$uuid != self$uuid)
-                    stop("Subcollection doesn't belong to this collection.")
-
-                content$removeFromCollection()
-            }
-        },
-
-        getTree = function() private$tree,
-
-        getFileContent = function() private$getCollectionContent(),
-
-        get = function(relativePath)
-        {
-            private$tree$getElement(relativePath)
-        }
-    ),
-
-    private = list(
-
-        http       = NULL,
-        httpParser = NULL,
-        tree       = NULL,
-
-        fileContent = NULL,
-
-        getCollectionContent = function()
-        {
-            collectionURL <- URLencode(paste0(self$api$getWebDavHostName(), "c=", self$uuid))
-
-            headers = list("Authorization" = paste("OAuth2", self$api$getToken()))
-
-            response <- private$http$PROPFIND(collectionURL, headers)
-
-            parsedResponse <- private$httpParser$parseWebDAVResponse(response, collectionURL)
-            parsedResponse[-1]
-        },
-
-        createFilesOnREST = function(files)
-        {
-            sapply(files, function(filePath)
-            {
-                private$createNewFile(filePath, NULL, "text/html")
-            })
-        },
-        
-        generateTree = function(content)
-        {
-            treeBranches <- sapply(collectionContent, function(filePath)
-            {
-                splitPath <- unlist(strsplit(filePath$name, "/", fixed = TRUE))
-
-                branch = private$createBranch(splitPath, filePath$fileSize)      
-            })
-        },
-
-        createNewFile = function(relativePath, content, contentType)
-        {
-            fileURL <- paste0(self$api$getWebDavHostName(), "c=", self$uuid, "/", relativePath);
-            headers <- list(Authorization = paste("OAuth2", self$api$getToken()), 
-                            "Content-Type" = contentType)
-            body <- content
-
-            serverResponse <- private$http$PUT(fileURL, headers, body)
-
-            if(serverResponse$status_code != 201)
-                stop(paste("Server code:", serverResponse$status_code))
-
-            print(paste("File created:", relativePath))
-        },
-        
-        deleteFromREST = function(relativePath)
-        {
-            fileURL <- paste0(self$api$getWebDavHostName(), "c=", self$uuid, "/", relativePath);
-            headers <- list(Authorization = paste("OAuth2", self$api$getToken())) 
-
-            serverResponse <- private$http$DELETE(fileURL, headers)
-
-            if(serverResponse$status_code != 204)
-                stop(paste("Server code:", serverResponse$status_code))
-
-            print(paste("File deleted", relativePath))
-        }
-    ),
-
-    cloneable = FALSE
-)
diff --git a/sdk/R/R/Collection.R b/sdk/R/R/Collection.R
index 94141d9..ea6f692 100644
--- a/sdk/R/R/Collection.R
+++ b/sdk/R/R/Collection.R
@@ -8,9 +8,11 @@ source("./R/HttpParser.R")
 #' Update description
 #'
 #' @examples arv = Collection$new(api, uuid)
-#' @export CTest
-CTest <- R6::R6Class(
-    "CTest",
+#' @export Collection
+Collection <- R6::R6Class(
+
+    "Collection",
+
     public = list(
 
         api  = NULL,
@@ -90,7 +92,18 @@ CTest <- R6::R6Class(
             }
         },
 
-        getTree = function() private$tree,
+        move = function(content, newLocation)
+        {
+            if(endsWith(content, "/"))
+                content <- substr(content, 0, nchar(content) - 1)
+
+            elementToMove <- self$get(content)
+
+            if(is.null(elementToMove))
+                stop("Element you want to move doesn't exist in the collection.")
+
+            elementToMove$move(newLocation)
+        },
 
         getFileContent = function() private$getCollectionContent(),
 
@@ -164,6 +177,23 @@ CTest <- R6::R6Class(
                 stop(paste("Server code:", serverResponse$status_code))
 
             print(paste("File deleted", relativePath))
+        },
+
+        moveOnRest = function(from, to)
+        {
+            collectionURL <- URLencode(paste0(self$api$getWebDavHostName(), "c=", self$uuid, "/"))
+            fromURL <- paste0(collectionURL, from)
+            toURL <- paste0(collectionURL, to)
+
+            headers = list("Authorization" = paste("OAuth2", self$api$getToken()),
+                           "Destination" = toURL)
+
+            serverResponse <- private$http$MOVE(fromURL, headers)
+
+            if(serverResponse$status_code < 200 || serverResponse$status_code >= 300)
+                stop(paste("Server code:", serverResponse$status_code))
+
+            serverResponse
         }
     ),
 
diff --git a/sdk/R/R/CollectionTree.R b/sdk/R/R/CollectionTree.R
index cf8c6eb..82c6eb8 100644
--- a/sdk/R/R/CollectionTree.R
+++ b/sdk/R/R/CollectionTree.R
@@ -1,4 +1,5 @@
 source("./R/Subcollection.R")
+
 source("./R/ArvadosFile.R")
 
 #' Arvados Collection Object
@@ -36,6 +37,9 @@ CollectionTree <- R6::R6Class(
 
         getElement = function(relativePath)
         {
+            if(endsWith(relativePath, "/"))
+                relativePath <- substr(relativePath, 0, nchar(relativePath) - 1)
+
             splitPath <- unlist(strsplit(relativePath, "/", fixed = TRUE))
             returnElement = private$tree
 
@@ -62,7 +66,7 @@ CollectionTree <- R6::R6Class(
 
             for(elementIndex in lastElementIndex:1)
             {
-            if(elementIndex == lastElementIndex)
+                if(elementIndex == lastElementIndex)
                 {
                     branch = ArvadosFile$new(splitPath[[elementIndex]])
                 }
diff --git a/sdk/R/R/HttpRequest.R b/sdk/R/R/HttpRequest.R
index f5c11a1..7a399a4 100644
--- a/sdk/R/R/HttpRequest.R
+++ b/sdk/R/R/HttpRequest.R
@@ -54,6 +54,15 @@ HttpRequest <- R6::R6Class(
             curl::handle_setheaders(h, .list = headers)
 
             propfindResponse <- curl::curl_fetch_memory(url, h)
+        },
+
+        MOVE = function(url, headers = NULL)
+        {
+            h <- curl::new_handle()
+            curl::handle_setopt(h, customrequest = "MOVE")
+            curl::handle_setheaders(h, .list = headers)
+
+            propfindResponse <- curl::curl_fetch_memory(url, h)
         }
     ),
 
diff --git a/sdk/R/R/Subcollection.R b/sdk/R/R/Subcollection.R
index b453c53..78cc4c1 100644
--- a/sdk/R/R/Subcollection.R
+++ b/sdk/R/R/Subcollection.R
@@ -53,7 +53,7 @@ Subcollection <- R6::R6Class(
 
             #todo rename this add to a collection
             private$addToCollection(NULL)
-            private$detachFromParent()
+            private$dettachFromParent()
 
         },
 
@@ -111,6 +111,35 @@ Subcollection <- R6::R6Class(
             paste0(relativePath, collapse = "/")
         },
 
+        move = function(newLocation)
+        {
+            if(endsWith(newLocation, paste0(private$name, "/")))
+            {
+                newLocation <- substr(newLocation, 0, nchar(newLocation) - nchar(paste0(private$name, "/")))
+            }
+            else if(endsWith(newLocation, private$name))
+            {
+                newLocation <- substr(newLocation, 0, nchar(newLocation) - nchar(private$name))
+            }
+            else
+            {
+                stop("Destination path is not valid.")
+            }
+
+            newParent <- private$collection$get(newLocation)
+
+            if(is.null(newParent))
+            {
+                stop("Unable to get destination subcollectin")
+            }
+
+            status <- private$collection$.__enclos_env__$private$moveOnRest(self$getRelativePath(), paste0(newParent$getRelativePath(), "/", self$getName()))
+
+            private$attachToParent(newParent)
+
+            paste("Status code :", status$status_code)
+        },
+
         getParent = function() private$parent
     ),
 
@@ -166,13 +195,21 @@ Subcollection <- R6::R6Class(
             private$collection = collection
         },
 
-        detachFromParent = function()
+        dettachFromParent = function()
         {
             if(!is.null(private$parent))
             {
                 private$parent$.__enclos_env__$private$removeChild(private$name)
                 private$parent <- NULL
             }
+            else
+                stop("Parent doesn't exists.")
+        },
+
+        attachToParent = function(parent)
+        {
+            parent$.__enclos_env__$private$children <- c(parent$.__enclos_env__$private$children, self)
+            private$parent <- parent
         }
     ),
     
diff --git a/sdk/R/man/CTest.Rd b/sdk/R/man/CTest.Rd
deleted file mode 100644
index 6c14529..0000000
--- a/sdk/R/man/CTest.Rd
+++ /dev/null
@@ -1,17 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/Collection.R
-\docType{data}
-\name{CTest}
-\alias{CTest}
-\title{Arvados Collection Object}
-\format{An object of class \code{R6ClassGenerator} of length 24.}
-\usage{
-CTest
-}
-\description{
-Update description
-}
-\examples{
-arv = Collection$new(api, uuid)
-}
-\keyword{datasets}
diff --git a/sdk/R/man/Collection.Rd b/sdk/R/man/Collection.Rd
index 2f54bfe..46c76cb 100644
--- a/sdk/R/man/Collection.Rd
+++ b/sdk/R/man/Collection.Rd
@@ -1,5 +1,5 @@
 % Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/CTest.R
+% Please edit documentation in R/Collection.R
 \docType{data}
 \name{Collection}
 \alias{Collection}

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list