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

Automatically infer rscript_sh for remote OS #97

Open
HenrikBengtsson opened this issue Jan 22, 2023 · 0 comments
Open

Automatically infer rscript_sh for remote OS #97

HenrikBengtsson opened this issue Jan 22, 2023 · 0 comments
Labels
enhancement New feature or request MS_Windows

Comments

@HenrikBengtsson
Copy link
Collaborator

HenrikBengtsson commented Jan 22, 2023

Triggered by #96, could we automatically detect what rscript_sh should be for remote workers? Right now it is hard-coded to rscript_sh = "sh" for remote workers based on the assumption that most clusters run on Unix-like systems.

Idea

At least when homogeneous = FALSE, we could query the remote operating system using something like:

$ '/usr/bin/ssh' pi-2021.local Rscript --vanilla -e .Platform | grep -A 1 -F OS.type
$OS.type
[1] "unix"

So, in R, something like:

## Set rscript_sh = "cmd", if remote machine runs MS Windows
rscript_sh <- "sh"
tryCatch({
  res <- system2(ssh_cmd, args = c(hostname, "Rscript", "--vanilla", "-e", ".Platform"), stdout = TRUE, stderr = TRUE)
  idx <- grep("OS.type", res)
  if (length(idx) == 0) return()
  if (any(grepl("windows", res[idx+1]))) rscript_sh <- "cmd"
}, error = identity)

The downside is that this adds to the startup time of each parallel worker (in the order of seconds)

@HenrikBengtsson HenrikBengtsson added enhancement New feature or request MS_Windows labels Jan 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request MS_Windows
Projects
None yet
Development

No branches or pull requests

1 participant