-
Notifications
You must be signed in to change notification settings - Fork 667
[DYN-1454] Unresolved nodes should attempt to be resolved when a new package is loaded #10011
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
336f9b8
First commit
reddyashish 514c1e0
Second commit
reddyashish 22d4d62
Check if the filename is null or empty
reddyashish 9b884d7
Adding test
reddyashish 9e87dbb
Triggering DependencyRegen event once all the dummy nodes in the work…
reddyashish be104b4
Remove extra line
reddyashish b8fc0d8
Addressing some comments
reddyashish f5ed4b6
some more comments
reddyashish 327e1dc
Addessing some more review comments.
reddyashish 056e001
Updating the test to check the value of the node after execution.
reddyashish 881ddbe
Moving some methods from DynamoModel to the DummyNode class.
reddyashish cc8a199
some more comments and changes.
reddyashish 5026867
Removing test
reddyashish 7e466b0
new check
reddyashish 584d669
Commenting out dependency regen event
reddyashish 2665c79
Adding back the test and the dll needed for the test.
reddyashish fd5b379
Modifying the test
reddyashish 083f763
Adding back the TriggerDependencyRegen method and disposing it when t…
reddyashish 54943c1
Adding the dispose method to prevent memory leaks.
reddyashish 3466c58
Updating comment
reddyashish 08c1b55
Adidng test for dummy nodes inside a custom node workspace and some c…
reddyashish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| using System.Collections.ObjectModel; | ||
| using System.ComponentModel; | ||
| using System.Diagnostics; | ||
| using System.Globalization; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Reflection; | ||
|
|
@@ -36,6 +37,8 @@ | |
| using DynamoServices; | ||
| using DynamoUnits; | ||
| using Greg; | ||
| using Newtonsoft.Json; | ||
| using Newtonsoft.Json.Linq; | ||
| using ProtoCore; | ||
| using ProtoCore.Runtime; | ||
| using Compiler = ProtoAssociative.Compiler; | ||
|
|
@@ -44,10 +47,6 @@ | |
| using FunctionGroup = Dynamo.Engine.FunctionGroup; | ||
| using Utils = Dynamo.Graph.Nodes.Utilities; | ||
|
|
||
| using Newtonsoft.Json; | ||
| using Newtonsoft.Json.Linq; | ||
| using System.Globalization; | ||
|
|
||
| namespace Dynamo.Models | ||
| { | ||
| /// <summary> | ||
|
|
@@ -732,6 +731,8 @@ protected DynamoModel(IStartConfiguration config) | |
|
|
||
| ResetEngineInternal(); | ||
|
|
||
| EngineController.VMLibrariesReset += ReloadDummyNodes; | ||
|
|
||
| AddHomeWorkspace(); | ||
|
|
||
| AuthenticationManager = new AuthenticationManager(config.AuthProvider); | ||
|
|
@@ -1037,6 +1038,8 @@ public void Dispose() | |
| LibraryServices.Dispose(); | ||
| LibraryServices.LibraryManagementCore.Cleanup(); | ||
|
|
||
| EngineController.VMLibrariesReset -= ReloadDummyNodes; | ||
|
|
||
| UpdateManager.Log -= UpdateManager_Log; | ||
| Logger.Dispose(); | ||
|
|
||
|
|
@@ -1715,6 +1718,78 @@ private bool OpenJsonFile( | |
| return true; | ||
| } | ||
|
|
||
| // Attempts to reload all the dummy nodes in the current workspace and replaces them with resolved version. | ||
| private void ReloadDummyNodes() | ||
| { | ||
| JObject dummyNodeJSON = null; | ||
| Boolean resolvedDummyNode = false; | ||
|
|
||
| WorkspaceModel currentWorkspace = this.CurrentWorkspace; | ||
|
|
||
| if (currentWorkspace == null || string.IsNullOrEmpty(currentWorkspace.FileName)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens if this is a customNode workspace? Have you tested that? I think we need a test for that case. |
||
| { | ||
| return; | ||
| } | ||
|
|
||
| // Get the dummy nodes in the current workspace. | ||
| var dummyNodes = currentWorkspace.Nodes.OfType<DummyNode>(); | ||
|
|
||
| foreach (DummyNode dn in dummyNodes) | ||
| { | ||
| dummyNodeJSON = dn.OriginalNodeContent as JObject; | ||
|
|
||
| if (dummyNodeJSON != null) | ||
| { | ||
| // Deserializing the dummy node and verifying if it is resolved by the downloaded or imported package | ||
| NodeModel resolvedNode = dn.GetNodeModelForDummyNode( | ||
| dummyNodeJSON.ToString(), | ||
| LibraryServices, | ||
| NodeFactory, | ||
| IsTestMode, | ||
| CustomNodeManager); | ||
|
|
||
| // If the resolved node is also a dummy node, then skip it else replace the dummy node with the resolved version of the node. | ||
| if (!(resolvedNode is DummyNode)) | ||
reddyashish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| // Disable graph runs temporarily while the dummy node is replaced with the resolved version of that node. | ||
| EngineController.DisableRun = true; | ||
aparajit-pratap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| currentWorkspace.RemoveAndDisposeNode(dn); | ||
| currentWorkspace.AddAndRegisterNode(resolvedNode, false); | ||
reddyashish marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Adding back the connectors for the resolved node. | ||
| List<ConnectorModel> connectors = dn.AllConnectors.ToList(); | ||
aparajit-pratap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| foreach (var connectorModel in connectors) | ||
| { | ||
| var startNode = connectorModel.Start.Owner; | ||
| var endNode = connectorModel.End.Owner; | ||
|
|
||
| if (startNode is DummyNode && startNode.GUID == resolvedNode.GUID) | ||
| { | ||
| startNode = resolvedNode; | ||
| } | ||
| if (endNode is DummyNode && endNode.GUID == resolvedNode.GUID) | ||
| { | ||
| endNode = resolvedNode; | ||
| } | ||
|
|
||
| connectorModel.Delete(); | ||
| ConnectorModel.Make(startNode, endNode, connectorModel.Start.Index, connectorModel.End.Index, connectorModel.GUID); | ||
| } | ||
| EngineController.DisableRun = false ; | ||
| resolvedDummyNode = true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (resolvedDummyNode) | ||
| { | ||
| currentWorkspace.HasUnsavedChanges = false; | ||
| // Once all the dummy nodes are reloaded, the DummyNodesReloaded event is invoked and | ||
| // the Dependency table is regenerated in the WorkspaceDependencyView extension. | ||
| currentWorkspace.OnDummyNodesReloaded(); | ||
| } | ||
| } | ||
|
|
||
| private bool OpenXmlFile(WorkspaceInfo workspaceInfo, XmlDocument xmlDoc, out WorkspaceModel workspace) | ||
| { | ||
| CustomNodeManager.AddUninitializedCustomNodesInPath( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
one thought I have about this is - is there a way to ensure we are transferring all view properties of the dummyNode - so we don't forget to update this if new view properties are added? Something like checking the ExtraNodeViewInfo object for all properties or something? This is not required - but something to think about.