CLIExecutor

CLIExecutor(
    command_template,
    input_path='temp_in.csv',
    output_path='temp_out.csv',
)

Runs an external program in a separate process, passing data through CSV files.

Each batch is written to input_path, the command is run and its results are read back from output_path. Because the solver runs in its own process, all its memory is released when it exits, which avoids leaks with heavy software (e.g. Abaqus, Ansys or a large Python FEA script).

Paths are substituted for {input} and {output} in the template. On POSIX the template is split into arguments first (no shell is used), so paths containing spaces stay single arguments. On Windows the command is passed as one string, so backslashes are kept but you should quote "{input}" and "{output}" in the template if the paths may contain spaces.

Parameters

Name Type Description Default
command_template str The command as you would type it in a terminal, with {input} and {output} where the file paths go. required
input_path str CSV file written for the solver to read. Defaults to "temp_in.csv". 'temp_in.csv'
output_path str CSV file the solver must write. Defaults to "temp_out.csv". 'temp_out.csv'

Examples

executor = CLIExecutor(command_template="python run_abaqus.py {input} {output}")

Methods

Name Description
run Writes samples to CSV, runs the command and reads the results back.