Is there a way to cache the GenericAnalysis (and/or all its associated results files) so I don’t have to re-run the simulation if I don’t need to? A code snippet would be much appreciated. Thank you.
@memoize def func(*, param_a, param_b, param_c): generic_analysis = GenericAnalysis(files=files, executable_key="executable", output_filenames=["output.xml", "geometry.json"]) return result class Controller(ViktorController): ... @DataView("Results", duration_guess=30) def get_data_view(self, params, **kwargs): ... result = func(param_a=..., param_b=..., param_c=...) ... return DataResult(...)
You do however need to keep in mind that there are some strict limitations to the use of the
memoize decorator. Most importantly in this case is that the inputs as well as the outputs of the method being memoized have to be serializable. So that is something to take into account when preparing the files for the
GenericAnalysis as well as the output parsing.
Another option would be to involve the
Storage capabilities. You could in that case include a check for a change in significant parameter values and if no change has occurred since the last storage entry of the analysis results, return the file directly from storage. If the params have changed, run the analysis again. Be warned though that this method is a lot less robust and therefore yields less value and requires more development work.
Hope that helped, if you have more questions let me know!