File: removeExperiments.R

package info (click to toggle)
r-cran-batchtools 0.9.15%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,416 kB
  • sloc: ansic: 172; sh: 156; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 1,075 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#' @title Remove Experiments
#'
#' @description
#' Remove Experiments from an \code{\link{ExperimentRegistry}}.
#' This function automatically checks if any of the jobs to reset is either pending or running.
#' However, if the implemented heuristic fails, this can lead to inconsistencies in the data base.
#' Use with care while jobs are running.
#'
#' @templateVar ids.default none
#' @template ids
#' @template expreg
#' @return [\code{\link{data.table}}] of removed job ids, invisibly.
#' @export
#' @family Experiment
removeExperiments = function(ids = NULL, reg = getDefaultRegistry()) {
  assertRegistry(reg, class = "ExperimentRegistry", writeable = TRUE, running.ok = FALSE)
  ids = convertIds(reg, ids, default = noIds())

  info("Removing %i Experiments ...", nrow(ids))
  reg$status = reg$status[!ids]
  i = reg$defs[!reg$status, on = "def.id", which = TRUE]
  if (length(i) > 0L) {
    info("Removing %i job definitions ...", length(i))
    reg$defs = reg$defs[-i]
  }
  fns = getResultFiles(reg, ids)
  file_remove(fns)

  sweepRegistry(reg)
  invisible(ids)
}