How to check if a variable is type BasicStreamingDataset

I have a named query in Perspective with the return format set to Dataset.

Using a script transform I am able to identify that the data type is:

com.inductiveautomation.ignition.gateway.datasource.BasicStreamingDataset

I would like to use the following script transform to return True / False however I always get the result False. Hence, a BasicStreamingDataset is not a BasicDataset. What do I need to compare against?

from com.inductiveautomation.ignition.common import BasicDataset
return isinstance(value, BasicDataset)

Thanks for any info.

Check against the Dataset interface, not any implementation.

1 Like

I don't understand what you mean here "check against the interface, not any implementation".

Why would a BasicStreamingDataset not be of type BasicDataset?

My real problem (XY problem - Wikipedia) is a value change script on the value property of my dropdown is being populated by the named query mentioned above which returns type dataset. What is happening is when my named query returns nothing or is invalid I get an error on that change script. I was investigating how to check for this condition in my value change script by trying different options in the script transform.

Both BasicDataset and BasicStreamingDataset are classes that implement the Dataset interface. That is, they each have the methods required by the interface, but execute them differently "under the hood". All of Ignition's dataset properties accept any implementation that follows the interface rules. All of Ignition's methods and functions that specify returning a Dataset can return any implementation that fits their needs. You should accept any implementation that follows the interface rules. Do that by checking isinstance(value, Dataset), not checking against a specific class.

This is exactly like checking basestring in python to accept either str or unicode types.

I see now. Is this the proper way to check against the interface?

Yes, but no need to alias.

from com.inductiveautomation.ignition.common import Dataset

would work just as well.

3 Likes