Ligare.programming.R.process
Classes
|
Configure an object to execute an R script with Rscript. |
- final class Ligare.programming.R.process.RProcessStepBuilder(log=None)[source]
Configure an object to execute an R script with Rscript.
- final class RProcessExecutorStepBuilder(parent, log=None)[source]
The final step in configurating an R process executor. This class can run the command with the execute() method.
- execute()[source]
Execute the configured R script.
- Return CompletedProcess[bytes]:
The completed process object from process.run(…)
- Return type:
tuple
[CompletedProcess
[bytes
],bytes
]
- static execute_R_process(args, parameter_read_fd, data)[source]
Run the process specified by args, which is passed into subprocess.run as the first argument. This method adds the METHOD_ARG_READ_FD environment variable whose value is str(parameter_read_fd). This method blocks thread execution until the process completes.
- Parameters:
args (list[str|bytes|PathLike[str]|PathLike[bytes]]) – The argument list to pass to subprocess.run.
parameter_read_fd (int) – A file descriptor number from which R will read method parameters.
data (bytes | None) – Data that is written to the executed process’s STDIN.
- Return subprocess.CompletedProcess[bytes]:
The completed process.
- Return type:
tuple
[CompletedProcess
[bytes
],bytes
]
- static handle_process_errors(proc, log=None)[source]
Decode a finished process’s STDERR. If the process’s STDOUT is empty, an error is considered to have occurred, and an exception is raised. Otherwise, STDERR is logged and the function returns.
- Parameters:
proc (subprocess.CompletedProcess[bytes]) – The completed process.
log (Logger) – The Logger that is written to
- Raises:
Exception – Raised only if STDERR is not empty and STDOUT is empty.
- Return type:
None
- property method: RProcessMethodStepBuilder
- property process: RProcessStepBuilder
- property script: RProcessScriptStepBuilder
- final class RProcessMethodStepBuilder(parent, log=None)[source]
Configure method parameters and input for the R script to read.
- property script: RProcessScriptStepBuilder
- with_data(data)[source]
The input data for the R script.
- Parameters:
data (bytes) – The data
- Return RProcessStepBuilder.RProcessExecutorStepBuilder:
The next step for configuration
- Return type:
- with_log(log)[source]
Configure the logger.
- Parameters:
log (Logger)
- Return Self:
- Return type:
Self
- with_method_parameters(parameters)[source]
The method parameters and their values.
- Parameters:
parameters (dict[str, Any]) – The parameters
- Return Self:
- Return type:
Self
- static write_method_parameters(parameters)[source]
Open a FIFO pipe and write the dictionary parameters as a CSV to write_fd.
- Parameters:
parameters (dict[str, Any]) – The parameters to write to the pipe
- Return tuple[int, int]:
(read_fd, write_fd) the input/output file descriptors of the pipe
- Return type:
tuple
[int
,int
]
- final class RProcessScriptStepBuilder(parent, log=None)[source]
Configure the R script to execute with Rscript.
- property process: RProcessStepBuilder