Some Project Resources not publishing

I’m having an issue with ignition where when I save and publish resources not all resources are being pushed to the client. Currently we have a shared script that runs on a global timer event, pulls plex workcenter information from 2 plants and a test database, and writes that information to a global dataset tag that we pull from to get current workcenter status and other info. The script was working good for over a month, until two days ago I got an error on the shared script, when I looked at the code it had changed.
After fixing the errors in the code saving it, then publishing again, the error never goes away, even if I completely remove the script from the project and save/publish again. I’ve tried clearing the local client java cache and it still gives the same error.

First, make sure you’re on the latest version of Ignition. If you are, please let support know about this right away because obviously this is something that needs to be fixed immediately.

This may be a side-effect of the fact that Ignition doesn’t/can’t track the usage and retention of python code objects throughout the gateway. This means that when your script modules have interlocking dependencies, updating one script won’t impact the code objects that other scripts have imported. You may need to make a trivial change in all of your scripts and save them all together to get it to “take”. You may also need to disable then re-enable the entire project. Consider renaming the offending class/function and having all code call the (fixed) new name.

Some practices to consider:

  • Avoid using import with any shared or project script. Use the full name everywhere, which will get the latest code version as long as that name hasn’t been imported.
  • Avoid using shared scripts for anything that isn’t extremely well-tested and unchanging, especially if python classes are being instantiated. It is relatively safe to add new functions and classes to existed shared scripts.
  • The above means you should also be avoiding tag events, as they cannot call project scripts. Use tag change events instead.
  • Gateway event scripts are defined in a project, so use that project to contain the corresponding script modules. When there is a need to call some of its code from another project, take care to factor out the simplest and best-tested parts to move to shared scripts.
  • If you are storing persistent python objects in system.util.getGlobals() and/or using system.util.invokeAsynchronous() for long-running tasks, you must implement some mechanism to replace the old code objects and kill off the old versions of background functions.
3 Likes

Thank you all of this was helpful.
We ended up renaming the function on the global script and updating the elements that called the old function name to call the new function name, and it fixed the issue.

1 Like