Skip to content

Conversation

@ymarcon
Copy link
Member

@ymarcon ymarcon commented Oct 15, 2025

Implementation of #23

@ymarcon ymarcon requested a review from Copilot October 15, 2025 07:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements remote R session management functionality for DataSHIELD, adding the ability to create, check, and monitor remote R sessions asynchronously. It introduces a new DSSession class and associated methods for session state management.

  • Adds DSSession class and related generics (dsIsReady, dsStateMessage, dsHasSession, dsSession)
  • Implements datashield.sessions() function for managing multiple connections with async support and progress tracking
  • Integrates session management into existing DataSHIELD workflows (login, assign, aggregate operations)

Reviewed Changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
R/DSSession.R New file defining DSSession class and core session management generics
R/DSConnection.R Extended with session-related methods and improved documentation
R/datashield.sessions.R New session management function with async support and callback handling
R/datashield.login.R Simplified login logic and integrated workspace restoration
R/datashield.assign.R Added session initialization calls to assignment functions
R/datashield.aggregate.R Added session initialization call to aggregate function
R/datashield.workspace.R Added session initialization to workspace operations
R/datashield.symbol.R Added session initialization to symbol listing
man/*.Rd Generated documentation files for new functions and updated cross-references
NAMESPACE Exported new session-related functions and classes
DESCRIPTION Updated collate order to include new session files
Comments suppressed due to low confidence (1)

R/datashield.assign.R:272

  • The datashield.assign.resource function is missing a datashield.sessions(conns) call at the beginning, which is inconsistent with other assignment functions like datashield.assign.table and datashield.assign.expr.
datashield.assign.resource <- function(conns, symbol, resource, async=TRUE, success=NULL, error=NULL, errors.print = getOption("datashield.errors.print", FALSE)) {

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ymarcon ymarcon requested a review from timcadman October 15, 2025 07:56
Copy link
Collaborator

@timcadman timcadman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good Yannick. Only suggestion is to consider refactoring datashield.session to reduce repetition and make it a bit more readable. I know this is in the same style as other DSI functions, so I leave this as an optional suggestion for you

#' }
#'
#' @export
datashield.sessions <- function(conns, async=TRUE, success=NULL, error=NULL, errors.print = getOption("datashield.errors.print", FALSE)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be refactored? These nested ifs within the for loop are quite hard to read and difficult to debug if something goes wrong.

tryCatch({
sessions[[n]] <- dsSession(fconns[[n]], async=async)
}, error = function(e) {
.appendError(n, conditionMessage(e))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is repeated - could you break into a separate helper function which is then called in the error part of the trycatch?

@ymarcon ymarcon merged commit 61c027b into master Oct 30, 2025
3 checks passed
@ymarcon ymarcon deleted the feat/session branch October 30, 2025 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants