Skip to contents

The Docker-backed twin of repro_run_scripts_py(): same return contract, same per-script semantics (skip on missing inputs / parse failure, timeout, error classification), but each script runs via docker run --network none --read-only --user <non-root> instead of a processx subprocess on the host — so the code cannot reach the network (unless net is given) or touch anything outside the mounted sandbox and library, even deliberately.

Usage

repro_run_scripts_py_docker(
  run_tbl,
  order,
  sandbox_root,
  lib_dir = NULL,
  image = getOption("metacheck.docker_image_py", .repro_docker_default_image_py),
  timeout = 600,
  skip = character(0),
  parses = NULL,
  failed_deps = character(0),
  deadline = NULL,
  net = NULL
)

Arguments

run_tbl

repro_write_scripts() output (file_name, script_path, run_dir) — run_dir must be the SAME directory as (or a subdirectory of) sandbox_root

order

a vector of file_names in the order to run

sandbox_root

the materialised layout root on the HOST — mounted read-write at /sandbox

lib_dir

throwaway pip install --target library ON THE HOST (or NULL) — mounted at /pylib when supplied, writable, so a package can keep data in its own folder

image

the Docker image to run scripts in (see .repro_docker_default_image_py)

timeout

per-script timeout in seconds

skip

character vector of file_names to record as skipped_missing_inputs instead of running

parses

named logical (by file_name); a file that will not parse is recorded not_parsed and not run

failed_deps

character vector of package names repro_install_deps_py_docker() could not install

deadline

the time (Sys.time() plus the time for all scripts together) after which no script is started, recorded as skipped_time_limit; a running script is stopped then. NULL (the default) sets no such limit.

net

NULL (the default) runs with the network off; see repro_run_scripts_docker().

Value

a data frame — identical columns to repro_run_scripts_py()'s return: file_name, outcome, error, error_type, undefined_var, stdout, stderr, elapsed, script_lines, captures (always NULL)

Examples

if (FALSE) { # \dontrun{
# needs Docker
root <- file.path(tempdir(), "run_demo_py")
plan <- data.frame(file_name = "analysis.py", target_path = "analysis/analysis.py")
code <- list(analysis.py = "print(sum([1, 2, 3]))")
run_tbl <- repro_write_scripts(code, list(), plan, root, lang = "Python")
repro_run_scripts_py_docker(run_tbl, order = "analysis.py", sandbox_root = root)
} # }