Skip to contents

Fetch information about a task. This is much more detailed than the information in task_status. If a task is running we also fetch the true status via its driver, which can be slower.

Usage

task_info(id, follow = TRUE, root = NULL)

Arguments

id

A single task id to fetch information for

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.

Value

An object of class hipercow_task_info, which will print nicely. This is just a list with elements:

  • id: the task identifier

  • status: the retrieved status

  • driver: the driver used to run the task (or NA)

  • data: the task data (depends on the type of task)

  • times: a vector of times

  • retry_chain: the retry chain (or NULL)

You can see and access these elements more easily by running unclass() on the result of task_info().

Examples

cleanup <- hipercow_example_helper()
#>  This example uses a special helper
id <- task_create_expr(runif(1))
#>  Submitted task '01375182d8805f7c24a0e98ec4de004c' using 'example'
task_wait(id)
#> [1] TRUE

# Task information at completion includes times:
task_info(id)
#> 
#> ── task 01375182d8805f7c24a0e98ec4de004c (success) ─────────────────────────────
#>  Submitted with 'example'
#>  Task type: expression
#>   • Expression: runif(1)
#>   • Locals: (none)
#>   • Environment: default
#>     R_GC_MEM_GROW: 3
#>  Created at 2024-08-16 20:23:00.744898 (moments ago)
#>  Started at 2024-08-16 20:23:00.922689 (moments ago; waited 178ms)
#>  Finished at 2024-08-16 20:23:01.011401 (moments ago; ran for 89ms)

# If you need to work with these times, use the "times" element:
task_info(id)$times
#>                   created                   started                  finished 
#> "2024-08-16 20:23:00 UTC" "2024-08-16 20:23:00 UTC" "2024-08-16 20:23:01 UTC" 

# If a task is retried, this information appears as a retry chain:
id2 <- task_retry(id)
#>  Submitted task '8ce6b09f1541cbe2129e3244782ea3e1' using 'example'
task_info(id2, follow = FALSE)
#> 
#> ── task 8ce6b09f1541cbe2129e3244782ea3e1 (success) ─────────────────────────────
#>  Submitted with 'example'
#>  Task type: expression
#>   • Expression: runif(1)
#>   • Locals: (none)
#>   • Environment: default
#>     R_GC_MEM_GROW: 3
#>  Created at 2024-08-16 20:23:00.744898 (moments ago)
#>  Started at 2024-08-16 20:23:01.816058 (moments ago; waited 1.1s)
#>  Finished at 2024-08-16 20:23:01.81693 (moments ago; ran for 1ms)
#>  Last of a chain of a task retried 1 time
task_info(id2)
#> 
#> ── task 8ce6b09f1541cbe2129e3244782ea3e1 (success) ─────────────────────────────
#>  Submitted with 'example'
#>  Task type: expression
#>   • Expression: runif(1)
#>   • Locals: (none)
#>   • Environment: default
#>     R_GC_MEM_GROW: 3
#>  Created at 2024-08-16 20:23:00.744898 (moments ago)
#>  Started at 2024-08-16 20:23:01.816058 (moments ago; waited 1.1s)
#>  Finished at 2024-08-16 20:23:01.81693 (moments ago; ran for 1ms)
#>  Last of a chain of a task retried 1 time

cleanup()
#>  Cleaning up example