I noticed some issues when passing --disable-safe-unpickle on the command line where the plugin would accidentally disable the flag attempting to restore its previous state. This version allows nested disable/enables by ref-counting the disable count.
I also added wrapper to use the Python with syntax instead of calling enable/disable. This has the advantage of being exception safe and also makes it impossible to forget to call enable after disabling it. I could revert this part of the change though if it's not something you want. However I did notice one missing enable in train_dreambooth.py
The large changes in this PR are due to indenting existing code to be inside with blocks. I didn't actually change the code although the GitHub diff view seems a little confused. The only actual new code is in model_utils.py
Issue ticket number and link (if applicable)
Checklist before requesting a review
[x] This is based on the /dev branch (Or a fork of it)
[x] This was created or at least validated using a proper IDE
[x] I have tested this code and validated any modified functions
[x] I have added the appropriate documentation and hint strings if adding or changing a user-facing feature
Describe your changes
I noticed some issues when passing
--disable-safe-unpickle
on the command line where the plugin would accidentally disable the flag attempting to restore its previous state. This version allows nested disable/enables by ref-counting the disable count.I also added wrapper to use the Python
with
syntax instead of calling enable/disable. This has the advantage of being exception safe and also makes it impossible to forget to call enable after disabling it. I could revert this part of the change though if it's not something you want. However I did notice one missing enable in train_dreambooth.pyThe large changes in this PR are due to indenting existing code to be inside
with
blocks. I didn't actually change the code although the GitHub diff view seems a little confused. The only actual new code is in model_utils.pyIssue ticket number and link (if applicable)
Checklist before requesting a review