1 [comment]: # (Copyright © The Arvados Authors. All rights reserved.)
3 [comment]: # (SPDX-License-Identifier: CC-BY-SA-3.0)
7 This SDK focuses on providing support for accessing Arvados projects, collections, and the files within collections. The API is not final and feedback is solicited from users on ways in which it could be improved.
13 * Working with collections
14 * Manipulating collection content
15 * Working with Arvados projects
17 * Building the ArvadosR package
21 Minimum R version required to run ArvadosR is 3.3.0.
24 install.packages("ArvadosR", repos=c("https://r.arvados.org", getOption("repos")["CRAN"]), dependencies=TRUE)
29 > On Linux, you may have to install supporting packages.
31 > On Centos 7, this is:
33 > yum install libxml2-devel openssl-devel curl-devel
38 > apt-get install build-essential libxml2-dev libssl-dev libcurl4-gnutls-dev
47 # use environment variables ARVADOS_API_TOKEN and ARVADOS_API_HOST
50 # provide them explicitly
51 arv <- Arvados$new("your Arvados token", "example.arvadosapi.com")
54 Optionally, add `numRetries` parameter to specify number of times to retry failed service requests. Default is 0.
57 arv <- Arvados$new("your Arvados token", "example.arvadosapi.com", numRetries = 3)
60 This parameter can be set at any time using `setNumRetries`
66 ### Working with collections
68 #### Get a collection:
71 collection <- arv$collections_get("uuid")
74 Be aware that the result from `collections_get` is not a Collection class. The object returned from this method lets you access collection fields like “name” and “description”. The Collection class lets you access the files in the collection for reading and writing, and is described in the next section.
76 #### List collections:
79 # offset of 0 and default limit of 100
80 collectionList <- arv$collections_list(list(list("name", "like", "Test%")))
82 collectionList <- arv$collections_list(list(list("name", "like", "Test%")), limit = 10, offset = 2)
84 # count of total number of items (may be more than returned due to paging)
85 collectionList$items_available
87 # items which match the filter criteria
91 #### List all collections even if the number of items is greater than maximum API limit:
94 collectionList <- listAll(arv$collections_list, list(list("name", "like", "Test%")))
97 #### Delete a collection:
100 deletedCollection <- arv$collections_delete("uuid")
103 #### Update a collection’s metadata:
106 collection <- arv$collections_update(name = "newCollectionTitle", description = "newCollectionDescription", ownerUUID = "collectionOwner", properties = NULL, uuid = "collectionUUID")
109 #### Create a new collection:
112 newCollection <- arv$collections_create(name = "collectionTitle", description = "collectionDescription", ownerUUID = "collectionOwner", properties = Properties)
115 ### Manipulating collection content
117 #### Initialize a collection object:
120 collection <- Collection$new(arv, "uuid")
123 #### Get list of files:
126 files <- collection$getFileListing()
129 #### Get ArvadosFile or Subcollection from internal tree-like structure:
132 arvadosFile <- collection$get("location/to/my/file.cpp")
134 arvadosSubcollection <- collection$get("location/to/my/directory/")
140 arvadosFile <- collection$get("myinput.txt")
141 arvConnection <- arvadosFile$connection("r")
142 mytable <- read.table(arvConnection)
148 arvadosFile <- collection$create("myoutput.txt")[[1]]
149 arvConnection <- arvadosFile$connection("w")
150 write.table(mytable, arvConnection)
154 #### Read a table from a tab delimited file:
157 arvadosFile <- collection$get("myinput.txt")
158 arvConnection <- arvadosFile$connection("r")
159 mytable <- read.delim(arvConnection)
162 #### Read a gzip compressed R object:
165 obj <- readRDS(gzcon(coll$get("abc.RDS")$connection("rb")))
168 #### Write to existing file (overwrites current content of the file):
171 arvadosFile <- collection$get("location/to/my/file.cpp")
172 arvadosFile$write("This is new file content")
175 #### Read whole file or just a portion of it:
178 fileContent <- arvadosFile$read()
179 fileContent <- arvadosFile$read("text")
180 fileContent <- arvadosFile$read("raw", offset = 1024, length = 512)
184 #### Get ArvadosFile or Subcollection size:
187 size <- arvadosFile$getSizeInBytes()
189 size <- arvadosSubcollection$getSizeInBytes()
192 #### Create new file in a collection (returns a vector of one or more ArvadosFile objects):
195 collection$create(files)
201 mainFile <- collection$create("cpp/src/main.cpp")[[1]]
202 fileList <- collection$create(c("cpp/src/main.cpp", "cpp/src/util.h"))
205 #### Delete file from a collection:
208 collection$remove("location/to/my/file.cpp")
211 You can remove both Subcollection and ArvadosFile. If subcollection contains more files or folders they will be removed recursively.
214 > You can also remove multiple files at once:
216 > collection$remove(c("path/to/my/file.cpp", "path/to/other/file.cpp"))
219 #### Delete file or folder from a Subcollection:
222 subcollection <- collection$get("mySubcollection/")
223 subcollection$remove("fileInsideSubcollection.exe")
224 subcollection$remove("folderInsideSubcollection/")
227 #### Move or rename a file or folder within a collection (moving between collections is currently not supported):
229 ##### Directly from collection
232 collection$move("folder/file.cpp", "file.cpp")
238 file <- collection$get("location/to/my/file.cpp")
239 file$move("newDestination/file.cpp")
242 ##### Or from subcollection
245 subcollection <- collection$get("location/to/folder")
246 subcollection$move("newDestination/folder")
250 > Make sure to include new file name in destination. In second example `file$move(“newDestination/”)` will not work.
252 #### Copy file or folder within a collection (copying between collections is currently not supported):
254 ##### Directly from collection
257 collection$copy("folder/file.cpp", "file.cpp")
263 file <- collection$get("location/to/my/file.cpp")
264 file$copy("destination/file.cpp")
267 ##### Or from subcollection
270 subcollection <- collection$get("location/to/folder")
271 subcollection$copy("destination/folder")
274 ### Working with Aravdos projects
279 project <- arv$project_get("uuid")
285 list subprojects of a project
286 projects <- arv$project_list(list(list("owner_uuid", "=", "aaaaa-j7d0g-ccccccccccccccc")))
288 list projects which have names beginning with Example
289 examples <- arv$project_list(list(list("name","like","Example%")))
292 #### List all projects even if the number of items is greater than maximum API limit:
295 projects <- listAll(arv$project_list, list(list("name","like","Example%")))
298 ##### Delete a project:
301 deletedProject <- arv$project_delete("uuid")
304 ##### Update project:
307 updatedProject <- arv$project_update(name = "new project name", properties = newProperties, uuid = "projectUUID")
310 ##### Create project:
313 newProject <- arv$project_create(name = "project name", description = "project description", owner_uuid = "project UUID", properties = NULL, ensureUniqueName = "false")
318 #### View help page of Arvados classes by puting `?` before class name:
327 #### View help page of any method defined in Arvados class by puting `?` before method name:
334 <!-- Taka konwencja USAGE -->
336 ## Building the ArvadosR package
339 cd arvados/sdk && R CMD build R
342 This will create a tarball of the ArvadosR package in the current directory.
344 <!-- Czy dodawać Documentation / Community / Development and Contributing / Licensing? Ale tylko do części Rowej? Wszystko? Wcale? -->
348 Complete documentation, including the [User Guide](https://doc.arvados.org/user/index.html), [Installation documentation](https://doc.arvados.org/install/index.html), [Administrator documentation](https://doc.arvados.org/admin/index.html) and
349 [API documentation](https://doc.arvados.org/api/index.html) is available at http://doc.arvados.org/
351 If you wish to build the Arvados documentation from a local git clone, see
352 [doc/README.textile](doc/README.textile) for instructions.
356 [![Join the chat at https://gitter.im/arvados/community](https://badges.gitter.im/arvados/community.svg)](https://gitter.im/arvados/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
358 The [Arvados community channel](https://gitter.im/arvados/community)
359 channel at [gitter.im](https://gitter.im) is available for live
360 discussion and support.
362 The [Arvados developement channel](https://gitter.im/arvados/development)
363 channel at [gitter.im](https://gitter.im) is used to coordinate development.
365 The [Arvados user mailing list](http://lists.arvados.org/mailman/listinfo/arvados)
366 is used to announce new versions and other news.
368 All participants are expected to abide by the [Arvados Code of Conduct](CODE_OF_CONDUCT.md).
372 [Report a bug](https://dev.arvados.org/projects/arvados/issues/new) on [dev.arvados.org](https://dev.arvados.org).
374 ## Development and Contributing
376 See [CONTRIBUTING](CONTRIBUTING.md) for information about Arvados development and how to contribute to the Arvados project.
378 The [development road map](https://dev.arvados.org/issues/gantt?utf8=%E2%9C%93&set_filter=1&gantt=1&f%5B%5D=project_id&op%5Bproject_id%5D=%3D&v%5Bproject_id%5D%5B%5D=49&f%5B%5D=&zoom=1) outlines some of the project priorities over the next twelve months.
382 Arvados is Free Software. See [COPYING](COPYING) for information about the open source licenses used in Arvados.