-
Notifications
You must be signed in to change notification settings - Fork 635
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
Adding a new "IF" node that would simply return the truevalue or falsevalue based on the test condition. #11481
Adding a new "IF" node that would simply return the truevalue or falsevalue based on the test condition. #11481
Conversation
@reddyashish Is it possible for me to test this build? If so, please let me know how. Also, have you tested with |
@Amoursol Yes I have tested this with Empty lists and null values and it works as expected. You can pull in the changes from this branch and test it locally. |
Cool - I'll build and test! :) |
@Amoursol please note that this new node does not have lacing or partial function support. It differs from the old one in that the old one did have partial function support. We did not feel it was very useful for this node as the usage of the If node as a partial function seemed ambiguous. Please let us know if you have other thoughts. |
@aparajit-pratap - gotcha! I need to test to see if we do need Lacing or List@Level - both were direct requests from our users when requesting feedback here: https://forum.dynamobim.com/t/request-for-feedback-if-node/45257 My concern without implementing this would be we are in the same position at a later date, but I'll test to see if the use cases in that thread are covered. The two bugs that appear to be fixed in this are definitely a step in the right direction: Empty List control and various length True/False lists not having data truncated. |
If you're comparing this with the Clockwork node, I'd like to add that it is almost identical to that. Secondly, about replication and list-at-level, in order to make this node match with user expectation of its use, we needed to disable replication for the |
From that forum thread to me it sounds like users are confused as to what Lacing or List@Level can do to help in the context of this node. Whatever output they expect from the node can be achieved without those additions. |
If lacing or list-at-level support is required for this node for consistency sake, I think it might be possible to still add it, however, for partial function support, I think we might need a different approach where we create a special builtin function and call that from this node:
|
I've been busy all day so far, going to download the build and test today/tomorrow :) Just need to see what kind of data I can emulated from a messy Revit source. |
@@ -72,4 +74,44 @@ public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode | |||
}; | |||
} | |||
} | |||
|
|||
[NodeName("NewIf")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to rename it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to decide on the final name for this node. I have just added this name as a draft. Since, the old "IF" node still exists in the Dynamo library, we will need a different name for the node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean to ask if we can keep the same name for the new node while deprecating the old one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reddyashish @QilongTang I'm still not sure about this. To give an example, I introduced a new IntegerSlider64Bit
NodeModel
class but could keep the same name Integer Slider
for the node. I think we may be able to do something similar here so that new If
nodes have new behaviour but the same name. We might just have to figure out a way for old If
nodes to continue to deserialize as the old NodeModel class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aparajit-pratap what about if the old IF node actually has its name migrated to "replicating if" or "legacy if" and the new node becomes "If"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reddyashish I think you're getting confused. The old node will be hidden from the library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reddyashish - AFAIK @aparajit-pratap is correct that the use of the [obsolete]
attribute should hide the node - it's possible you need to use [NodeObsolete]
for that though - I know there is some discrepancy between zero touch and nodeModel nodes though - so watch out for that.
Maybe a good first step is to decide what should happen?
- should the original node be hidden, but still load when in an existing graph to stay backward compatible?
- If a user places a new node what should it be called?
- Is there any way to tell the difference between the old and new nodes in the same graph? (I assume the old ones will be in error state because of the obsolete attr - if it's working right?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, from a user perspective they want the following
@reddyashish - AFAIK @aparajit-pratap is correct that the use of the
[obsolete]
attribute should hide the node - it's possible you need to use[NodeObsolete]
for that though - I know there is some discrepancy between zero touch and nodeModel nodes though - so watch out for that.Maybe a good first step is to decide what should happen?
- should the original node be hidden, but still load when in an existing graph to stay backward compatible?
- If a user places a new node what should it be called?
- Is there any way to tell the difference between the old and new nodes in the same graph? (I assume the old ones will be in error state because of the obsolete attr - if it's working right?)
@mjkkirschner IMHO, from a user perspective:
- Yes this should happen
- It should simply be called "If" but reference the updated, new node.
- Is the error message obvious if we do this? Or will it simply say it's missing something? Ideally, users would understand that they need to replace that node. Would Copy + Paste of that node into the same place do the trick?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the code to hide the old "If" node from the library and rename the new one to have the same name. When the users open an old graph with the if node, it will behave like the old one(conditional if). Any new "If" node that will be placed will build on the new functionality. The [NodeObsolete] attribute can only be used for a method or a property and the [obsolete] attribute will throw a warning when the old "if" class is used in any of the code. It wouldn't throw an error on the Dynamo side. Do we want to throw an error or warning for the old "if" nodes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reddyashish Can we get a build of Dynamo including the NewIf node? That way we get get some feedback from users prior to merge. |
We can get a branch build out of this work for sure. Is this PR in a good state? If yes, we can merge into a feature branch and start from there |
@Amoursol Yes, we can get the branch build like Aaron suggested. I have added tests and this PR is pending review. Just need to figure out a proper name for this name. |
We can also crowd-source that name from the Forum with a testable build 😄 Can you let me know when you have a Branch build up? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one comment
Just waiting for the self-serve to confirm no regressions. |
|
Can we please get a working build to let users test against? We can put that into the forum thread and get direct feedback before merging the PR, as noted above in a previous comment :) |
@aparajit-pratap @Amoursol To get a build, we will need to merge it to a feature branch atleast. We will not be merging this to master yet as will do that after the feedback. What do you guys think? |
Changed the base to point to a new branch "RefactoredIfNode". |
Awesome. Are you able to create a Sandbox build for users to test please @reddyashish? |
@reddyashish Go for it. Let me know if you have any question in terms of creating branch build after merging into feature branch |
Ok, I thought this was ready to be merged into master. If this is going into a feature branch for some user testing, then that sounds good. |
* Adding a new "IF" node that would simply return the truevalue or falsevalue based on the test condition. (#11481) * attempt1 at creating partially applied function * change implementation of If NodeModel node * Move the functionality to a new if node that will be renamed. * Update IfTest.cs * Hiding the old If node and renaming to the new one to have the same name. * Throw a warning message when the old node is opened. * add comments. * Update the warning message and move it to the resources file. * Fix failing test Co-authored-by: Aparajit Pratap <[email protected]> * Add list level and lacing functionality to the new "If" node. (#11598) * Add lacing feature to the "If" node. * Addressing comments * additional comments * Move code into a private function. * Add tests for the new IF node. * Update one of the If tests. * Update the test. * Add the If node icon to the new node. * Changes to the Icon image * Update the IconUrl Co-authored-by: Aparajit Pratap <[email protected]>
Purpose
Task: https://jira.autodesk.com/browse/DYN-1976
This PR is made from the original one by @aparajit-pratap : #11464.
Created a new if node that would create a AST output for the following DS code
[t, f][cond ? 0 : 1];
We will have to figure out a new name for this node so that it would be clear to the users and can be found easily.
Added a test to verify the functionality of this new node.
The current if node can be removed in the next major version if we feel it would not be needed.
If the input condition has a list of boolean values then the output will be replicated based on the test input value.
Declarations
Check these if you believe they are true
*.resx
filesReviewers
@aparajit-pratap @QilongTang @mmisol @Amoursol @mjkkirschner