R/loadTask.R

Defines functions loadTask

Documented in loadTask

#' Load a task.
#'
#' @inheritParams D4TAlink-common-args
#' @inheritParams readBinary
#' @return Object of class \code{\link{D4TAlinkTask}} or NULL if the \code{task} does not exists.
#' @export
loadTask <- function(project, package, taskname,
                     sponsor=getTaskSponsor(),
                     author=getTaskAuthor(),
                     quiet=FALSE) {
  tabk <- createTask(project,package,taskname,sponsor,author)
  ta <- readBinary(task=tabk,type="task",quiet=TRUE)
  if(is.null(ta)) {
    fn <- file.path(binaryDir(tabk),paste0(tabk$task,"_task.json"))
    if(file.exists(fn)) {
      v <- jsonlite::read_json(fn)
      ta <- tabk
      for(n in names(v)) ta[[n]] <- unlist(v[[n]])
    }
  }
  if(!quiet&&is.null(ta)) message("Task does not exist.")
  if(!is.null(ta)) ta$paths <- NULL # Back-compatibility 
  ta
}

Try the D4TAlink.light package in your browser

Any scripts or data that you put into this service are public.

D4TAlink.light documentation built on April 4, 2025, 1:02 a.m.