Diadem Python Script Does Not Reflect the Changes in the Module Called

Updated Oct 14, 2021

Reported In

Software

  • DIAdem

Issue Details

My main Python script call a module. When I modify the module then I execute my main script, these changes will not be reflected in the result. I have to close and reopen DIAdem to execute the module with the changes. 
What can I do to avoid to close and reopen DIAdem ?
 

Solution

Global variables, to which a value in a DIAdem Python script is assigned, retain that value even after the script ends. A similar behavior occurs when importing Python modules with the import command. After you have imported a module, Python in DIAdem does not automatically detect when the module changes unless you reload it with importlib.reload.
 
For example:
   import MySub
   import importlib
   importlib.reload(MySub).