Python Script Development in own IDE

Certain things are very easy to mock in an IDE. F.e. the DB functions are largely based on JDBC functionality. To mock tags, you can just use your own dictionaries and set/get methods. A logger can be a simple print, …

When you’ve implemented a few of those basic mock methods, it gets quite easy to test scripts against the Ignition API, without the chance to actually modify data inside Ignition.

Currently we’re even unit-testing our libraries using these mock methods.

We also have a small script to send files from our development environment to the Ignition server (just copying the files and checking for old files to delete). Then Ignition picks up those new files and just runs them. Exactly like saving a shared script.

For some scripts that interact deeply with Ignition, we still need to develop directly into ignition, but most logic can be taken out into external functions on external libraries.

PS. I don’t know why you need to import the PyDataSet and BasicDataset into that script you posted. If you mock the system.dataset.toDataSet and system.dataset.toPyDataSet to return something comparable, you already get a long way. Duck typing is a powerful thing in Python

3 Likes