Skip to content

Commit

Permalink
Improve reloading py module
Browse files Browse the repository at this point in the history
  • Loading branch information
augustjohansson committed Dec 5, 2024
1 parent 377a0b9 commit 517fa5b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Utilities/JsonUtils/loadModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@ function loadModule(modulenames, varargin)
modulename = modulenames{k};
try
dispif(mrstVerbose, 'Loading module %s\n', modulename);
mod = py.importlib.import_module(modulename);
py.importlib.import_module(modulename);

if opt.reload
py.importlib.reload(mod);

sys = py.importlib.import_module('sys');
if isfield(sys.modules, modulename)
remove(sys.modules, modulename);
else
warning('Module %s was not loaded before, so it cannot be reloaded.', modulename);
end

py.importlib.import_module(modulename);

end

catch e
Expand Down

0 comments on commit 517fa5b

Please sign in to comment.