Skip to content

Commit

Permalink
removing tunneling check
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkliming committed Sep 21, 2023
1 parent 89106ba commit 68f06b8
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 64 deletions.
2 changes: 0 additions & 2 deletions R/run_sas.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)
}
Expand All @@ -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, ...)
}
3 changes: 2 additions & 1 deletion R/sascfg.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
21 changes: 0 additions & 21 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")`
Expand Down
3 changes: 2 additions & 1 deletion man/sascfg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions man/validate_ssh_with_tunnel.Rd

This file was deleted.

15 changes: 0 additions & 15 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
2 changes: 1 addition & 1 deletion vignettes/introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 68f06b8

Please sign in to comment.