View source: R/trace_functions.R
start_trace | R Documentation |
Some functions create output files during their execution; some of them are slow, so the probability that something goes wrong during their execution is not null, with the consequence that output files are incomplete, or that undesired temporary files are left on the filesystem.
This functions is though to manage these situations.
trace_function runs a function and checks if errors occur during its execution; in this case, the files created by it are deleted (only if the timestamp of the files is subsequent to the time of execution of the function). If the code interrupts before the function ends, the paths of the files intended to be created by the function are saved within the package, so that they can be easily deleted in a second time; to do it, simply run clean_traces.
Other intermediate functions are used internally: start_trace saves the paths of the files intended to be created within a text file; end_trace deletes this text file (it is used by trace_function when a function stops without errors); clean_trace deletes this text file and the intended output files (it is used by trace_function when a function stops with errors).
start_trace(trace_files, trace_funname)
end_trace(tracename)
clean_trace(tracename)
trace_function(trace_fun, trace_files, trace_funname = NA, ...)
clean_traces(trace_funname = NA)
trace_files |
Vector of the files intended to be created by |
trace_funname |
The name of the function to be run (in start_trace) or to be cleaned (in clean_traces; if NA, all the traces are cleaned). |
tracename |
The path of the text file containing the log information generated by start_trace. |
trace_fun |
The function to be run. |
... |
Arguments of the function |
NULL (the function is called for its side effects)
License: GPL 3.0
Luigi Ranghetti, phD (2019)
L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). "sen2r": An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.cageo.2020.104473")}, URL: https://sen2r.ranghetti.info/.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.