Skip to content

Commit

Permalink
Add option to reload module
Browse files Browse the repository at this point in the history
  • Loading branch information
augustjohansson committed Jun 19, 2024
1 parent e8bcb8d commit d2dfbe3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Utilities/JsonUtils/loadModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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);
Expand Down

0 comments on commit d2dfbe3

Please sign in to comment.