Run a single file in pytest that is a module in a PEP 420. So appearently Maya has all the script files in some cache memory, so when running import again you are not actually trying to import the modified - working - script, but the old one with the error. Related Query Packaging single Python module with dependencies python reload module for beginner. Running reload(module) gives you an error saying the module couldn´t be found. You save (or copy) the now working script to the Maya user script dir. The python interpreter halts the execution, you are alerted of the error and you go back to your IDE/text editor and fix the problem. You save the script (in the Maya user script dir) and run Maya. Now lets add an error that will cause the script to fail execution, such as trying to iterate over an undeclared variable. The init-file in turn imports other scripts from the same package, in a particular order. Hello from M1: ABC def dir(M1) surprise M1.> reload(M1) rerun M1 in its own namespace. Say you have a working python module - in the form of a package - in the user script dir. change a ABC, remove c, add d xyz in module M1. Though I appreciate that is not very pretty.This has bugged me like forever, and if I recall I´ve tried making sense of this before but haven´t really found an answer (nor has anyone given me the answer I want). I think the problem with your code is that due to scope, the loaded variable is reset when you run the Toolkit restart, so it is never True? The environment variables should survive the reload. Examples of how to reload a python module: Table of contents Reload a module for Python 3.4 or > Reload a module for Python > 3.0 and < 3. _command("Show Starter Template App.", self.show_app) Created Aug Viewed 3966 Comments If you develop your own python module it can be useful to reload it each time you make some change. If "MESSAGE_HELPER_PRELOADED" in os.environ: You can reload the module as: reload (sys. # Append path to message helper module location takes all exported objects from module and binds them to module-level (or whatever-your-scope-was-level) names. I just mocked up an example on my side, and whilst Toolkit wonât reload any modules that it didnât import (Iâm not actually a 100% on what the requirements are there), you should be able to reload them with a reload statement, but you would need to handle that your self. The reload() function in this module also reloads everything imported from that. # when reloaded, loaded is defined as true, so reload your submodules:Äo you know any way to force python / sgtk to reload all submodules without exiting maya? Right now, everytime I make a syntaårror, it takes me several minutes juste to relaunch maya⦠Pythons normal reload() function only reloads the module that its passed. # loaded is then defined in the exception block # First time the module imports, loaded is undefined and will trigger the exception. Module B is outside config folder, in a cross project directoryĪll init.py are setuped to reload submodules: I am using a decentralised setup (descriptor pointing to a folder on our sever) Even âReload engine and appsâ in Maya Shotgunâs Work Area Info does not seem to do the trick. My problem is that SGTK does not seem to reload module B if I donât completly close and restart maya. Iâm currently working on a publish pipeline, using STK to do checks and publish operations with my own modules.Ä®nv hook tk-multi-publish2 loads a module A, which loads a module B, which does some stuff.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |