R/prepare_scan_run.R
ensure_shared_output_dir.RdThe integration point for born-shared outputs: a portable, guarded hook that
turns a run's
output_dir into a symlink into lab-shared storage before the run
populates it, so the bytes live off /home and the leaf is registered for
clone reconstruction. prepare_scan_run() calls it for SNV-set runs; the
GLOWanalyses upstream templates call it directly when a run opts in (config
field symlinked_shared_root non-NULL). This function does not read
config — the caller decides whether to call it and passes the resolved
share_root.
ensure_shared_output_dir(output_dir, share_root = NULL, verbose = 0)Logical, invisibly: TRUE iff a shared-backed symlink was created.
If output_dir does not yet exist and lies inside a git repository that ships
tools/shared-storage/scaffold_shared_output.sh, it invokes that helper to
create output_dir as a symlink into shared storage and register it in the
manifest. With share_root = NULL the shared location is the helper's default
(tools/shared-storage/shared-root.conf, overridable by GLOW_SHARE_ROOT);
with an explicit share_root the symlink points into
<share_root>/<repo-relative-leaf> and that exact target is recorded in the
manifest (so a clone reconstructs it regardless of any default).
It is a deliberate no-op (returning FALSE, after which the caller's own
dir.create makes a plain local dir) when: the dir already exists (real or
symlink); the parent does not exist yet; the path is not inside a git repo (e.g. a
tempfile() under /tmp, so unit tests are unaffected); the path is outside
the enclosing repo; the leaf is empty (the repo root); the helper is absent; or the
helper fails (e.g. the shared volume is unavailable). No shared path is hardcoded here,
so the package stays portable.
if (FALSE) { # \dontrun{
# Opt-in born-sharing from a workflow template: symlink this run's outputs/ into a
# shared root before creating it (no-op outside a repo that ships the tooling).
ensure_shared_output_dir("runs/myrun/outputs", share_root = "/project/lab/shared")
} # }