Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a function to load additional workspaces #16

Closed
davraam opened this issue Jun 17, 2022 · 2 comments
Closed

add a function to load additional workspaces #16

davraam opened this issue Jun 17, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@davraam
Copy link
Member

davraam commented Jun 17, 2022

Is it a useful to have a "datashield.workspace_restore" function to allow users to restore more than one workspaces (in addition to the restore of a single workspace through the datashield.login(.... restore='xxx') function) and therefore to allow them to combine objects from the different workspaces?

@ymarcon ymarcon added the enhancement New feature or request label Jun 17, 2022
@ymarcon
Copy link
Member

ymarcon commented Jun 17, 2022

Can be easily done, requires the following changes:

  • DSI : addition of dsRestoreWorkspace (generic API) and datashield.workspace_restore (user API)
  • DSOpal / DSLite / etc. : implementation of dsRestoreWorkspace
  • Opal : addition of the REST entry point PUT /datashield/session/{id}/workspace/{ws}

Note that the side effect of this operation will be that any previously existing symbol will be overridden by the restored ones having the same name.

ymarcon added a commit to datashield/DSLite that referenced this issue Jun 17, 2022
@ymarcon
Copy link
Member

ymarcon commented Jun 17, 2022

As a prototype, you can try this feature with DSLite

#install.packages("dsBase", repos = c("https://cloud.r-project.org", "https://cran.datashield.org"))

remotes::install_github("datashield/DSI", ref = "workspaces")
remotes::install_github("datashield/DSLite", ref = "workspaces")

library(DSLite)
library(dsBaseClient)

# prepare DSLite server
data("CNSIM1")
data("CNSIM2")
dslite.server <- newDSLiteServer(tables=list(CNSIM1=CNSIM1, CNSIM2=CNSIM2))

builder <- newDSLoginBuilder()
builder$append(server = "study1",  url = "dslite.server",
               table = "CNSIM1", driver = "DSLiteDriver")
logindata <- builder$build()
conns <- datashield.login(logins = logindata, assign = TRUE)
# save what was assigned at login
datashield.symbols(conns)
datashield.workspace_save(conns, "c1")
# assign a new table
datashield.assign.table(conns, "D2", list(study1 = "CNSIM2"))
datashield.symbols(conns)
# remove first data.frame and save workspace
datashield.rm(conns, "D")
datashield.symbols(conns)
datashield.workspace_save(conns, "c2")
# list saved workspaces
datashield.workspaces(conns)
datashield.logout(conns)

conns <- datashield.login(logins = logindata)
# verify no assignments
datashield.symbols(conns)
# verify available workspaces
datashield.workspaces(conns)
# restore c1
datashield.workspace_restore(conns, "c1")
datashield.symbols(conns)
# restore c2
datashield.workspace_restore(conns, "c2")
datashield.symbols(conns)
# verify data.frames are the ones expected
ds.summary("D")
ds.summary("D2")
# note that lsDS() is broken because it searches symbols in the .GlobalEnv instead of the parent.frame()
ds.ls()
datashield.logout(conns)

ymarcon added a commit to obiba/opal that referenced this issue Jun 17, 2022
@ymarcon ymarcon self-assigned this Oct 6, 2022
ymarcon added a commit to datashield/DSLite that referenced this issue Oct 6, 2022
ymarcon added a commit that referenced this issue Oct 6, 2022
* #16 dsRestoreWorkspace and datashield.workspace_restore added

* roxygen version
ymarcon added a commit to datashield/DSOpal that referenced this issue Oct 6, 2022
@ymarcon ymarcon closed this as completed Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants