Skip to content

Commit

Permalink
Integrating ML node autocomplete. (DynamoDS#13496)
Browse files Browse the repository at this point in the history
* Integrate ML Node-Autocompletion,

* Update NodeModel.cs

* Update NodeModel.cs

* some changes

* more changes

* Update NodeAutoCompleteSearchControl.xaml

* Fix edge cases and UI improvements.

* update

* Update NodeAutoCompleteSearchControl.xaml

* fix highlighting items.

* fix

* Port name for variable input nodes.

* Add base test.

* addressing comments.

* Fix the edge cases for search results.

* Clean up code

* Update NodeAutoCompleteSearchViewModel.cs

* refactoring.

* updates

* Use IDSDK token for authentication

* updates

(cherry picked from commit 34fe0f1)
  • Loading branch information
reddyashish committed Nov 17, 2022
1 parent 80694f1 commit 1ef0c9c
Show file tree
Hide file tree
Showing 23 changed files with 1,115 additions and 390 deletions.
2 changes: 1 addition & 1 deletion src/DynamoCore/App.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="IDSDK_CLIENT_ID" value="IAtF1TBSlCeGqWAXKsBkcZBBwomALZsq"/>
<add key="IDSDK_CLIENT_ID" value="No0wuv5G1sGm3mcMLrVuvS5qKFqxekiN"/>
<add key="IDSDK_ENVIRONMENT" value=""/>
</appSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
16 changes: 16 additions & 0 deletions src/DynamoCore/Core/IDSDKManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ public void SignRequest(ref RestRequest m, RestClient client)
m.AddHeader("Authorization", $"Bearer {IDSDK_GetToken()}");
}

/// <summary>
/// Checks if the user is logged in and adds the token to request header.
/// </summary>
internal void LoginRequest(ref RestRequest m, RestClient client)
{
if (LoginState == LoginState.LoggedIn)
{
m.AddHeader("Authorization", $"Bearer {IDSDK_GetToken()}");
}
else {
throw new Exception("You must be logged in, to use this service.");
}
}

private void OnLoginStateChanged(LoginState state)
{
if (LoginStateChanged != null)
Expand Down Expand Up @@ -177,6 +191,7 @@ private bool SetProductConfigs(string productLineCode, idsdk_server server, stri
idsdk_status_code bRet = Client.SetProductConfig(oauthKey, "", productLineCode, DateTime.Now.Year.ToString(), "1.2.3.4", server);
return Client.IsSuccess(bRet);
}

/// <summary>
/// Returns the OAuth2 token for the current session, or an empty string if token is not available.
/// </summary>
Expand All @@ -189,6 +204,7 @@ private string IDSDK_GetToken()
}
return String.Empty;
}

private bool Initialize()
{
idsdk_status_code bRet = Client.Init();
Expand Down
6 changes: 4 additions & 2 deletions src/DynamoCore/Graph/Nodes/CustomNodes/Function.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
Expand Down Expand Up @@ -99,7 +99,7 @@ public override string NodeType
{
get
{
return "FunctionNode";
return FunctionNode;
}
}

Expand Down Expand Up @@ -310,6 +310,8 @@ private void ValidateDefinition(CustomNodeDefinition def)
}
}

internal static string FunctionNode = "FunctionNode";

/// <summary>
/// Validates passed Custom Node definition and synchronizes node with it.
/// </summary>
Expand Down
5 changes: 3 additions & 2 deletions src/DynamoCore/Graph/Nodes/NodeModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
Expand Down Expand Up @@ -106,6 +106,7 @@ public abstract class NodeModel : ModelBase, IRenderPackageSource<NodeModel>, ID
#endregion

internal const double HeaderHeight = 46;
internal static string ExtensionNode = "ExtensionNode";

#region public members

Expand Down Expand Up @@ -136,7 +137,7 @@ public virtual string NodeType
{
get
{
return "ExtensionNode";
return ExtensionNode;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCore/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/DynamoCore/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -876,10 +876,10 @@ This package likely contains an assembly that is blocked. You will need to load
<value>Low confidence</value>
</data>
<data name="AutocompleteNoRecommendationsMessage" xml:space="preserve">
<value>There’s no node that we can recommend to you, you may try</value>
<value>There are no nodes that we can recommend, you may try to</value>
</data>
<data name="AutocompleteSwitchToObjectTypeMessage" xml:space="preserve">
<value>switching to Object Type Autocomplete</value>
<value>switch to Object Type Autocomplete</value>
</data>
<data name="AutocompleteLowConfidenceMessage" xml:space="preserve">
<value>We are not very confident that the nodes below will work, you may try them or</value>
Expand All @@ -893,4 +893,4 @@ This package likely contains an assembly that is blocked. You will need to load
<data name="FailedInsertFileNodeExistNotification" xml:space="preserve">
<value>Failed to insert the file as some of the nodes already exist in the current worspace.</value>
</data>
</root>
</root>
6 changes: 3 additions & 3 deletions src/DynamoCore/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -879,10 +879,10 @@ This package likely contains an assembly that is blocked. You will need to load
<value>Low confidence</value>
</data>
<data name="AutocompleteNoRecommendationsMessage" xml:space="preserve">
<value>There’s no node that we can recommend to you, you may try</value>
<value>There are no nodes that we can recommend, you may try to</value>
</data>
<data name="AutocompleteSwitchToObjectTypeMessage" xml:space="preserve">
<value>switching to Object Type Autocomplete</value>
<value>switch to Object Type Autocomplete</value>
</data>
<data name="AutocompleteLowConfidenceMessage" xml:space="preserve">
<value>We are not very confident that the nodes below will work, you may try them or</value>
Expand All @@ -896,4 +896,4 @@ This package likely contains an assembly that is blocked. You will need to load
<data name="FailedInsertFileNodeExistNotification" xml:space="preserve">
<value>Failed to insert the file as some of the nodes already exist in the current worspace.</value>
</data>
</root>
</root>
6 changes: 3 additions & 3 deletions src/DynamoCore/Search/SearchDictionary.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Dynamo.Utilities;
using Dynamo.Utilities;
using Dynamo.Logging;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -305,11 +305,11 @@ private static Dictionary<V, double> MatchWithSubset(Dictionary<V,double> search
foreach (var searchElement in searchDict)
{
var currentElement = (searchElement.Key as SearchElements.NodeSearchElement);
var currentElementName = currentElement.FullName;
var currentElementName = currentElement.CreationName;
foreach (var ele in subset)
{
//if any element in tagDictionary matches to any element in subset, return true
if (currentElementName.IndexOf(ele.FullName, StringComparison.OrdinalIgnoreCase) != -1)
if (currentElementName.Equals(ele.CreationName, StringComparison.OrdinalIgnoreCase))
{
filteredDict.Add(searchElement.Key, searchElement.Value);
break;
Expand Down
Loading

0 comments on commit 1ef0c9c

Please sign in to comment.