futureverse / futureverse/parallelly

Automatically infer `rscript_sh` for remote OS

Open
#97 0 comments 0 reactions 0 assignees View on GitHub
enhancement MS_Windows
Dominant language
R
Stars
140
Forks
9
PR merge metrics
No merged PRs in 30d

Description

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:

```sh
$ '/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:

```r
## 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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.