3 This SDK focuses on providing support for accessing Arvados projects, collections, and the files within collections.
5 The API is not final and feedback is solicited from users on ways in which it could be improved.
9 1. Install the dependencies
11 > install.packages(c('R6', 'httr', 'stringr', 'jsonlite', 'curl', 'XML'))
13 If needed, you may have to install the supporting packages first. On Linux, these are:
15 libxml2-dev, libssl-dev, curl
17 2. Install the ArvardosR package
19 > install.packages('/path/to/ArvadosR_0.0.1.tar.gz', repos = NULL, type="source", dependencies = TRUE)
25 #Load Library and Initialize API:
28 arv <- Arvados$new() # uses environment variables ARVADOS_API_TOKEN and ARVADOS_API_HOST
29 arv <- Arvados$new("your Arvados token", "example.arvadosapi.com")
31 --------------------------------------------------------------------------------------------------------------------------------
35 arv$getCollection("uuid")
37 --------------------------------------------------------------------------------------------------------------------------------
40 collectionList <- arv$listCollections(list(list("name", "like", "Test%"))) # offset of 0 and default limit of 100
41 collectionList <- arv$listCollections(list(list("name", "like", "Test%")), limit = 10, offset = 2)
43 collectionList$items_available # count of total number of items (may be more than returned due to paging)
44 collectionList$items # items which match the filter criteria
46 --------------------------------------------------------------------------------------------------------------------------------
50 deletedCollection <- arv$deleteCollection("uuid")
52 --------------------------------------------------------------------------------------------------------------------------------
54 #Update a collection's metadata:
56 updatedCollection <- arv$updateCollection("uuid", list(name = "My new name", description = "a brand new description"))
58 --------------------------------------------------------------------------------------------------------------------------------
62 createdCollection <- arv$createCollection(list(name = "Example", description = "This is a test collection"))
65 --------------------------------------------------------------------------------------------------------------------------------
66 COLLECTION CONTENT MANIPULATION
67 --------------------------------------------------------------------------------------------------------------------------------
69 #Create collection object:
71 collection <- Collection$new(arv, "uuid")
73 --------------------------------------------------------------------------------------------------------------------------------
75 #Get file/folder content as character vector
77 collection$getFileContent()
79 --------------------------------------------------------------------------------------------------------------------------------
81 #This will return 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/")
89 --------------------------------------------------------------------------------------------------------------------------------
91 #Read whole file or just a portion of it.
93 fileContent <- arvadosFile$read()
94 fileContent <- arvadosFile$read("text")
95 fileContent <- arvadosFile$read("raw", offset = 1024, length = 512)
97 --------------------------------------------------------------------------------------------------------------------------------
99 #Get ArvadosFile or Subcollection size
101 size <- arvadosFile$getSizeInBytes()
102 size <- arvadosSubcollection$getSizeInBytes()
104 --------------------------------------------------------------------------------------------------------------------------------
106 #Create new file in a collection
108 collection$create(fileNames, optionalRelativePath)
112 mainFile <- collection$create("main.cpp", "cpp/src/")
113 fileList <- collection$create(c("main.cpp", lib.dll), "cpp/src/")
115 --------------------------------------------------------------------------------------------------------------------------------
117 #Add existing ArvadosFile or Subcollection to a collection
119 folder <- Subcollection$new("src")
120 file <- ArvadosFile$new("main.cpp")
123 collection$add(folder, "cpp")
125 #This examples will add file "main.cpp" in "./cpp/src/" folder if folder exists.
126 #If subcollection contains more files or folders they will be added recursively.
128 --------------------------------------------------------------------------------------------------------------------------------
130 #Write to existing file (Override current content of the file)
132 arvadosFile <- collection$get("location/to/my/file.cpp")
134 arvadosFile$write("This is new file content")
136 --------------------------------------------------------------------------------------------------------------------------------
138 #Delete file from a collection
140 file <- collection$get("location/to/my/file.cpp")
142 file$removeFromCollection()
146 collection$remove(file)
148 #Both examples will remove file "file.cpp" from a collection
149 #If subcollection contains more files or folders they will be removed recursively.
151 #You can also remove multiple files
153 collection$remove(c("path/to/my/file.cpp", "path/to/other/file.cpp"))
155 --------------------------------------------------------------------------------------------------------------------------------
157 #Move file or folder inside collection
159 file <- collection$get("location/to/my/file.cpp")
161 file$move("destination/file.cpp")
165 subcollection <- collection$get("location/to/folder")
167 subcollection$move("destination/folder")
169 #Make sure to include folder name in destination
171 #file$move("destination/") will not work
174 --------------------------------------------------------------------------------------------------------------------------------
175 WORKING WITH ARVADOS PROJECTS
176 --------------------------------------------------------------------------------------------------------------------------------
180 arv$getProject("uuid")
182 --------------------------------------------------------------------------------------------------------------------------------
186 projects <- arv$listProjects(list(list("owner_uuid", "=", "aaaaa-j7d0g-ccccccccccccccc"))) # list subprojects of a project
187 arv$listProjects(list(list("name","like","Example%"))) # list projects which have names beginning with Example
189 --------------------------------------------------------------------------------------------------------------------------------
193 deletedProject <- arv$deleteProject("uuid")
195 --------------------------------------------------------------------------------------------------------------------------------
199 updatedProject <- arv$updateProject("uuid", list(name = "new_name", description = "new description"))
201 --------------------------------------------------------------------------------------------------------------------------------
205 createdProject <- arv$createProject(list(name = "project_name", description = "project description"))
208 --------------------------------------------------------------------------------------------------------------------------------
209 BUILDING THE ARVADOS SDK TARBALL
210 --------------------------------------------------------------------------------------------------------------------------------
216 This will create a tarball of the Arvados package in the current directory.