R/exec_py.R

Defines functions run_script

#' @export
run_script <- function(x, work_dir = NULL, local = FALSE, convert = FALSE){

  if(length(work_dir) == 1 && dir.exists(work_dir)){
    `_cwd` <- getwd()
    on.exit({setwd(`_cwd`)}, add = TRUE, after = TRUE)
    work_dir <- normalizePath(work_dir)
    setwd(work_dir)
  }

  x <- normalizePath(x, mustWork = TRUE)
  ravepy::ensure_ravepy()
  reticulate::py_run_file(file = x, local = local, convert = convert)
}
dipterix/ravepy documentation built on Aug. 6, 2021, 1:14 p.m.