Learn R Programming

targets (version 0.7.0)

tar_watch: Shiny app to watch the dependency graph.

Description

Launches a background process with a Shiny app that calls tar_visnetwork() every few seconds. To embed this app in other apps, use the Shiny module in tar_watch_ui() and tar_watch_server().

Usage

tar_watch(
  seconds = 10,
  seconds_min = 1,
  seconds_max = 60,
  seconds_step = 1,
  targets_only = FALSE,
  exclude = ".Random.seed",
  outdated = FALSE,
  label = NULL,
  level_separation = 150,
  degree_from = 1L,
  degree_to = 1L,
  config = "_targets.yaml",
  height = "650px",
  display = "summary",
  displays = c("summary", "branches", "progress", "graph", "about"),
  background = TRUE,
  browse = TRUE,
  host = getOption("shiny.host", "127.0.0.1"),
  port = getOption("shiny.port", targets::tar_random_port()),
  verbose = TRUE,
  supervise = TRUE,
  poll_connection = TRUE,
  stdout = "|",
  stderr = "|"
)

Arguments

seconds

Numeric of length 1, default number of seconds between refreshes of the graph. Can be changed in the app controls.

seconds_min

Numeric of length 1, lower bound of seconds in the app controls.

seconds_max

Numeric of length 1, upper bound of seconds in the app controls.

seconds_step

Numeric of length 1, step size of seconds in the app controls.

targets_only

Logical, whether to restrict the output to just targets (FALSE) or to also include global functions and objects.

exclude

Character vector of nodes to omit from the graph.

outdated

Logical, whether to show colors to distinguish outdated targets from up-to-date targets. (Global functions and objects still show these colors.) Looking for outdated targets takes a lot of time for large pipelines with lots of branches, and setting outdated to FALSE is a nice way to speed up the graph if you only want to see dependency relationships and build progress.

label

Label argument to tar_visnetwork().

level_separation

Numeric of length 1, levelSeparation argument of visNetwork::visHierarchicalLayout(). Controls the distance between hierarchical levels. Consider changing the value if the aspect ratio of the graph is far from 1. If level_separation is NULL, the levelSeparation argument of visHierarchicalLayout() defaults to 150.

degree_from

Integer of length 1. When you click on a node, the graph highlights a neighborhood of that node. degree_from controls the number of edges the neighborhood extends upstream.

degree_to

Integer of length 1. When you click on a node, the graph highlights a neighborhood of that node. degree_to controls the number of edges the neighborhood extends downstream.

config

Character of length 1, path to the YAML file with all the configuration settings (default: _targets.yaml).

height

Character of length 1, height of the visNetwork widget and branches table.

display

Character of length 1, which display to show first.

displays

Character vector of choices for the display. Elements can be any of "graph", "summary", "branches", or "about".

background

Logical, whether to run the app in a background process so you can still use the R console while the app is running.

browse

Whether to open the app in a browser when the app is ready. Only relevant if background is TRUE.

host

Character of length 1, IPv4 address to listen on. Only relevant if background is TRUE.

port

Positive integer of length 1, TCP port to listen on. Only relevant if background is TRUE.

verbose

whether to print a spinner and informative messages. Only relevant if background is TRUE.

supervise

Whether to register the process with a supervisor. If TRUE, the supervisor will ensure that the process is killed when the R process exits.

poll_connection

Whether to have a control connection to the process. This is used to transmit messages from the subprocess to the main process.

stdout

The name of the file the standard output of the child R process will be written to. If the child process runs with the --slave option (the default), then the commands are not echoed and will not be shown in the standard output. Also note that you need to call print() explicitly to show the output of the command(s).

stderr

The name of the file the standard error of the child R process will be written to. In particular message() sends output to the standard error. If nothing was sent to the standard error, then this file will be empty. This argument can be the same file as stdout, in which case they will be correctly interleaved. If this is the string "2>&1", then standard error is redirected to standard output.

Value

A handle to callr::r_bg() background process running the app.

Details

The controls of the app are in the left panel. The seconds control is the number of seconds between refreshes of the graph, and the other settings match the arguments of tar_visnetwork().

See Also

Other progress: tar_built(), tar_canceled(), tar_errored(), tar_poll(), tar_progress_branches(), tar_progress_summary(), tar_progress(), tar_skipped(), tar_started(), tar_watch_server(), tar_watch_ui()

Examples

Run this code
# NOT RUN {
if (identical(Sys.getenv("TAR_INTERACTIVE_EXAMPLES"), "true")) {
tar_dir({ # tar_dir() runs code from a temporary directory.
tar_script({
  sleep_run <- function(...) {
    Sys.sleep(10)
  }
  list(
    tar_target(settings, sleep_run()),
    tar_target(data1, sleep_run(settings)),
    tar_target(data2, sleep_run(settings))
  )
}, ask = FALSE)
# Launch the app in a background process.
tar_watch(seconds = 10, outdated = FALSE, targets_only = TRUE)
# Run the pipeline.
tar_make()
})
}
# }

Run the code above in your browser using DataLab