From d2dfbe33f45e884f14e0e3017675c678f53879b3 Mon Sep 17 00:00:00 2001 From: August Johansson Date: Wed, 19 Jun 2024 10:06:58 +0200 Subject: [PATCH] Add option to reload module --- Utilities/JsonUtils/loadModule.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Utilities/JsonUtils/loadModule.m b/Utilities/JsonUtils/loadModule.m index 23c788f2..38b5f635 100644 --- a/Utilities/JsonUtils/loadModule.m +++ b/Utilities/JsonUtils/loadModule.m @@ -5,7 +5,8 @@ function loadModule(modulenames, varargin) opt = struct('setupPython', true, ... 'dir', fullfile(battmoDir(), 'Utilities', 'JsonUtils'), ... - 'exec', ''); + 'exec', '', ... + 'reload', false); opt = merge_options(opt, varargin{:}); if mrstPlatform('matlab') @@ -22,8 +23,13 @@ function loadModule(modulenames, varargin) for k = 1:numel(modulenames) modulename = modulenames{k}; try - py.importlib.import_module(modulename); dispif(mrstVerbose, 'Loading module %s\n', modulename); + mod = py.importlib.import_module(modulename); + + if opt.reload + py.importlib.reload(mod); + end + catch e disp(e); error('Failed to load module %s', modulename);