Description Usage Arguments Details Value Fields Methods Examples
Create/Restore a client-side task proxy
1 2 3 | new_task2(fun, ..., task_name = "Noname", globals = TRUE, env = parent.frame())
restore_task2(task_name)
|
fun, ... |
function to apply and additional parameters to be
passed to |
task_name |
a readable name for the task; default is |
globals |
variables to export to the computing processes; see details. |
env |
environment where the |
A task proxy manages a folder at task_dir containing all
the information necessary to perform the task. A task is a collection
of "jobs" (see its definition in batchMap).
The evaluation of the jobs is always in different processes with the current
R session, sometimes even different computers.
Sometimes the function fun may contains external objects that need
to be exported. For example, function(x){ a+x } has a variable
a that might be defined in somewhere else. It will raise errors
if we simply execute the function. Therefore, the task requires exporting
the variable a before executing jobs. This task could be done
automatically or manually.
If globals is TRUE, then all the external variables including
the packages needed will be automatically detected and exported.
If globals is a character vector, then only the variables indicated
will be correctly exported
If globals is FALSE, then you need to manually specify them
in task$set_globals method
If the task does not exist, the returns NULL, otherwise
returns a locked environment proxy that wraps batch task with the following
fields and methods.
task_nametask ID, a combination of user ID, task readable name, and a 16-character random string
readable_namea friendly name of the task
task_dirtask directory where the jobs are stored
task_rootroot directory where all tasks are stored
reg'batchtools' registry that reads batch job status
njobstotal number of jobs in the task
protocol, host, port, path_*server
to be submitted to, used by 'submit()' method
submittedwhether the task has been submitted or not
submitted_toif the task has been submitted, then where
resultsthe result of the task, should almost surely use
collect() instead
collectedwhether the results has been loaded from task directory into the memory
submitsubmit or re-submit a task. If 'pack' is true,
then the task files will be archived before sending to the server. This
option is required when server runs remotely.
resolvedcheck whether the task has been resolved, a
combination of server_status() and local_status(). Will
raise errors if server if not running
locally_resolvedcheck whether task is resolved locally without
query the server. Only used to check local files. It's possible that
server has finished but locally not resolved. See download() to
synchronize local files with the finished tasks on the server
server_statusget task status from servers
local_statusget task status from servers
downloaddownload the finished tasks from the server and overwrite the local files. Raises error if the task is not finished remotely. Always check server status before downloading.
collectcollect results. It checks the status both locally and remotely; download the task if finished; load up the results. This function will block the session waiting for results.
zipcreate an archive that stores the task
clear_registryclear the registry, usually used to re-use the task or to re-run the task
reload_registryreload 'reg' registry under read-only
or writable modes. If the task has been submitted, please load in
read-only mode to avoid file corrects
removeremove the whole task from the hard drive
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | task <- new_task2(function(...){
list(...)
}, x = 1:3, y = 1:6)
# Not submitted
task
# save task name to same other places
task_name <- task$task_name
# submit the task
if(interactive()){
ensure_server()
task$submit()
task
# once finished
kill_server()
}
# Remove the task. You can always restore with task_name
rm(task)
task_restored <- restore_task2(task_name = task_name)
if(task_restored$submitted && task_restored$resolved()){
task_restored$collect()
}
# clean up, remove all task files
task_restored$remove()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.