Get the task log, if the task has produced one. Tasks run by the
dide-windows
driver will generally produce a log. A log might be
quite long, and you might want to print it to screen in its
entirety (task_log_show
), or return it as character vector
(task_log_value
).
Usage
task_log_show(id, outer = FALSE, follow = TRUE, root = NULL)
task_log_value(id, outer = FALSE, follow = TRUE, root = NULL)
task_log_watch(
id,
poll = 1,
skip = 0,
timeout = NULL,
progress = NULL,
follow = TRUE,
root = NULL
)
Arguments
- id
The task identifier
- outer
Logical, indicating if we should request the "outer" logs; these are logs from the underlying HPC software before it hands off to hipercow.
- follow
Logical, indicating if we should follow any retried tasks.
- root
A hipercow root, or path to it. If
NULL
we search up your directory tree.- poll
Time, in seconds, used to throttle calls to the status function. The default is 1 second
- skip
Optional integer indicating how to handle log content that exists at the point where we start watching. The default (0) shows all log contents. A positive integer skips that many lines, while a negative integer shows only that many lines (so -5 shows the first five lines in the log). You can pass
Inf
to discard all previous logs, but stream all new ones.- timeout
The time to wait for the task to complete. The default is to wait forever.
- progress
Logical value, indicating if a progress spinner should be used. The default
NULL
uses the optionhipercow.progress
, and if unset displays a progress bar in an interactive session.
Value
Depending on the function:
task_log_show
returns the log value contents invisibly, but primarily displays the log contents on the console as a side effecttask_log_value
returns a character of log contentstask_log_watch
returns the status converted to logical (as for task_wait)
Details
The function task_log_watch
has similar semantics to
task_wait but does not error on timeout, and always displays a
log.
Examples
cleanup <- hipercow_example_helper(with_logging = TRUE)
#> ℹ This example uses a special helper
# Tasks that don't produce any output (print, cat, warning, etc)
# will only contain logging information from hipercow itself
id <- task_create_expr(runif(1))
#> ✔ Submitted task '4b8b48df89e7f004a5c2920c22756f21' using 'example'
task_wait(id)
#> [1] TRUE
task_log_show(id)
#>
#> ── hipercow 1.1.3 running at '/home/runner/work/_temp/hv-20250423-1de5242945f1'
#> ℹ library paths:
#> • /home/runner/work/_temp/Library
#> • /opt/R/4.5.0/lib/R/site-library
#> • /opt/R/4.5.0/lib/R/library
#> ℹ id: 4b8b48df89e7f004a5c2920c22756f21
#> ℹ starting at: 2025-04-23 13:09:10.233409
#> ℹ Task type: expression
#> • Expression: runif(1)
#> • Locals: (none)
#> • Environment: default
#> R_GC_MEM_GROW: 3
#> ───────────────────────────────────────────────────────────────── task logs ↓ ──
#>
#> ───────────────────────────────────────────────────────────────── task logs ↑ ──
#> ✔ status: success
#> ℹ finishing at: 2025-04-23 13:09:10.233409 (elapsed: 0.204 secs)
# If your task creates output then it will appear within the
# horizontal rules:
id <- task_create_explicit(quote({
message("Starting analysis")
x <- mean(runif(100))
message("all done!")
x
}))
#> ✔ Submitted task '466756dd1ebb6053fdf411e79285426a' using 'example'
task_wait(id)
#> [1] TRUE
task_log_show(id)
#>
#> ── hipercow 1.1.3 running at '/home/runner/work/_temp/hv-20250423-1de5242945f1'
#> ℹ library paths:
#> • /home/runner/work/_temp/Library
#> • /opt/R/4.5.0/lib/R/site-library
#> • /opt/R/4.5.0/lib/R/library
#> ℹ id: 466756dd1ebb6053fdf411e79285426a
#> ℹ starting at: 2025-04-23 13:09:11.146183
#> ℹ Task type: explicit
#> • Expression: { [...]
#> • Locals: (none)
#> • Environment: default
#> R_GC_MEM_GROW: 3
#> ───────────────────────────────────────────────────────────────── task logs ↓ ──
#> Starting analysis
#> all done!
#>
#> ───────────────────────────────────────────────────────────────── task logs ↑ ──
#> ✔ status: success
#> ℹ finishing at: 2025-04-23 13:09:11.146183 (elapsed: 0.2213 secs)
# Use "task_log_value" to get the log value as a character vector
task_log_value(id)
#> [1] ""
#> [2] "── hipercow 1.1.3 running at '/home/runner/work/_temp/hv-20250423-1de5242945f1' "
#> [3] "ℹ library paths:"
#> [4] "• /home/runner/work/_temp/Library"
#> [5] "• /opt/R/4.5.0/lib/R/site-library"
#> [6] "• /opt/R/4.5.0/lib/R/library"
#> [7] "ℹ id: 466756dd1ebb6053fdf411e79285426a"
#> [8] "ℹ starting at: 2025-04-23 13:09:11.146183"
#> [9] "ℹ Task type: explicit"
#> [10] "• Expression: { [...]"
#> [11] "• Locals: (none)"
#> [12] "• Environment: default"
#> [13] " R_GC_MEM_GROW: 3"
#> [14] "───────────────────────────────────────────────────────────────── task logs ↓ ──"
#> [15] "Starting analysis"
#> [16] "all done!"
#> [17] ""
#> [18] "───────────────────────────────────────────────────────────────── task logs ↑ ──"
#> [19] "✔ status: success"
#> [20] "ℹ finishing at: 2025-04-23 13:09:11.146183 (elapsed: 0.2213 secs)"
# Depending on the driver you are using, there may be useful
# information in the "outer" log; the logs produced by the
# submission system before hipercow takes over:
task_log_show(id, outer = TRUE)
#> Running task 466756dd1ebb6053fdf411e79285426a
#> Finished task 466756dd1ebb6053fdf411e79285426a
cleanup()
#> ℹ Cleaning up example