Skip to content

Commit

Permalink
DYN-6769 improving dynamo load graph ii 2 (#15158)
Browse files Browse the repository at this point in the history
* DYN-6769 Improving Dynamo Load Graph II (#15108)

* DYN-6769 Improving Dynamo Load Graph

With this change only will be executing the DefaultAutocompleteCandidates functionality only once at Dynamo startup and when a graph is loaded won't be executed anymore.

* DYN-6769 Improving Dynamo Load Graph

With this change only will be executing the DefaultAutocompleteCandidates functionality only once at Dynamo startup and when a graph is loaded won't be executed anymore.

* DYN-6769 Improving Dynamo Load Graph II - 2

Instead of using a static Dictionary now I will be using a normal instance that will be initialized in DynamoViewModel and pass it to NodeAutoCompleteSearchViewModel, in this case we are also confirming that only be executed once.

* DYN-6769 Improving Dynamo Load Graph II - 2

Disabling the DefaultNodeAutocomplete functionality when Dynamo is in ServiceMode.

* DYN-6769 Improving Dynamo Load Graph II

Marking the test RemovePIIDataFromWorkspace as Failure
  • Loading branch information
RobertGlobant20 authored Apr 24, 2024
1 parent 79ecacb commit 50627dd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
29 changes: 29 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public partial class DynamoViewModel : ViewModelBase, IDynamoViewModel

internal DynamoMLDataPipelineExtension MLDataPipelineExtension { get; set; }

internal Dictionary<string, NodeSearchElementViewModel> DefaultAutocompleteCandidates;

/// <summary>
/// Collection of Right SideBar tab items: view extensions and docked windows.
/// </summary>
Expand Down Expand Up @@ -695,6 +697,28 @@ public struct StartConfiguration
return new DynamoViewModel(startConfiguration);
}

private void SearchDefaultNodeAutocompleteCandidates()
{
var tempSearchViewModel = new SearchViewModel(this)
{
Visible = true
};
DefaultAutocompleteCandidates = new Dictionary<string, NodeSearchElementViewModel>();

// TODO: These are basic input types in Dynamo
// This should be only served as a temporary default case.
var queries = new List<string>() { "String", "Number Slider", "Integer Slider", "Number", "Boolean", "Watch", "Watch 3D", "Python Script" };
foreach (var query in queries)
{
var foundNode = tempSearchViewModel.Search(query).Where(n => n.Name.Equals(query)).FirstOrDefault();
if (foundNode != null)
{
DefaultAutocompleteCandidates.Add(foundNode.Name, foundNode);
}
}
tempSearchViewModel.Dispose();
}

protected DynamoViewModel(StartConfiguration startConfiguration)
{
// CurrentDomain_UnhandledException - catches unhandled exceptions that are fatal to the current process. These exceptions cannot be handled and process termination is guaranteed
Expand Down Expand Up @@ -734,6 +758,11 @@ protected DynamoViewModel(StartConfiguration startConfiguration)

//add the initial workspace and register for future
//updates to the workspaces collection
if(!Model.IsServiceMode)
{
SearchDefaultNodeAutocompleteCandidates();
}

var homespaceViewModel = new HomeWorkspaceViewModel(model.CurrentWorkspace as HomeWorkspaceModel, this);
workspaces.Add(homespaceViewModel);
currentWorkspaceViewModel = homespaceViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public bool DisplayLowConfidence
internal NodeAutoCompleteSearchViewModel(DynamoViewModel dynamoViewModel) : base(dynamoViewModel)
{
// Off load some time consuming operation here
InitializeDefaultAutoCompleteCandidates();
DefaultResults = dynamoViewModel.DefaultAutocompleteCandidates.Values;
ServiceVersion = string.Empty;
}

Expand All @@ -179,23 +179,6 @@ internal void ResetAutoCompleteSearchViewState()
searchElementsCache = new List<NodeSearchElementViewModel>();
}

private void InitializeDefaultAutoCompleteCandidates()
{
var candidates = new List<NodeSearchElementViewModel>();
// TODO: These are basic input types in Dynamo
// This should be only served as a temporary default case.
var queries = new List<string>(){"String", "Number Slider", "Integer Slider", "Number", "Boolean", "Watch", "Watch 3D", "Python Script"};
foreach (var query in queries)
{
var foundNode = Search(query).Where(n => n.Name.Equals(query)).FirstOrDefault();
if(foundNode != null)
{
candidates.Add(foundNode);
}
}
DefaultResults = candidates;
}

internal MLNodeAutoCompletionRequest GenerateRequestForMLAutocomplete()
{
// Initialize request for the the ML API
Expand Down
2 changes: 1 addition & 1 deletion test/DynamoCoreWpfTests/WorkspaceSaving.cs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public void CanSaveAsNewWorkspaceWithNewGuids()
}

[Test]
[Category("UnitTests")]
[Category("Failure")]
public void RemovePIIDataFromWorkspace()
{
string graphWithPIIDataPath = Path.Combine(TestDirectory, (@"UI\GraphWithPIIData.dyn"));
Expand Down

0 comments on commit 50627dd

Please sign in to comment.