Skip to contents

Get the task log, if the task has produced one. Tasks run by the 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 option hipercow.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 effect

  • task_log_value returns a character of log contents

  • task_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 'cc8b7aecd66dcaaeb1c400ec794c700a' using 'example'
task_wait(id)
#> [1] TRUE
task_log_show(id)
#> 
#> ── hipercow 1.0.34 running at '/tmp/RtmpUN1Cun/file194c56a28874' ───────────────
#> ℹ library paths:
#> • /home/runner/work/_temp/Library
#> • /opt/R/4.4.1/lib/R/site-library
#> • /opt/R/4.4.1/lib/R/library
#> ℹ id: cc8b7aecd66dcaaeb1c400ec794c700a
#> ℹ starting at: 2024-08-16 20:23:02.556858
#> ℹ Task type: expression
#> • Expression: runif(1)
#> • Locals: (none)
#> • Environment: default
#>   R_GC_MEM_GROW: 3
#> ───────────────────────────────────────────────────────────────── task logs ↓ ──
#> 
#> ───────────────────────────────────────────────────────────────── task logs ↑ ──
#> ✔ status: success
#> ℹ finishing at: 2024-08-16 20:23:02.556858 (elapsed: 0.2068 secs)

# If your task creates output then it will appear within the
# horizontal rules:
id <- task_create_expr({
  message("Starting analysis")
  x <- mean(runif(100))
  message("all done!")
  x
})
#>  Submitted task '9bfac0676ecf9b35dc6dab6a317855c0' using 'example'
task_wait(id)
#> [1] TRUE
task_log_show(id)
#> 
#> ── hipercow 1.0.34 running at '/tmp/RtmpUN1Cun/file194c56a28874' ───────────────
#> ℹ library paths:
#> • /home/runner/work/_temp/Library
#> • /opt/R/4.4.1/lib/R/site-library
#> • /opt/R/4.4.1/lib/R/library
#> ℹ id: 9bfac0676ecf9b35dc6dab6a317855c0
#> ℹ starting at: 2024-08-16 20:23:03.371516
#> ℹ Task type: expression
#> • Expression: { [...]
#> • Locals: (none)
#> • Environment: default
#>   R_GC_MEM_GROW: 3
#> ───────────────────────────────────────────────────────────────── task logs ↓ ──
#> Starting analysis
#> all done!
#> 
#> ───────────────────────────────────────────────────────────────── task logs ↑ ──
#> ✔ status: success
#> ℹ finishing at: 2024-08-16 20:23:03.371516 (elapsed: 0.2172 secs)

# Use "task_log_value" to get the log value as a character vector
task_log_value(id)
#>  [1] ""                                                                                
#>  [2] "── hipercow 1.0.34 running at '/tmp/RtmpUN1Cun/file194c56a28874' ───────────────"
#>  [3] "ℹ library paths:"                                                                
#>  [4] "• /home/runner/work/_temp/Library"                                               
#>  [5] "• /opt/R/4.4.1/lib/R/site-library"                                               
#>  [6] "• /opt/R/4.4.1/lib/R/library"                                                    
#>  [7] "ℹ id: 9bfac0676ecf9b35dc6dab6a317855c0"                                          
#>  [8] "ℹ starting at: 2024-08-16 20:23:03.371516"                                       
#>  [9] "ℹ Task type: expression"                                                         
#> [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: 2024-08-16 20:23:03.371516 (elapsed: 0.2172 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 9bfac0676ecf9b35dc6dab6a317855c0
#> Finished task 9bfac0676ecf9b35dc6dab6a317855c0

cleanup()
#>  Cleaning up example