Issue reloading external python library

I’m trying to make a python package for our company, so it can be reused over multiple projects.

As the editor in Ignition is rather basic, I prefer to write it in a separate editor and load it into Ignition as a third party library (https://support.inductiveautomation.com/index.php?/Knowledgebase/Article/View/98/2/importing-and-using-3rd-party-python-libraries-in-ignition)

So far so good. When I update the code in that library, the changes get applied automatically in the designer, and the clients ask for updates, which is perfect for my purpose. However, the update isn’t always cascading down to the bottom.

Referencing the external package directly works fine.
F.e. if I have a script that imports myPackage.myModule, and calls myPackage.myModule.myFunction(), when I modify the function in the library, and use the yellow bar to update the client, the most recent version of that function is executed.

But when I reference it through a shared script, it doesn’t get updated.
F.e. I define the functions as above, and create a “myModule” script under the shared scripts where I import the functions from myPackage (from myPackage.myModule import *), and I use them in a regular script as shared.myModule.myFunction().
When I now update the code of myFunction (still defined in the external package), the client does show the yellow upadate bar, but after an update keeps executing the old function code.

The ways to get around this is either to edit the script under “shared” to force a new update on the clients. Or to completely close a client and open it again.

Can someone give me some insights in the update model, and check if this is a bug or if there is some way in my code to get around it? We’re currently using version 7.9.1

1 Like

Apparently it’s also related to how the package gets imported.

Adding a new script to the package and importing it like “from myPackage import *” didn’t load it, but importing it as “from myPackage import myNewScript” did work.

Are there any best practices for the development of larger shared scripts (where things like syntax checking, source control and autocompletion are definitely wanted)?

1 Like