To store the assigned data in the Armadillo service, you can use workspaces to make sure a certain state of the data is maintained on the service.
Saving the workspaces can be done during datashield.logout
or at runtime.
library(dsBaseClient)
library(DSMolgenisArmadillo)
# specify server url
armadillo_url <- "https://armadillo.dev.molgenis.org"
# get token from central authentication server
token <- armadillo.get_token(armadillo_url)
## [1] "We're opening a browser so you can log in with code QR4XJ9"
# build the login dataframe
builder <- DSI::newDSLoginBuilder()
builder$append(server = "armadillo",
url = armadillo_url,
token = token,
table = "gecko/2_1-core-1_0/nonrep",
driver = "ArmadilloDriver")
# create loginframe
logindata <- builder$build()
conns <- datashield.login(login = logindata)
##
## Logging into the collaborating servers
##
Logged in all servers [================================================================] 100% / 0s
datashield.assign.table(conns = conns,
table = "gecko/2_1-core-1_0/nonrep",
symbol = "J",
variables = c("recruit_age", "child_id"))
##
Assigned all table (J <- ...) [========================================================] 100% / 0s
datashield.logout(conns, save = "my-workspace")
conns <- datashield.login(logins = logindata,
assign = FALSE,
restore = "my-workspace")
##
## Logging into the collaborating servers
datashield.symbols(conns)
## $armadillo
## [1] "J"
datashield.workspace_save(conns, "my-workspace-version-2")
You can overwrite workspaces using the same name again when saving the workspace.
datashield.logout(conns)
##
Logged out from all servers [==========================================================] 100% / 1s
conns <- datashield.login(logins = logindata)
##
## Logging into the collaborating servers
datashield.assign.table(conns = conns,
table = "gecko/2_1-core-1_0/nonrep",
symbol = "H")
##
Assigned all table (H <- ...) [========================================================] 100% / 0s
datashield.workspace_save(conns, "my-workspace-overwritten")
datashield.workspace_save(conns, "my-workspace-overwritten")
You can list the workspaces as well.
datashield.workspaces(conns$armadillo)
## lastAccessDate ETag name size user
## 1 2020-09-08T10:14:42.345Z "79ea8e26a41a0f43716040c5f09466c0" armadillo:my-workspace-overwritten 172072
## 2 2020-09-08T10:14:40.907Z "7de51b96e6d15e9ab13b9ef52fe3547f" armadillo:my-workspace-version-2 3610
## 3 2020-09-08T10:14:40.524Z "7de51b96e6d15e9ab13b9ef52fe3547f" armadillo:my-workspace 3610
Remove workspaces.
datashield.workspace_rm(conns, "my-workspace-overwritten")
datashield.workspaces(conns)
## server name..armadillo.my.workspace.version.2. name..armadillo.my.workspace. user
## 1 armadillo armadillo:my-workspace-version-2 armadillo:my-workspace
## 2 armadillo armadillo:my-workspace-version-2 armadillo:my-workspace
## lastAccessDate..2020.09.08T10.14.40.907Z. lastAccessDate..2020.09.08T10.14.40.524Z. size.3610L size.3610L.1
## 1 2020-09-08T10:14:40.907Z 2020-09-08T10:14:40.524Z 3610 3610
## 2 2020-09-08T10:14:40.907Z 2020-09-08T10:14:40.524Z 3610 3610