Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary Expressions deleted by live runner make their first input symbols null. #10512

Merged
merged 5 commits into from
Apr 2, 2020

Conversation

mjkkirschner
Copy link
Member

@mjkkirschner mjkkirschner commented Mar 27, 2020

Purpose

When a binary expression is deleted by the live runner - the binary AST is walked and all binary expressions within that subtree are assigned to null...

the change was from:
#7282

The behavior before this PR was that top level binary expressions were assigned to null and no AST walking was done.

I'm guessing @ke-yu was trying to support multiple assignments like:
a = 3;
b = a;
all being set to null.

but the consequence was other binary expressions like
a && b end up resulting in this a = null

I'm opening this PR for feedback because I'm not clear on what binary expressions should actually be set to null, only assignments? Right now I am only stopping OR and AND - since that effects this particular bug, but I don't think thats the whole story.
all good.
Screen Shot 2020-03-27 at 5 41 04 PM
still good!
Screen Shot 2020-03-27 at 5 41 07 PM

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.

@mjkkirschner mjkkirschner changed the title Binary Expressions deleted by live runner make their first input symbols null. FEEDBACK Binary Expressions deleted by live runner make their first input symbols null. Mar 27, 2020
Copy link
Contributor

@aparajit-pratap aparajit-pratap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjkkirschner I didn't realize this was submitted only in 2.0 but you're right, this is the breaking change. Good find!

The reason why only the UI nodes (for logic operators) cause the issue and not the && or || node (neither the operators used in a CBN), is because in the latter cases, the expression is actually a function call (in order to support replication) and in the case of the UI nodes, we are specifically building a binary expression AST:

AstFactory.BuildBinaryExpression(node, current, _op)))

For the same reason, replication doesn't work for And and Or UI nodes as we are not building function call ASTs. I can therefore think of a couple of ways to solve this:

  1. Change the BuildOutputAST method to generate function calls for the logic UI nodes instead of binary exp. ASTs. Doing this will fix this issue and also enable replication to work for these nodes thereby making them consistent with the other ways of using these operators.
  2. Revert @ke-yu's change to walk the AST in BuildNullAssignments - in other words, just assign the top-level expression to null OR
  3. Leave BuildNullAssignments as it is, just add a check here to specifically check if the binary exp. AST is an assignment - meaning assign it to null only if it is an assignment expression, not otherwise.

ignore all expressions which are not assigments in the nullifyBinaryExpression code
@mjkkirschner
Copy link
Member Author

@aparajit-pratap please take another look, went with your third suggestion and added 2 tests. I still need to run the self serve to see if it breaks anything.

@mjkkirschner mjkkirschner changed the title FEEDBACK Binary Expressions deleted by live runner make their first input symbols null. Binary Expressions deleted by live runner make their first input symbols null. Apr 1, 2020
@mjkkirschner mjkkirschner added PTAL Please Take A Look 👀 and removed WIP labels Apr 1, 2020
@mjkkirschner
Copy link
Member Author

mjkkirschner commented Apr 2, 2020

@aparajit-pratap unfortunately, a bunch of failures in self serve, looking into it. - Think I got it now, was missing latest fixes on master.

@aparajit-pratap
Copy link
Contributor

Curious, what did you think about making the UI logic nodes support replication?

@@ -982,7 +983,7 @@ private List<BinaryExpressionNode> BuildNullAssignments(List<AssociativeNode> as
}

IdentifierNode leftNode = bNode.LeftNode as IdentifierNode;
if (leftNode == null || leftNode.ArrayDimensions != null)
if (leftNode == null || leftNode.ArrayDimensions != null || bNode.Optr != Operator.assign)
Copy link
Contributor

@aparajit-pratap aparajit-pratap Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but why not have this check on line 980?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, that seems like a more appropriate place, where the binary node is validated, I can move it.

@mjkkirschner
Copy link
Member Author

mjkkirschner commented Apr 2, 2020

Curious, what did you think about making the UI logic nodes support replication?

I thought that could get very difficult because the ZT versions only support two inputs and the UI ones support more than 2 - so I believe we'd end up doing binary expressions anyway - we could do both though? This fix and also the change to UI nodes?

@@ -852,6 +852,93 @@ public void GraphILTest_DeletedNode01()

}

[Test]
public void GraphILTest_DeletedBinaryExpresionDoesNotEffectReferences()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effectively this test is simulating the same thing that would happen in the Dynamo UI when running the graph, deleting the node, and rerunning it or is it testing something additionally?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simulating the same thing as in the UI - I verified it failed before this change.

@aparajit-pratap
Copy link
Contributor

I thought that could get very difficult because the ZT versions only support two inputs and the UI ones support more than 2 - so I believe we'd end up doing binary expressions anyway - we could do both though? This fix and also the change to UI nodes?

Probably that's something to think about for later, add to the backlog maybe? For now, I think this fix looks good.

@aparajit-pratap aparajit-pratap added the LGTM Looks good to me label Apr 2, 2020
@mjkkirschner
Copy link
Member Author

@aparajit-pratap the self serve and parallel tests all pass, gonna merge this in.

@mjkkirschner mjkkirschner removed the PTAL Please Take A Look 👀 label Apr 2, 2020
@mjkkirschner mjkkirschner merged commit 6ce8ce7 into DynamoDS:master Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LGTM Looks good to me
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants