{"action":"closed","issue":{"url":"https://api.github.com/repos/ImageEngine/gaffer/issues/1081","labels_url":"https://api.github.com/repos/ImageEngine/gaffer/issues/1081/labels{/name}","comments_url":"https://api.github.com/repos/ImageEngine/gaffer/issues/1081/comments","events_url":"https://api.github.com/repos/ImageEngine/gaffer/issues/1081/events","html_url":"https://github.com/ImageEngine/gaffer/issues/1081","id":48586604,"number":1081,"title":"Serialization problems with Expression nodes","user":{"login":"davidsminor","id":3986762,"avatar_url":"https://avatars.githubusercontent.com/u/3986762?v=3","gravatar_id":"","url":"https://api.github.com/users/davidsminor","html_url":"https://github.com/davidsminor","followers_url":"https://api.github.com/users/davidsminor/followers","following_url":"https://api.github.com/users/davidsminor/following{/other_user}","gists_url":"https://api.github.com/users/davidsminor/gists{/gist_id}","starred_url":"https://api.github.com/users/davidsminor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidsminor/subscriptions","organizations_url":"https://api.github.com/users/davidsminor/orgs","repos_url":"https://api.github.com/users/davidsminor/repos","events_url":"https://api.github.com/users/davidsminor/events{/privacy}","received_events_url":"https://api.github.com/users/davidsminor/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ImageEngine/gaffer/labels/component-core","name":"component-core","color":"E6EBFF"},{"url":"https://api.github.com/repos/ImageEngine/gaffer/labels/type-bug","name":"type-bug","color":"FFE6E6"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ImageEngine/gaffer/milestones/41","html_url":"https://github.com/ImageEngine/gaffer/milestones/Geometry%20Instancing","labels_url":"https://api.github.com/repos/ImageEngine/gaffer/milestones/41/labels","id":889054,"number":41,"title":"Geometry Instancing","description":"To push instancing workflows at Image Engine","creator":{"login":"andrewkaufman","id":3979682,"avatar_url":"https://avatars.githubusercontent.com/u/3979682?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewkaufman","html_url":"https://github.com/andrewkaufman","followers_url":"https://api.github.com/users/andrewkaufman/followers","following_url":"https://api.github.com/users/andrewkaufman/following{/other_user}","gists_url":"https://api.github.com/users/andrewkaufman/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewkaufman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewkaufman/subscriptions","organizations_url":"https://api.github.com/users/andrewkaufman/orgs","repos_url":"https://api.github.com/users/andrewkaufman/repos","events_url":"https://api.github.com/users/andrewkaufman/events{/privacy}","received_events_url":"https://api.github.com/users/andrewkaufman/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":1,"state":"open","created_at":"2014-12-02T22:06:42Z","updated_at":"2015-03-24T17:32:28Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2014-11-13T01:25:44Z","updated_at":"2015-03-24T17:32:28Z","closed_at":"2015-03-24T17:32:28Z","body":"Hello,\r\n\r\nAn artist was having some problems saving and loading scripts containing expression nodes. Here are two test cases illustrating some problems I found:\r\n\r\n```\r\n\r\n\tdef testSerializationCreationOrder( self ) :\r\n\t\t\r\n\t\t# create a script where the expression node is created before the nodes it's targeting,\r\n\t\t# and make sure it serializes/loads correctly\r\n\t\ts = Gaffer.ScriptNode()\r\n\r\n\t\ts[\"e\"] = Gaffer.Expression()\r\n\t\t\r\n\t\ts[\"m1\"] = GafferTest.MultiplyNode()\r\n\t\ts[\"m1\"][\"op1\"].setValue( 10 )\r\n\t\ts[\"m1\"][\"op2\"].setValue( 20 )\r\n\r\n\t\ts[\"m2\"] = GafferTest.MultiplyNode()\r\n\t\ts[\"m2\"][\"op2\"].setValue( 1 )\r\n\t\t\r\n\t\ts[\"e\"][\"expression\"].setValue( \"parent[\\\"m2\\\"][\\\"op1\\\"] = parent[\\\"m1\\\"][\\\"product\\\"] * 2\" )\r\n\t\t\r\n\t\tss = s.serialise()\r\n\t\t\r\n\t\ts2 = Gaffer.ScriptNode()\r\n\t\t\r\n\t\t# If the Expression node's \"expression\" plug is set before the nodes it targets have been created\r\n\t\t# in the script, its updatePlugs() method will throw an exception. Because of that, its input/output\r\n\t\t# plugs won't exist later on in the script, and execution will fail:\r\n\t\t\r\n\t\ts2.execute( ss )\r\n\r\n\tdef testSerialisationPlugAccumulation( self ) :\r\n\r\n\t\ts = Gaffer.ScriptNode()\r\n\r\n\t\ts[\"n\"] = Gaffer.Node()\r\n\t\ts[\"n\"][\"user\"].addChild( Gaffer.FloatPlug( \"f\", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )\r\n\t\t\r\n\t\ts[\"e\"] = Gaffer.Expression()\r\n\t\ts[\"e\"][\"engine\"].setValue( \"python\" )\r\n\t\t\r\n\t\ts[\"e\"][\"expression\"].setValue( \"parent[\\\"n\\\"][\\\"user\\\"][\\\"f\\\"] = 2\" )\r\n\r\n\t\tself.assertEqual( s[\"n\"][\"user\"][\"f\"].getValue(), 2 )\r\n\t\t\r\n\t\tss = s.serialise()\r\n\r\n\t\ts2 = Gaffer.ScriptNode()\r\n\t\ts2.execute( ss )\r\n\t\t\r\n\t\tself.assertEqual( s[\"n\"][\"user\"][\"f\"].getValue(), 2 )\r\n\t\t\r\n\t\tself.failUnless( s2[\"e\"].getChild(\"out1\") is None )\r\n\t\tself.failUnless( s2[\"e\"].getChild(\"in1\") is None )\r\n\r\n```"}}