armi.utils.outputCache module

TerraPower Calculation Results Cache (CRC).

This helps avoid duplicated time/energy in running cases. In test systems and analysis, it’s possible that the same calc will be done over and over, always giving the same result. This system allows the results to be cached and returned instantly instead of re-running, for example, MC2.

API usage

Getting a cached file:

exe = 'MC2-2018-blah.exe'
inpFiles = ['mccAA.inp', 'rmzflx']
outputFound = crc.retrieveOutput(exe, inp, output)
if not outputFound:
    mc2.run(exe, inp, output)

Storing a file to the cache:

crc.store(exe, inp, outFiles)

Notes

Could probably be, like, a decorate on subprocess but we call subprocess a bunch of different ways.

armi.utils.outputCache.retrieveOutput(exePath, inputPaths, cacheDir, locToRetrieveTo=None)[source]

Check the cache for a valid file and copy it if it exists.

Notes

Input paths need to be in the same order each time if the same cached folder is expected to be found.

armi.utils.outputCache.store(exePath, inputPaths, outputFiles, cacheDir)[source]

Store an output file in the cache.

Notes

Input paths need to be in the same order each time if the same cached folder is expected to be found. It is difficult to know what outputs will exist from a specific run, so only outputs that do exist will attempt to be copied. This function should be supplied with a greedy list of outputs.

armi.utils.outputCache.deleteCache(cachedFolder)[source]

Remove this folder.

Requires safeword because this is potentially extremely destructive.

armi.utils.outputCache.cacheCall(cacheDir, executablePath, inputPaths, outputFileNames, execute=None, tearDown=None)[source]

Checks the cache to see if there are outputs for the run and returns them, otherwise calls the execute command.

Notes

It is non-trivial to determine the exact set of outputs an executable will produce without running the executable. Therefore, outputFileNames is expected to be a greedy list and cache will attempt to copy all the files, but not fail if the file is not present. When copying outputs back, all files copied previously will be targeted.