diff --git a/R/run_sas.R b/R/run_sas.R index 0e6dfe3..ad71155 100644 --- a/R/run_sas.R +++ b/R/run_sas.R @@ -37,7 +37,6 @@ run_sas <- function(sas_code, results = c("TEXT", "HTML"), sas_session = get_sas #' @return "saspy.sasdata.SASdata" object. #' @export df2sd <- function(df, table = "_df", libref = "", ..., sas_session = get_sas_session()) { - validate_ssh_with_tunnel(sas_session) df <- validate_data(df) sas_session$df2sd(df, table = table, libref = libref, ...) } @@ -55,6 +54,5 @@ df2sd <- function(df, table = "_df", libref = "", ..., sas_session = get_sas_ses #' @return `data.frame` object. #' @export sd2df <- function(table, libref = "", ..., sas_session = get_sas_session()) { - validate_ssh_with_tunnel(sas_session) sas_session$sd2df(table = table, libref = libref, ...) } diff --git a/R/sascfg.R b/R/sascfg.R index de34c56..0c2e9f2 100644 --- a/R/sascfg.R +++ b/R/sascfg.R @@ -17,7 +17,8 @@ #' @export #' @details #' `host` and `saspath` are required to connect to remote SAS server. Other arguments can follow default. -#' If transferring datasets is needed, then tunnelling is required. +#' If transferring datasets is needed and the client(running sasr) is not reachable from the server, +#' then tunnelling is required. #' Use `tunnel = `, `rtunnel = ` to specify tunnels and reverse tunnels. #' The values should be length 1 integer. sascfg <- function(name = "default", host, saspath, ssh = system("which ssh", intern = TRUE), diff --git a/R/utils.R b/R/utils.R index 776760c..1c961f4 100644 --- a/R/utils.R +++ b/R/utils.R @@ -22,27 +22,6 @@ install_saspy <- function(method = "auto", conda = "auto") { reticulate::py_install("saspy", method = method, conda = conda) } -#' Validate the SAS ssh Session Has Tunnels -#' -#' @description `r lifecycle::badge("experimental")` -#' Validate if the SAS session has tunnels enabled if it is ssh connection. -#' -#' @param session (`saspy.sasbase.SASsession`) SAS session. -#' @param msg (`character`)\cr message to display. -#' -#' @description SAS session must enable tunnels to transfer datasets. If not used, a error will pop up. -#' -#' @keywords internal -validate_ssh_with_tunnel <- function(session, msg = "SAS session through ssh must use tunnels to transfer datasets!") { - cfgname <- session$sascfg$name - is_ssh <- identical(session$sascfg$mode, "ssh") - assert_subset(cfgname, names(session$sascfg$SAScfg)) - cfg <- session$sascfg$SAScfg[[cfgname]] - if (is_ssh && (is.null(cfg$tunnel) || is.null(cfg$rtunnel))) { - stop(msg) - } -} - #' Validate and Process `data.frame` for SAS #' #' @description `r lifecycle::badge("experimental")` diff --git a/man/sascfg.Rd b/man/sascfg.Rd index 65fe8f6..6d7ca08 100644 --- a/man/sascfg.Rd +++ b/man/sascfg.Rd @@ -41,7 +41,8 @@ Create SAS session configuration file based on argument. } \details{ \code{host} and \code{saspath} are required to connect to remote SAS server. Other arguments can follow default. -If transferring datasets is needed, then tunnelling is required. +If transferring datasets is needed and the client(running sasr) is not reachable from the server, +then tunnelling is required. Use \verb{tunnel = }, \verb{rtunnel = } to specify tunnels and reverse tunnels. The values should be length 1 integer. } diff --git a/man/validate_ssh_with_tunnel.Rd b/man/validate_ssh_with_tunnel.Rd deleted file mode 100644 index 259711c..0000000 --- a/man/validate_ssh_with_tunnel.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{validate_ssh_with_tunnel} -\alias{validate_ssh_with_tunnel} -\title{Validate the SAS ssh Session Has Tunnels} -\usage{ -validate_ssh_with_tunnel( - session, - msg = "SAS session through ssh must use tunnels to transfer datasets!" -) -} -\arguments{ -\item{session}{(\code{saspy.sasbase.SASsession}) SAS session.} - -\item{msg}{(\code{character})\cr message to display.} -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -Validate if the SAS session has tunnels enabled if it is ssh connection. - -SAS session must enable tunnels to transfer datasets. If not used, a error will pop up. -} -\keyword{internal} diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index d38bb80..f1f5aca 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -27,21 +27,6 @@ test_that("validate_data drop row names and give warnings", { expect_identical(row.names(df2), "1") }) -# validate_ssh_with_tunnel ---- -test_that("validate_ssh_with_tunnel works as expected for a dummy session", { - session <- list(sascfg = list(name = "a", SAScfg = list(a = list(tunnel = 123L, rtunnel = 321L)))) - expect_silent(validate_ssh_with_tunnel(session)) -}) - -test_that("validate_ssh_with_tunnel fails when either tunnel or rtunnle is not there", { - session <- list(sascfg = list(name = "a", mode = "ssh", SAScfg = list(a = list(tunnel = 123L)))) - expect_error(validate_ssh_with_tunnel(session, "wrong"), "wrong") - session <- list(sascfg = list(name = "a", mode = "ssh", SAScfg = list(a = list(rtunnel = 123L)))) - expect_error(validate_ssh_with_tunnel(session, "wrong"), "wrong") - session <- list(sascfg = list(name = "a", mode = "http", SAScfg = list(a = list(rtunnel = 123L)))) - expect_silent(validate_ssh_with_tunnel(session, "wrong")) -}) - # validate_sascfg ---- test_that("validate_sascfg works if file exists", { diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index 6a2bf30..305009b 100644 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -36,7 +36,7 @@ To use `sasr`, you need to follow these steps 1. `host` is the hostname of the SAS server. 1. `saspath` is the SAS executable path on the SAS server. 1. Other arguments are added to the configuration file directly. - 1. `tunnel` and `rtunnel` are required if you want to transfer datasets between R and SAS. Use integers like `tunnel = 9999L` in R, or modify `sascfg_personal.py` to make sure they are integers. + 1. `tunnel` and `rtunnel` are required if you want to transfer datasets between R and SAS if the client (running sasr) is not reachable from the server. Use integers like `tunnel = 9999L` in R, or modify `sascfg_personal.py` to make sure they are integers. 1. You can create the configuration by yourself and then SAS connection will not be restricted to ssh. 1. You can have multiple configuration files with different file names 1. Create the SAS session based on the configuration file