From 8186fc4b246d977812524f4a5972faa927d99a24 Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" <173288704@qq.com> Date: Mon, 5 Feb 2024 13:47:21 -0500 Subject: [PATCH 1/7] first commit --- src/DynamoCore/Models/DynamoModel.cs | 2 +- .../ViewModels/Menu/PreferencesViewModel.cs | 11 +++++++++++ src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/DynamoCore/Models/DynamoModel.cs b/src/DynamoCore/Models/DynamoModel.cs index 27713cb10e3..e8a63732c79 100644 --- a/src/DynamoCore/Models/DynamoModel.cs +++ b/src/DynamoCore/Models/DynamoModel.cs @@ -1719,7 +1719,7 @@ private void InitializePreferences() if (PreferenceSettings != null) { ProtoCore.Mirror.MirrorData.PrecisionFormat = DynamoUnits.Display.PrecisionFormat = PreferenceSettings.NumberFormat; - PreferenceSettings.InitializeNamespacesToExcludeFromLibrary(); + // PreferenceSettings.InitializeNamespacesToExcludeFromLibrary(); if (string.IsNullOrEmpty(PreferenceSettings.BackupLocation)) { diff --git a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs index 9e74bb37fdd..bf5c38dd2b3 100644 --- a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs @@ -1121,6 +1121,17 @@ public bool NodeAutocompleteMachineLearningIsBeta } } + /// + /// Controls if the the Node autocomplete Machine Learning option is beta from feature flag + /// + public bool IsTSplineNodesExperimentToggleVisible + { + get + { + return DynamoModel.FeatureFlags?.CheckFeatureFlag("NodeAutocompleteMachineLearningIsBeta", true) ?? false; + } + } + /// /// Contains the numbers of result of the ML recommendation /// diff --git a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml index 4d058c95b7d..2a30adf8421 100644 --- a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml +++ b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml @@ -1023,7 +1023,10 @@ - + Date: Mon, 5 Feb 2024 16:22:49 -0500 Subject: [PATCH 2/7] Add feature flag based list initial value manipulation --- src/DynamoCore/Configuration/PreferenceSettings.cs | 10 +++++++++- src/DynamoCore/Models/DynamoModel.cs | 2 +- .../ViewModels/Menu/PreferencesViewModel.cs | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/DynamoCore/Configuration/PreferenceSettings.cs b/src/DynamoCore/Configuration/PreferenceSettings.cs index a07ec1fd5e3..ab7e4dd6a68 100644 --- a/src/DynamoCore/Configuration/PreferenceSettings.cs +++ b/src/DynamoCore/Configuration/PreferenceSettings.cs @@ -1141,8 +1141,16 @@ internal static string GetDefaultPythonEngine() return defaultPythonEngine; } - internal void InitializeNamespacesToExcludeFromLibrary() + internal void InitializeNamespacesToExcludeFromLibrary(bool isTSplineNodesExperimentToggleVisible) { + // When the experiment toggle is disabled by feature flag, include the TSpline namespace from the library OOTB. + if (!isTSplineNodesExperimentToggleVisible) + { + NamespacesToExcludeFromLibrary.Remove( + "ProtoGeometry.dll:Autodesk.DesignScript.Geometry.TSpline" + ); + return; + } if (!NamespacesToExcludeFromLibrarySpecified) { NamespacesToExcludeFromLibrary.Add( diff --git a/src/DynamoCore/Models/DynamoModel.cs b/src/DynamoCore/Models/DynamoModel.cs index e8a63732c79..7bc15aa9198 100644 --- a/src/DynamoCore/Models/DynamoModel.cs +++ b/src/DynamoCore/Models/DynamoModel.cs @@ -1719,7 +1719,7 @@ private void InitializePreferences() if (PreferenceSettings != null) { ProtoCore.Mirror.MirrorData.PrecisionFormat = DynamoUnits.Display.PrecisionFormat = PreferenceSettings.NumberFormat; - // PreferenceSettings.InitializeNamespacesToExcludeFromLibrary(); + PreferenceSettings.InitializeNamespacesToExcludeFromLibrary(DynamoModel.FeatureFlags?.CheckFeatureFlag("IsTSplineNodesExperimentToggleVisible", false) ?? false); if (string.IsNullOrEmpty(PreferenceSettings.BackupLocation)) { diff --git a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs index bf5c38dd2b3..709e60b2748 100644 --- a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs @@ -1128,7 +1128,7 @@ public bool IsTSplineNodesExperimentToggleVisible { get { - return DynamoModel.FeatureFlags?.CheckFeatureFlag("NodeAutocompleteMachineLearningIsBeta", true) ?? false; + return DynamoModel.FeatureFlags?.CheckFeatureFlag("IsTSplineNodesExperimentToggleVisible", false) ?? false; } } From 28c4cc2dcbe34bccba9fa0226ecf042f670fc24b Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" Date: Mon, 5 Feb 2024 16:30:50 -0500 Subject: [PATCH 3/7] Comments --- src/DynamoCore/Configuration/PreferenceSettings.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/DynamoCore/Configuration/PreferenceSettings.cs b/src/DynamoCore/Configuration/PreferenceSettings.cs index ab7e4dd6a68..e7cb4cd6e2a 100644 --- a/src/DynamoCore/Configuration/PreferenceSettings.cs +++ b/src/DynamoCore/Configuration/PreferenceSettings.cs @@ -1141,6 +1141,10 @@ internal static string GetDefaultPythonEngine() return defaultPythonEngine; } + /// + /// Initialize namespaces to exclude from Library based on conditions + /// + /// indicates if the experiment toggle is visible under feature flag internal void InitializeNamespacesToExcludeFromLibrary(bool isTSplineNodesExperimentToggleVisible) { // When the experiment toggle is disabled by feature flag, include the TSpline namespace from the library OOTB. From 2a65da00df7a2cc10466c4af0af07d0141f7a8c1 Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" Date: Tue, 6 Feb 2024 17:11:43 -0500 Subject: [PATCH 4/7] Updates --- src/DynamoCore/Configuration/PreferenceSettings.cs | 5 ++--- src/DynamoCore/Models/DynamoModel.cs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/DynamoCore/Configuration/PreferenceSettings.cs b/src/DynamoCore/Configuration/PreferenceSettings.cs index e7cb4cd6e2a..3cf7d75fa52 100644 --- a/src/DynamoCore/Configuration/PreferenceSettings.cs +++ b/src/DynamoCore/Configuration/PreferenceSettings.cs @@ -1144,11 +1144,10 @@ internal static string GetDefaultPythonEngine() /// /// Initialize namespaces to exclude from Library based on conditions /// - /// indicates if the experiment toggle is visible under feature flag - internal void InitializeNamespacesToExcludeFromLibrary(bool isTSplineNodesExperimentToggleVisible) + internal void InitializeNamespacesToExcludeFromLibrary() { // When the experiment toggle is disabled by feature flag, include the TSpline namespace from the library OOTB. - if (!isTSplineNodesExperimentToggleVisible) + if (!DynamoModel.FeatureFlags?.CheckFeatureFlag("IsTSplineNodesExperimentToggleVisible", false) ?? false) { NamespacesToExcludeFromLibrary.Remove( "ProtoGeometry.dll:Autodesk.DesignScript.Geometry.TSpline" diff --git a/src/DynamoCore/Models/DynamoModel.cs b/src/DynamoCore/Models/DynamoModel.cs index 7bc15aa9198..27713cb10e3 100644 --- a/src/DynamoCore/Models/DynamoModel.cs +++ b/src/DynamoCore/Models/DynamoModel.cs @@ -1719,7 +1719,7 @@ private void InitializePreferences() if (PreferenceSettings != null) { ProtoCore.Mirror.MirrorData.PrecisionFormat = DynamoUnits.Display.PrecisionFormat = PreferenceSettings.NumberFormat; - PreferenceSettings.InitializeNamespacesToExcludeFromLibrary(DynamoModel.FeatureFlags?.CheckFeatureFlag("IsTSplineNodesExperimentToggleVisible", false) ?? false); + PreferenceSettings.InitializeNamespacesToExcludeFromLibrary(); if (string.IsNullOrEmpty(PreferenceSettings.BackupLocation)) { From 5ec597ae7b090534198d179c6b5517da460c2838 Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" Date: Tue, 6 Feb 2024 17:23:02 -0500 Subject: [PATCH 5/7] Update --- src/DynamoCore/Configuration/PreferenceSettings.cs | 2 +- src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DynamoCore/Configuration/PreferenceSettings.cs b/src/DynamoCore/Configuration/PreferenceSettings.cs index 3cf7d75fa52..d9e836d36d2 100644 --- a/src/DynamoCore/Configuration/PreferenceSettings.cs +++ b/src/DynamoCore/Configuration/PreferenceSettings.cs @@ -1147,7 +1147,7 @@ internal static string GetDefaultPythonEngine() internal void InitializeNamespacesToExcludeFromLibrary() { // When the experiment toggle is disabled by feature flag, include the TSpline namespace from the library OOTB. - if (!DynamoModel.FeatureFlags?.CheckFeatureFlag("IsTSplineNodesExperimentToggleVisible", false) ?? false) + if (!DynamoModel.FeatureFlags?.CheckFeatureFlag("IsTSplineNodesExperimentToggleVisible", false) ?? true) { NamespacesToExcludeFromLibrary.Remove( "ProtoGeometry.dll:Autodesk.DesignScript.Geometry.TSpline" diff --git a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs index 709e60b2748..7dcf38a58f5 100644 --- a/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs @@ -1122,7 +1122,7 @@ public bool NodeAutocompleteMachineLearningIsBeta } /// - /// Controls if the the Node autocomplete Machine Learning option is beta from feature flag + /// Controls if the TSpline nodes experiment toggle is visible from feature flag /// public bool IsTSplineNodesExperimentToggleVisible { From dedd8d1cb1ce544c28213454258319158ed7836c Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" Date: Wed, 7 Feb 2024 16:23:53 -0500 Subject: [PATCH 6/7] Add event based TSplineNodes show/hide --- .../Configuration/PreferenceSettings.cs | 21 ++++++++++++------- src/DynamoCore/Models/DynamoModel.cs | 14 ++++++++++++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/DynamoCore/Configuration/PreferenceSettings.cs b/src/DynamoCore/Configuration/PreferenceSettings.cs index d9e836d36d2..aa1e3e8b8d1 100644 --- a/src/DynamoCore/Configuration/PreferenceSettings.cs +++ b/src/DynamoCore/Configuration/PreferenceSettings.cs @@ -1146,20 +1146,27 @@ internal static string GetDefaultPythonEngine() /// internal void InitializeNamespacesToExcludeFromLibrary() { - // When the experiment toggle is disabled by feature flag, include the TSpline namespace from the library OOTB. - if (!DynamoModel.FeatureFlags?.CheckFeatureFlag("IsTSplineNodesExperimentToggleVisible", false) ?? true) + if (!NamespacesToExcludeFromLibrarySpecified) { - NamespacesToExcludeFromLibrary.Remove( + NamespacesToExcludeFromLibrary.Add( "ProtoGeometry.dll:Autodesk.DesignScript.Geometry.TSpline" ); - return; + NamespacesToExcludeFromLibrarySpecified = true; } - if (!NamespacesToExcludeFromLibrarySpecified) + } + + /// + /// Update namespaces to exclude from Library based on feature flags + /// + internal void UpdateNamespacesToExcludeFromLibrary() + { + // When the experiment toggle is disabled by feature flag, include the TSpline namespace from the library OOTB. + if (!DynamoModel.FeatureFlags?.CheckFeatureFlag("IsTSplineNodesExperimentToggleVisible", false) ?? false) { - NamespacesToExcludeFromLibrary.Add( + NamespacesToExcludeFromLibrary.Remove( "ProtoGeometry.dll:Autodesk.DesignScript.Geometry.TSpline" ); - NamespacesToExcludeFromLibrarySpecified = true; + return; } } diff --git a/src/DynamoCore/Models/DynamoModel.cs b/src/DynamoCore/Models/DynamoModel.cs index 27713cb10e3..5d5c1eeaa77 100644 --- a/src/DynamoCore/Models/DynamoModel.cs +++ b/src/DynamoCore/Models/DynamoModel.cs @@ -36,6 +36,7 @@ using Dynamo.Selection; using Dynamo.Utilities; using DynamoServices; +using DynamoUtilities; using Greg; using Lucene.Net.Documents; using Lucene.Net.Index; @@ -716,7 +717,7 @@ protected DynamoModel(IStartConfiguration config) { //this will kill the CLI process after cacheing the flags in Dynamo process. using (FeatureFlags = - new DynamoUtilities.DynamoFeatureFlagsManager( + new DynamoFeatureFlagsManager( AnalyticsService.GetUserIDForSession(), mainThreadSyncContext, IsTestMode)) @@ -728,6 +729,7 @@ protected DynamoModel(IStartConfiguration config) } catch (Exception e) { Logger.LogError($"could not start feature flags manager {e}"); }; }); + DynamoFeatureFlagsManager.FlagsRetrieved += HandleFeatureFlags; } // TBD: Do we need settings migrator for service mode? If we config the docker correctly, this could be skipped I think @@ -975,6 +977,15 @@ protected DynamoModel(IStartConfiguration config) DynamoReady(new ReadyParams(this)); } + /// + /// When feature flags received, handle them and make changes + /// + private void HandleFeatureFlags() + { + PreferenceSettings.UpdateNamespacesToExcludeFromLibrary(); + return; + } + private void HandleAnalytics() { if (IsTestMode) @@ -1367,6 +1378,7 @@ public void Dispose() LibraryServices.LibraryLoaded -= LibraryLoaded; EngineController.VMLibrariesReset -= ReloadDummyNodes; + DynamoFeatureFlagsManager.FlagsRetrieved -= HandleFeatureFlags; Logger.Dispose(); From 307d38c6525dcbb484a95967e19bf7f40c9ba819 Mon Sep 17 00:00:00 2001 From: "Aaron (Qilong)" Date: Thu, 8 Feb 2024 10:19:07 -0500 Subject: [PATCH 7/7] regressions --- test/DynamoCoreWpfTests/NodeAutoCompleteSearchTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/DynamoCoreWpfTests/NodeAutoCompleteSearchTests.cs b/test/DynamoCoreWpfTests/NodeAutoCompleteSearchTests.cs index a90471daf5e..d5784464d62 100644 --- a/test/DynamoCoreWpfTests/NodeAutoCompleteSearchTests.cs +++ b/test/DynamoCoreWpfTests/NodeAutoCompleteSearchTests.cs @@ -166,7 +166,7 @@ public void NodeSuggestions_CanAutoCompleteOnCustomNodesOutPort_WithSpaceInPortN // Results will be nodes that accept Line as parameter. searchViewModel.PopulateAutoCompleteCandidates(); - Assert.AreEqual(44, searchViewModel.FilteredResults.Count()); + Assert.AreEqual(58, searchViewModel.FilteredResults.Count()); } [Test] public void NodeSuggestions_CanAutoCompleteOnCustomNodesOutPort_WithWhiteSpaceStartingPortName() @@ -186,7 +186,7 @@ public void NodeSuggestions_CanAutoCompleteOnCustomNodesOutPort_WithWhiteSpaceSt // Results will be nodes that accept Line as parameter. searchViewModel.PopulateAutoCompleteCandidates(); - Assert.AreEqual(44, searchViewModel.FilteredResults.Count()); + Assert.AreEqual(58, searchViewModel.FilteredResults.Count()); } [Test] @@ -316,7 +316,7 @@ public void NodeSuggestions_OutputPortBuiltInNode_AreCorrect() // Get the output port type for the node. var outPorts = nodeView.ViewModel.OutPorts; - Assert.AreEqual(1, outPorts.Count()); + Assert.AreEqual(1, outPorts.Count); var port = outPorts[0].PortModel; var type = port.GetOutPortType(); @@ -326,7 +326,7 @@ public void NodeSuggestions_OutputPortBuiltInNode_AreCorrect() var searchViewModel = ViewModel.CurrentSpaceViewModel.NodeAutoCompleteSearchViewModel; searchViewModel.PortViewModel = outPorts[0]; var suggestions = searchViewModel.GetMatchingSearchElements(); - Assert.AreEqual(44, suggestions.Count()); + Assert.AreEqual(58, suggestions.Count()); } [Test]