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 'de886c9df25512d83bab9126b1cbea2c' using 'example'
task_wait(id)
#> [1] TRUE
task_log_show(id)
#> 
#> ── hipercow 1.0.36 running at '/tmp/Rtmpw3JKrD/file16dc468e9efa' ───────────────
#> ℹ 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: de886c9df25512d83bab9126b1cbea2c
#> ℹ starting at: 2024-10-08 15:27:16.026911
#> ℹ Task type: expression
#> • Expression: runif(1)
#> • Locals: (none)
#> • Environment: default
#>   R_GC_MEM_GROW: 3
#> ───────────────────────────────────────────────────────────────── task logs ↓ ──
#> 
#> ───────────────────────────────────────────────────────────────── task logs ↑ ──
#> ✔ status: success
#> ℹ finishing at: 2024-10-08 15:27:16.026911 (elapsed: 0.2116 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 '58de7651cd68b3ce91778fed0a242b73' using 'example'
task_wait(id)
#> [1] TRUE
task_log_show(id)
#> 
#> ── hipercow 1.0.36 running at '/tmp/Rtmpw3JKrD/file16dc468e9efa' ───────────────
#> ℹ 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: 58de7651cd68b3ce91778fed0a242b73
#> ℹ starting at: 2024-10-08 15:27:16.849377
#> ℹ 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-10-08 15:27:16.849377 (elapsed: 0.2187 secs)

# Use "task_log_value" to get the log value as a character vector
task_log_value(id)
#>  [1] ""                                                                                
#>  [2] "── hipercow 1.0.36 running at '/tmp/Rtmpw3JKrD/file16dc468e9efa' ───────────────"
#>  [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: 58de7651cd68b3ce91778fed0a242b73"                                          
#>  [8] "ℹ starting at: 2024-10-08 15:27:16.849377"                                       
#>  [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-10-08 15:27:16.849377 (elapsed: 0.2187 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 58de7651cd68b3ce91778fed0a242b73
#> Finished task 58de7651cd68b3ce91778fed0a242b73

cleanup()
#>  Cleaning up example