Repeater#
- class simplesimdb.Repeater(executable='./execute.sh', inputfile='temp.json', outputfile='temp.nc')[source]#
Bases:
objectManage a single file pair (inputfile, outputfile)
The purpose of this class is to provide a simple tool when you do not want to actually store simulation data on disc (except temporarily). It is sometimes more efficient to simply write the data into a single file and then reuse/overwrite it in all subsequent simulations.
- __init__(executable='./execute.sh', inputfile='temp.json', outputfile='temp.nc')[source]#
Set the executable and files to use in the run method
- property executable#
- property inputfile#
- property outputfile#
- run(js, error='display', stdout='ignore', *, check=True, capture_output=True, **kwargs)[source]#
Write inputfile and then run a simulation
- Parameters:
js (
dict[str,Any]) – the complete input file as a python dictionary. All keys must be strings such that js can be converted to JSON.error (
str) –“raise”: raise a subprocess.CalledProcessError error if the executable returns a non-zero exit code
”display”: print(stderr ) then return
”ignore” return
stdout (
str) –“ignore” throw away std output
”display” print( process.stdout)
check (
bool) – passed to subprocess.run, if True a non-zero exit code raises a subprocess.CalledProcessError, if False, no exception is raised and you can check the return code with process.returncodecapture_output (
bool) – passed to subprocess.run, if True, stdout and stderr are captured and can be accessed with process.stdout and process.stderr.kwargs – additional arguments passed to subprocess.run in the run method