-
Notifications
You must be signed in to change notification settings - Fork 636
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
Package B should not overwrite CustomNodes defined in Package A #9841
Conversation
fix tests pass PackageInfo around add PackageInfo to customNodeInfo class use it to throw exceptions change message when installing package that already is installed.
@@ -6,7 +6,7 @@ namespace Dynamo.Graph.Workspaces | |||
/// <summary> | |||
/// Class containing info about a package | |||
/// </summary> | |||
internal class PackageInfo | |||
public class PackageInfo |
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.
Good, we still end up making it public. Would you check if there is any internal available code we need to remove?
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.
will do.
public IEnumerable<CustomNodeInfo> AddUninitializedCustomNodesInPath(string path, bool isTestMode, PackageInfo packageInfo) | ||
{ | ||
var result = new List<CustomNodeInfo>(); | ||
foreach (var info in ScanNodeHeadersInDirectory(path, isTestMode)) |
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.
Without checking the function ScanNodeHeadersInDirectory
can you tell us a bit why testMode is needed 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.
so because this function results in loading something from disk, its needed to be passed down to the xml and json deserialization methods:
https://github.com/DynamoDS/Dynamo/blob/master/src/DynamoCore/Core/CustomNodeManager.cs#L601
eventually... it's used to fail tests, which is a good thing (instead of logging the exceptions like we do at runtime)
if (isTestMode) |
@mjkkirschner there are few other places where you need to make changes to account for the |
Aside from the comments above, looks good. Thanks @mjkkirschner |
finish removing test mode add new package
Some comments there, with Unit tests should look good |
Unfortunately during testing I found 2 issues-
1. Customnodes often have their info reset and loose the package info and member properties - this is because they use data from the workspace only - I’m looking at solutions for this and already have one, but I’d like to use the new logic added to package loader to check if the cn belongs to a package to be more accurate.
2. More cases to test - involving the transition from custom node to package member ie when publishing a package or version of a package.
… On Jul 13, 2019, at 1:08 AM, Aaron (Qilong) ***@***.***> wrote:
Some comments there, with Unit tests should look good
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
…Info objects use correct customNodeLoading method from Package object when publishing a package update test
Assert.AreEqual(2, nodeInstance.OutPorts.Count()); | ||
Assert.AreEqual("anewoutput", nodeInstance.OutPorts[1].Name); | ||
|
||
} |
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.
Nice test 👍
@aparajit-pratap @QilongTang - you may want to hang on before reviewing this again - I will redo my PR description as my thinking on this has changed a bit. |
@mjkkirschner given the new findings from your testing and the need to add these new events, I feel that adding the |
@aparajit-pratap - yep we can discuss more tomorrow, I do not think the path information alone gives us enough to make the correct determination, some examples:
Alot of these cases are tricky no matter if we use paths or packageInfo - the crux being that the tldr; |
…m node address some review comments add some tech debt test cases
if (newInfo.PackageInfo.Name != info.PackageInfo.Name) | ||
|
||
//only try to compare package info if both customNodeInfos have package info. | ||
if(info.IsPackageMember && info.PackageInfo != null) |
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.
Doesn't one being true mean the other is true - if IsPackageMember
is true, doesn't it imply that PackageInfo
is non-null or is this double check just to be safe?
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.
yes, it's just a double check, the second check should always be true if the first is true - but I wanted to verify.
|
||
Assert.AreEqual(new PackageInfo("PublishingACustomNodeSetsPackageInfoCorrectly", new Version(0,0,1)) | ||
,GetModel().CustomNodeManager.NodeInfos[cnworkspace.CustomNodeId].PackageInfo); | ||
Assert.IsFalse(GetModel().CustomNodeManager.NodeInfos[cnworkspace.CustomNodeId].IsPackageMember); |
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.
Is this not expected to be true?
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.
this is currently false, because the new package does not actually get loaded. - It just gets added to the list of loaded packages... not exactly the same thing. Thats why this one is tech debt, my expectations were not what I found.
this.CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(customNodeInstance); | ||
|
||
//load again. | ||
loader.LoadPackages(new Package[] { package1, package2 }); |
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 are you loading the packages again here? One of them is already loaded so it's not going to load again, is it? The following assertions are going to work even without this LoadPackages
call again, won't they?
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 want to try loading package2 again - after the customNodeInstance is placed - because this action resets the customNodeInfo to not include the package info - so I want to verify that loading package2 (which was not loaded the first time) - is still not loaded even after creating an instance of this custom 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 could be more explicit and not try to load package1 again for clarity.
LGTM! |
* remove testMode fix tests pass PackageInfo around add PackageInfo to customNodeInfo class use it to throw exceptions change message when installing package that already is installed. * add new tests finish removing test mode add new package * update test * update test and package json * try using package manger to keep packageInfo up to date on customNodeInfo objects use correct customNodeLoading method from Package object when publishing a package update test * add logging for different case to setInfo * update message for feedback when package overwrites non package custom node address some review comments add some tech debt test cases
Purpose
Updated:
After going back and forth with this for a few days my opinion is that we should move very slowly with this change because the customNodeManager and package loading logic is quite fragile and has many cases. Some of which are not well defined today. I think before we can change these we need to define them and the expected behavior.
Having said that here is what I'm proposing and what I have found.
I propose that at this time we only change one loading behavior to address the initial bug we identified using the
WorkspaceDependencyViewer
that one node could belong to two packages.After this PR:
If you try to load two conflicting packages you see this message(added by @aparajit-pratap ):
These are the only cases which are changed, and the only one that prevents loading is number 1. - I think this has low risk since most behaviors are unchanged, and provides some more information to help users understand what is being overwritten and by what.
These are the cases I was able to write automated tests for:
These are the cases I could not write tests for, but work in Dynamo:
These are cases that are not well defined or have surprising behavior that I am hesitant to change.
PackageInfo added to CustomNodeInfo
To handle these cases the
PackageInfo
class was made public and added to theCusotmNodeInfo
class as a property - this property is valid if the customNode was requested to be loaded as a consequence of some package being loaded.I found out that⚠️ I believe this is the information we absolutely must know to address case 1. (packages overwriting other packages) - To address this when
IsPackageMember
was never consistently set on the CustomNodeInfo -CustomNodeInfo
is set theCustomNodeManager
requests the packageManager return the owningPackage of the customNode if it exists, this is done with a dictionary lookup, so it is fast.Next we check the updated
info
is owned by a package, if it is, we check if the same package added the existingcustomNodeInfo
- if so, we update the info. If the existingInfo
has no package - we log a notification (the one above in case 2), and still load the package.The only case that throws, is case 1. Two different packages (tested by Name only) are trying to redefine the same
info
tested byGuid
.PR Also does the following:
TechDebt
that I hope we can address as we define the expected behavior of these other cases and eventually refactor CustomNodeManager / PackageLoader.Declarations
Check these if you believe they are true
*.resx
filesReviewers
(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)
(FILL ME IN, optional) Any additional notes to reviewers or testers.
FYIs
@aparajit-pratap @scottmitchell @QilongTang