Page 1 of 1

Unable to set a temporary attribute

Posted: Thu Mar 30, 2023 10:59 pm
by Jack Harich
This is a two-hour puzzle. See News Org action G5_2 Create News Org MMs. The value of Invoker.temp PoliticianID is never set, as seen in the News Orgs results table. This causes many warnings.

Compare this to Voter action G3_1 Create Politician Comparison which also sets a temporary attribute value, in almost the exact same manner.

I’m using lots of temporary variables, since Ventity triggers and actions appear to have no equivalent of passing arguments in a function call. This creates a lot of clutter. Is there a better way? Thanks.

Re: Unable to set a temporary attribute

Posted: Thu Mar 30, 2023 11:08 pm
by tomfid
I think this may have been saved before the invoker attribute surrogate was defined, because for me there's nothing on the action view except a local attribute, "source type". What should the temp ID be set to?

Re: Unable to set a temporary attribute

Posted: Fri Mar 31, 2023 12:51 am
by Jack Harich
Thanks. Are we looking at the same diagram? "source type" is nowhere on News Org action G5_2 Create News Org MMs. See the image.

The especially odd thing is temp politician truthfulness IS being set.
PostCreateNewsOrgsMMs.png
PostCreateNewsOrgsMMs.png (45.11 KiB) Viewed 5422 times

Re: Unable to set a temporary attribute

Posted: Fri Mar 31, 2023 1:17 am
by tomfid
Is it a key? You can't change a key.

Re: Unable to set a temporary attribute

Posted: Fri Mar 31, 2023 1:25 am
by Jack Harich
No, and it refers to none. It is indeed a puzzle, a head scratcher, and an enigma! I also tried setting it with a shadow variable.

Re: Unable to set a temporary attribute

Posted: Fri Mar 31, 2023 1:55 am
by Jack Harich
We have a clue. See the table for Media Meme. Action G5_2 Create News Org MMs calls action G5_3 Create News Org MMs for One Politician, which adds five records to Media Meme, all for the same politician. Only the first has Politician set. The rest are empty. Is it possible that Ventity is somehow losing the value of temp PoliticianID after the first of five calls?
PostResultsTableMediaMeme_Every fifth Politician is set.png
PostResultsTableMediaMeme_Every fifth Politician is set.png (53.96 KiB) Viewed 5416 times

Re: Unable to set a temporary attribute

Posted: Fri Mar 31, 2023 11:51 am
by Jack Harich
A small question. What is the logical operator for "or"? The one for and is "&&".

Re: Unable to set a temporary attribute

Posted: Fri Mar 31, 2023 2:05 pm
by tomfid
or = ||

Generally boolean syntax is c-like: &&, II, !=, == but we permit a single = and <> too.

Re: Unable to set a temporary attribute

Posted: Fri Mar 31, 2023 6:02 pm
by tomfid
Problem could be that you're using surrogates where you need references. Rule of thumb should be, if you're not changing an attribute, use a reference. Easiest way to change it is to edit the downstream equation, change the bullet to a dot, then use the right click method to add the referenced var, and delete the surrogate from the model.

Re: Unable to set a temporary attribute

Posted: Fri Mar 31, 2023 6:25 pm
by tomfid
Another thing I notice is that there's an undeleted parent surrogate that's not on the diagram (probably inadvertent use of delete key).
rdem97.png
rdem97.png (131.5 KiB) Viewed 5376 times

Re: Unable to set a temporary attribute

Posted: Fri Mar 31, 2023 7:50 pm
by Jack Harich
Thanks once again. I appreciate your style, showing and explaining the problems you find, rather than solving the problem. That maximizes learning!

I noticed you had shadow variables and my version of the model didn't. First I deleted two undeleted items. This made almost no difference, still got about 170 warnings. Then I started changing attributes to shadows. On G5_3 Create News Org MMs for One Politician, changing Invoker (large dot) temp politicianID to little dot with a shadow eliminated all warnings. Wow.

If use of a non-shadow causes the framework to misbehave, it seems to me it would be extremely helpful to say so in the warnings. Instead, all it says is "Unable to reference Entity Type [politician] from belief_meme [belief_meme[belief_meme_0108]] using Attribute [Politician]". This problem happens much later than what this action is doing. Thanks!

Re: Unable to set a temporary attribute

Posted: Fri Mar 31, 2023 8:55 pm
by tomfid
I'm not sure if the change in notation is causing fewer warnings because of some property of surrogate vs. reference, or because the result is fewer undefined reference attributes around, but I'll look into it.

I think the underlying problem is that the interface steers you to use of surrogates where references would be more appropriate. I've ticketed this for an improvement.