[Bug-1083]Perspective script not fully executing in client but does in Designer


I have a script that is creating the instances array of a flex repeater, but for god knows why, it executes fully in the Designer but not in the client…

def refreshOptions(self):
	Custom method that can be invoked directly on this component.

		self: A reference to the component that is invoking this function.
	self.props.instances = []
	self.props.instances = [{'optionLabel':1}]
	options_raw = self.custom.options_raw
	self.props.instances = [{'optionLabel':'2a'}] # <-- here
	options_raw = system.dataset.toPyDataSet(options_raw)
	options = []
	self.props.instances = [{'optionLabel':3}]
        ## blah blah
        ## ....
	for i, option_raw in enumerate(options_raw):
		option = {'optionValue': option_raw['Value'],
			  	  'optionLabel': option_raw['Label'],
				  'selectTagPath': self.view.params.selectTagPath}
		# this uses the "Available" field in the available dataset passed in
		if hasAvail:
			avail = option_raw['Available']
			option['available'] = avail
			option['availableBit'] = ''
			option['availableTagPath'] = ''
		# this uses the Available Bit
		elif hasAvailBit:
			avail = option_raw['AvailableBit'] if hasAvailBit else 1
			option['available'] = ''
			option['availableBit'] = avail
			option['availableTagPath'] = self.view.params.availableTagPath
	self.props.instances = [{'optionLabel':8}]
	self.props.instances = options
	self.props.instances = [{'optionLabel':'DONE'}]

I trigger this manually at the moment, and in the Designer I see the ‘DONE’ appear in my flex repeater, but I see ‘2a’ appear in the client, indicating that it’s only getting to line 4 before giving up??

Any ideas? I’ve spent far too long on this…



This is my dataset options_raw:


Ok, so it works if I don’t pass the dataset into the popup… even though I can see that the dataset gets properly passed into the popup if I included it… (I added a table component and bound its data to the dataset param I pass in)??

Where’s the pulling out hair emoticon?

If I write the dataset to a session custom prop and reference that within the popup, it works.

I figured you shouldn’t pass too much data to a popup, but I didn’t think a dataset with 24 rows max by 3 cols would be enough to max it out

1 Like

No answer for you but I too have trouble with perspective scripts modifying components as well and may have an explanation. If I had to guess it’s due to the architecture. IIRC everything in Perspective technically runs on the gateway (because browsers can’t/don’t interpret python), so the client has to talk to the gateway, the gateway runs your refreshOptions, and then the gateway tries to update your page. I’d guess somewhere in between there is some lapse in communicatiion,

When you are testing in designer however, I do not believe the execution is the same as I just described. The designer environment is slightly different from clients (for both vision and perspective) so I am making an educated guess there’s no round trip of data going on when you are testing it in your designer, your designer runs the script and gives the results back immediately, but with the client you have a round trip and now you have different potholes that can arise.

You are not alone in perspective making you want to pull your hair out I am right there with ya. I understand that React is the hot new js technology for single page apps but it introduces new problems as well.

Idk maybe I am getting jaded but the longer I’ve developed web tech, the more I yearn to go back to simple server side rendering of HTML/CSS/JS like flask/jinja or django.

In my experience as well I have scripted pages that worked perfectly in designer but once they were deployed and tested on clients, I ran into all types of issues as well. I think the simpler the page the better. The more scripts you have, and the more scripts you have that trigger other scripts on the same page via value changes or w/e and things start to get really sweaty.

While true that the design environment is not a perfect simulacra of the live environment, there is very much still a round trip happening - having scripts run on the designer ‘locally’ would make things even worse for Perspective development, in fact.

Well, the Webdev module is certainly available to you :slight_smile:
Ironically, React isn’t even ‘hot new technology’ - at this point it’s considered slightly stale.

1 Like

Interesting. I was just making my best educated guess on why thigns seem to work better in designer for perspsetive.

Good point about the web dev module, I might have to bring that up with an upcoming project we have.

The pace at which new JS libraries and frameworks come out, if something is older than a month it is considered stale :rofl:

You’re encountering a known issue with popups where the dataset is not encoded properly. Did you look at your gateway logs after trying to execute this script in a session? You should see an error becuase the dataset is being interpreted as a com.inductiveautomation.perspective.gateway.script.DotReferenceJythonMap instead of a dataset. You can either convert the dataset to an array or object before sending it to the popup, or you can wait on a fix.

1 Like

I didn't check the logs, but will do. I'll convert to an array of dicts for now, cheers! That session prop was uuuugglee

I am not getting that error in the log but the dataset I am passing in to a popup is certainly being corrupted. Before the pass it is a dataset and after the pass it looks something like json. And of course this only happens in the client.

Actually, it is a dictionary and if I tell it to use value[“rows”] I can get it to work in the client. Of course then it is broken in designer…

This was resolved as part of the 8.1.4 release.

1 Like