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 1. Install the dependencies
10 `install.packages(c('R6', 'httr', 'stringr', 'jsonlite', 'curl', 'XML'))`
12 If needed, you may have to install the supporting packages first.
13 On Linux, these are: libxml2-dev, libssl-dev, libcurl4-gnutls-dev or libcurl4-openssl-dev
16 2. Install the ArvardosR package
18 `install.packages('/path/to/ArvadosR_0.0.2.tar.gz', repos = NULL, type="source", dependencies = TRUE)`
24 * Load Library and Initialize API:
27 `arv <- Arvados$new() # uses environment variables ARVADOS_API_TOKEN and ARVADOS_API_HOST`
28 `arv <- Arvados$new("your Arvados token", "example.arvadosapi.com")`
30 Optionally, add numRetries parameter to specify number of times to retry failed service requests.
33 `arv <- Arvados$new("your Arvados token", "example.arvadosapi.com", numRetries = 3)`
35 This parameter can be set at any time using setNumRetries
37 `arv$setNumRetries(5)`
40 #### WORKING WITH COLLECTIONS
44 `collection <- arv$getCollection("uuid")`
48 `collectionList <- arv$listCollections(list(list("name", "like", "Test%"))) # offset of 0 and default limit of 100`
49 `collectionList <- arv$listCollections(list(list("name", "like", "Test%")), limit = 10, offset = 2)`
51 `collectionList$items_available # count of total number of items (may be more than returned due to paging)`
52 `collectionList$items # items which match the filter criteria`
54 * List all collections even when the number of items is greater than maximum API limit:
56 `collectionList <- arv$listAllCollections(list(list("name", "like", "Test%")))`
58 * Delete a collection:
60 `deletedCollection <- arv$deleteCollection("uuid")`
62 * Update a collection's metadata:
64 `updatedCollection <- arv$updateCollection("uuid", list(name = "New name", description = "New description"))`
68 `createdCollection <- arv$createCollection(list(name = "Example", description = "This is a test collection"))`
71 #### MANIPULATIN COLLECTION CONTENT
73 * Create collection object:
75 `collection <- Collection$new(arv, "uuid")`
79 `files <- collection$getFileListing()`
81 * Get ArvadosFile or Subcollection from internal tree-like structure:
83 `arvadosFile <- collection$get("location/to/my/file.cpp")`
87 `arvadosSubcollection <- collection$get("location/to/my/directory/")`
91 `arvadosFile <- collection$get("myinput.txt")`
92 `arvConnection <- arvadosFile$connection("r")`
93 `mytable <- read.table(arvConnection)`
97 `arvadosFile <- collection$create("myoutput.txt")`
98 `arvConnection <- arvadosFile$connection("w")`
99 `write.table(mytable, arvConnection)`
100 `arvadosFile$flush()`
102 * Read whole file or just a portion of it:
104 `fileContent <- arvadosFile$read()`
105 `fileContent <- arvadosFile$read("text")`
106 `fileContent <- arvadosFile$read("raw", offset = 1024, length = 512)`
108 * Get ArvadosFile or Subcollection size:
110 `size <- arvadosFile$getSizeInBytes()`
114 `size <- arvadosSubcollection$getSizeInBytes()`
116 * Create new file in a collection:
118 `collection$create(fileNames, optionalRelativePath)`
122 `mainFile <- collection$create("main.cpp", "cpp/src/")`
123 `fileList <- collection$create(c("main.cpp", lib.dll), "cpp/src/")`
125 * Add existing ArvadosFile or Subcollection to a collection:
127 `folder <- Subcollection$new("src")`
128 `file <- ArvadosFile$new("main.cpp")`
131 `collection$add(folder, "cpp")`
133 This examples will add file "main.cpp" in "./cpp/src/" folder if folder exists.
134 If subcollection contains more files or folders they will be added recursively.
136 * Write to existing file (override current content of the file):
138 `arvadosFile <- collection$get("location/to/my/file.cpp")`
139 `arvadosFile$write("This is new file content")`
141 * Delete file from a collection:
143 `collection$remove("location/to/my/file.cpp")`
145 You can remove both Subcollection and ArvadosFile.
146 If subcollection contains more files or folders they will be removed recursively.
148 You can also remove multiple files at once:
150 `collection$remove(c("path/to/my/file.cpp", "path/to/other/file.cpp"))`
152 * Delete file or folder from a Subcollection:
154 `subcollection <- collection$get("mySubcollection/")`
155 `subcollection$remove("fileInsideSubcollection.exe")`
156 `subcollection$remove("folderInsideSubcollection/")`
158 * Move file or folder inside collection:
160 Directley from collection
162 `collection$move("folder/file.cpp", "file.cpp")`
166 `file <- collection$get("location/to/my/file.cpp")`
167 `file$move("newDestination/file.cpp")`
169 Or from subcollection
171 `subcollection <- collection$get("location/to/folder")`
172 `subcollection$move("newDestination/folder")`
174 Make sure to include new file name in destination.
175 In second example file$move("newDestination/") will not work.
177 #### WORKING WITH ARVADOS PROJECTS
181 `project <- arv$getProject("uuid")`
185 `projects <- arv$listProjects(list(list("owner_uuid", "=", "aaaaa-j7d0g-ccccccccccccccc"))) # list subprojects of a project`
186 `arv$listProjects(list(list("name","like","Example%"))) # list projects which have names beginning with Example`
188 * List all projects even when the number of items is greater than maximum API limit:
190 `collectionList <- arv$listAllProjects(list(list("name","like","Example%")))`
194 `deletedProject <- arv$deleteProject("uuid")`
198 `updatedProject <- arv$updateProject("uuid", list(name = "new_name", description = "new description"))`
202 `createdProject <- arv$createProject(list(name = "project_name", description = "project description"))`
204 ### BUILDING THE ARVADOS SDK TARBALL
209 This will create a tarball of the Arvados package in the current directory.