Learn R Programming

targets (version 0.4.1)

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,
  outdated = TRUE,
  label = NULL,
  level_separation = 150,
  height = "650px",
  background = TRUE,
  browse = TRUE,
  host = getOption("shiny.host", "127.0.0.1"),
  port = getOption("shiny.port", targets::tar_random_port()),
  verbose = TRUE,
  supervise = TRUE
)

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 imported global functions and objects.

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.

height

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

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.

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_poll(), tar_progress_branches(), tar_progress_summary(), tar_progress(), 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