--- title: "Using workspaces" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Using workspaces} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- 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. Please be aware that if your workspace is too big to store on the server, it won't save and you'll get an error message. If this happens, please try cleaning up the workspace as much as possible and try again. If it still doesn't work, please contact the administrator of the server, to ask if the diskspace can be increased. ```r library(dsBaseClient) library(DSMolgenisArmadillo) # specify server url armadillo_url <- "https://armadillo-demo.molgenis.net/" # 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 6SFLND" ``` ```r # 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 <- DSI::datashield.login(login = logindata) ``` ``` ## ## Logging into the collaborating servers ``` ``` ## [-------------------------------------------------------------------------------------] 0% / 0s Login armadillo [==================================>-----------------------------------] 50% / 0s Logged in all servers [================================================================] 100% / 4s ``` ```r datashield.assign.table(conns = conns, table = "gecko/2_1-core-1_0/nonrep", symbol = "J", variables = c("recruit_age", "child_id")) ``` ``` ## [-------------------------------------------------------------------------------------] 0% / 0s Checking armadillo (J <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (J <- ...) [---------------------------------------------------------------] 0% / 0s Checking armadillo (J <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (J <- ...) [---------------------------------------------------------------] 0% / 0s Checking armadillo (J <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (J <- ...) [---------------------------------------------------------------] 0% / 0s Checking armadillo (J <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (J <- ...) [---------------------------------------------------------------] 0% / 0s Checking armadillo (J <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (J <- ...) [---------------------------------------------------------------] 0% / 0s Checking armadillo (J <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (J <- ...) [---------------------------------------------------------------] 0% / 0s Checking armadillo (J <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (J <- ...) [---------------------------------------------------------------] 0% / 1s Checking armadillo (J <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 1s Waiting... (J <- ...) [---------------------------------------------------------------] 0% / 1s Checking armadillo (J <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 1s Waiting... (J <- ...) [---------------------------------------------------------------] 0% / 1s Checking armadillo (J <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 1s Waiting... (J <- ...) [---------------------------------------------------------------] 0% / 1s Checking armadillo (J <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 1s Finalizing assignment armadillo (J <- `gecko/2_1-core-1_0/nonrep`) [=========>---------] 50% / 1s Assigned all table (J <- ...) [========================================================] 100% / 1s ``` ```r datashield.logout(conns, save = "my-workspace") ``` ``` ## [-------------------------------------------------------------------------------------] 0% / 0s Logout armadillo [=================================>-----------------------------------] 50% / 0s Logged out from all servers [==========================================================] 100% / 0s ``` ```r conns <- DSI::datashield.login(logins = logindata, assign = FALSE, restore = "my-workspace") ``` ``` ## ## Logging into the collaborating servers ## [-------------------------------------------------------------------------------------] 0% / 0s Login armadillo [==================================>-----------------------------------] 50% / 0s Logged in all servers [================================================================] 100% / 5s ``` ```r datashield.symbols(conns) ``` ``` ## $armadillo ## [1] "J" ``` ```r datashield.workspace_save(conns, "my-workspace-version-2") ``` You can overwrite workspaces using the same name again when saving the workspace. ```r datashield.logout(conns) ``` ``` ## [-------------------------------------------------------------------------------------] 0% / 0s Logout armadillo [=================================>-----------------------------------] 50% / 0s Logged out from all servers [==========================================================] 100% / 0s ``` ```r conns <- DSI::datashield.login(logins = logindata) ``` ``` ## ## Logging into the collaborating servers ## [-------------------------------------------------------------------------------------] 0% / 0s Login armadillo [==================================>-----------------------------------] 50% / 0s Logged in all servers [================================================================] 100% / 4s ``` ```r datashield.assign.table(conns = conns, table = "gecko/2_1-core-1_0/nonrep", symbol = "H") ``` ``` ## [-------------------------------------------------------------------------------------] 0% / 0s Checking armadillo (H <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (H <- ...) [---------------------------------------------------------------] 0% / 0s Checking armadillo (H <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (H <- ...) [---------------------------------------------------------------] 0% / 0s Checking armadillo (H <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (H <- ...) [---------------------------------------------------------------] 0% / 0s Checking armadillo (H <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (H <- ...) [---------------------------------------------------------------] 0% / 0s Checking armadillo (H <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (H <- ...) [---------------------------------------------------------------] 0% / 0s Checking armadillo (H <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 0s Waiting... (H <- ...) [---------------------------------------------------------------] 0% / 0s Checking armadillo (H <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 1s Waiting... (H <- ...) [---------------------------------------------------------------] 0% / 1s Checking armadillo (H <- `gecko/2_1-core-1_0/nonrep`) [--------------------------------] 0% / 1s Finalizing assignment armadillo (H <- `gecko/2_1-core-1_0/nonrep`) [=========>---------] 50% / 1s Assigned all table (H <- ...) [========================================================] 100% / 1s ``` ```r datashield.workspace_save(conns, "my-workspace-overwritten") datashield.workspace_save(conns, "my-workspace-overwritten") ``` You can list the workspaces as well. ```r datashield.workspaces(conns$armadillo) ``` ``` ## name size lastAccessDate user ## 1 armadillo:my-workspace-overwritten 172672 2024-05-17T10:07:25.624+02:00 ## 2 armadillo:my-workspace 3947 2024-05-17T10:07:14.872+02:00 ## 3 armadillo:my-workspace-version-2 3883 2024-05-17T10:07:20.072+02:00 ``` Remove workspaces. ```r datashield.workspace_rm(conns, "my-workspace-overwritten") datashield.workspaces(conns) ``` ``` ## server name..armadillo.my.workspace. name..armadillo.my.workspace.version.2. user lastAccessDate..2024.05.17T10.07.14.872.02.00. ## 1 armadillo armadillo:my-workspace armadillo:my-workspace-version-2 2024-05-17T10:07:14.872+02:00 ## 2 armadillo armadillo:my-workspace armadillo:my-workspace-version-2 2024-05-17T10:07:14.872+02:00 ## lastAccessDate..2024.05.17T10.07.20.072.02.00. size.3947L size.3883L ## 1 2024-05-17T10:07:20.072+02:00 3947 3883 ## 2 2024-05-17T10:07:20.072+02:00 3947 3883 ```