christofmuc / KnobKraft-orm

The KnobKraft Orm - The free modern cross-platform MIDI Sysex Librarian
GNU Affero General Public License v3.0
200 stars 25 forks source link

2.0.1 reload python file no longer reloads python file #227

Closed bboc closed 1 year ago

bboc commented 1 year ago

It appears that the button for reloading an adaptation no longer does that. When I remove an api method and press the button, the file is not reloaded and the function is not removed from the list.

This means I now have to close and re-open KnobKraft every time I make a change in an adaptation.

christofmuc commented 1 year ago

@bboc I tested this, and I think it still works. If you switch the log level to debug in the log window, you can see that it prints the namespace of the newly loaded module after each reload. So adding functions certainly works. The limitation seems to come from the fact that reload in Python does actually not clear the namespace, it just executes the def() functions in the module. So if a previous run created a function, it will stay there.

We could add code to clear out the namespace and del the functions, but I am not sure how relevant that use case is. I understand it came up when testing the friendlyProgramName bug, but normally this is not a common operation?

bboc commented 1 year ago

I just tested it, the log confirms the adaptation is reloaded. I agree the usecase is only when testing adaptations, so I'll close this.