3 This SDK focuses on providing support for accessing Arvados projects, collections, and the files within collections.
4 The API is not final and feedback is solicited from users on ways in which it could be improved.
8 ```install.packages("ArvadosR", repos=c("http://r.arvados.org", getOption("repos")["CRAN"]), dependencies=TRUE)```
10 Note: on Linux, you may have to install supporting packages.
14 ```yum install libxml2-devel openssl-devel curl-devel```
18 ```apt-get install build-essential libxml2-dev libssl-dev libcurl4-gnutls-dev```
26 knitr::opts_chunk$set(eval = FALSE)
29 * Load Library and Initialize API:
33 # use environment variables ARVADOS_API_TOKEN and ARVADOS_API_HOST
36 # provide them explicitly
37 arv <- Arvados$new("your Arvados token", "example.arvadosapi.com")
40 Optionally, add numRetries parameter to specify number of times to retry failed service requests.
44 arv <- Arvados$new("your Arvados token", "example.arvadosapi.com", numRetries = 3)
47 This parameter can be set at any time using setNumRetries
54 #### Working with collections
59 collection <- arv$getCollection("uuid")
65 # offset of 0 and default limit of 100
66 collectionList <- arv$listCollections(list(list("name", "like", "Test%")))
68 collectionList <- arv$listCollections(list(list("name", "like", "Test%")), limit = 10, offset = 2)
72 # count of total number of items (may be more than returned due to paging)
73 collectionList$items_available
75 # items which match the filter criteria
79 * List all collections even if the number of items is greater than maximum API limit:
82 collectionList <- arv$listAllCollections(list(list("name", "like", "Test%")))
85 * Delete a collection:
88 deletedCollection <- arv$deleteCollection("uuid")
91 * Update a collection's metadata:
94 updatedCollection <- arv$updateCollection("uuid", list(name = "New name", description = "New description"))
100 createdCollection <- arv$createCollection(list(name = "Example", description = "This is a test collection"))
104 #### Manipulating collection content
106 * Create collection object:
109 collection <- Collection$new(arv, "uuid")
115 files <- collection$getFileListing()
118 * Get ArvadosFile or Subcollection from internal tree-like structure:
121 arvadosFile <- collection$get("location/to/my/file.cpp")
127 arvadosSubcollection <- collection$get("location/to/my/directory/")
133 arvadosFile <- collection$get("myinput.txt")
134 arvConnection <- arvadosFile$connection("r")
135 mytable <- read.table(arvConnection)
141 arvadosFile <- collection$create("myoutput.txt")
142 arvConnection <- arvadosFile$connection("w")
143 write.table(mytable, arvConnection)
147 * Write to existing file (override current content of the file):
150 arvadosFile <- collection$get("location/to/my/file.cpp")
151 arvadosFile$write("This is new file content")
154 * Read whole file or just a portion of it:
157 fileContent <- arvadosFile$read()
158 fileContent <- arvadosFile$read("text")
159 fileContent <- arvadosFile$read("raw", offset = 1024, length = 512)
162 * Get ArvadosFile or Subcollection size:
165 size <- arvadosFile$getSizeInBytes()
171 size <- arvadosSubcollection$getSizeInBytes()
174 * Create new file in a collection:
177 collection$create(fileNames, optionalRelativePath)
183 mainFile <- collection$create("main.cpp", "cpp/src/")
184 fileList <- collection$create(c("main.cpp", lib.dll), "cpp/src/")
187 * Add existing ArvadosFile or Subcollection to a collection:
190 folder <- Subcollection$new("src")
191 file <- ArvadosFile$new("main.cpp")
196 collection$add(folder, "cpp")
199 This examples will add file "main.cpp" in "./cpp/src/" folder if folder exists.
200 If subcollection contains more files or folders they will be added recursively.
202 * Delete file from a collection:
205 collection$remove("location/to/my/file.cpp")
208 You can remove both Subcollection and ArvadosFile.
209 If subcollection contains more files or folders they will be removed recursively.
211 You can also remove multiple files at once:
214 collection$remove(c("path/to/my/file.cpp", "path/to/other/file.cpp"))
217 * Delete file or folder from a Subcollection:
220 subcollection <- collection$get("mySubcollection/")
221 subcollection$remove("fileInsideSubcollection.exe")
222 subcollection$remove("folderInsideSubcollection/")
225 * Move file or folder inside collection:
227 Directley from collection
230 collection$move("folder/file.cpp", "file.cpp")
236 file <- collection$get("location/to/my/file.cpp")
237 file$move("newDestination/file.cpp")
240 Or from subcollection
243 subcollection <- collection$get("location/to/folder")
244 subcollection$move("newDestination/folder")
247 Make sure to include new file name in destination.
248 In second example file$move("newDestination/") will not work.
250 #### Working with Aravdos projects
255 project <- arv$getProject("uuid")
261 # list subprojects of a project
262 projects <- arv$listProjects(list(list("owner_uuid", "=", "aaaaa-j7d0g-ccccccccccccccc")))
264 # list projects which have names beginning with Example
265 arv$listProjects(list(list("name","like","Example%")))
268 * List all projects even if the number of items is greater than maximum API limit:
271 collectionList <- arv$listAllProjects(list(list("name","like","Example%")))
277 deletedProject <- arv$deleteProject("uuid")
283 updatedProject <- arv$updateProject("uuid", list(name = "new_name", description = "new description"))
289 createdProject <- arv$createProject(list(name = "project_name", description = "project description"))
292 ### Building the ArvadosR package
295 cd arvados/sdk && R CMD build R
298 This will create a tarball of the ArvadosR package in the current directory.