Skip to content

Commit

Permalink
DYN-7122: Node autocomplete clusters - internal testing tool (#15693)
Browse files Browse the repository at this point in the history
  • Loading branch information
reddyashish authored Dec 9, 2024
1 parent 6d5ea68 commit b845513
Show file tree
Hide file tree
Showing 20 changed files with 701 additions and 52 deletions.
1 change: 1 addition & 0 deletions src/DynamoCore/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
[assembly: InternalsVisibleTo("ExportSampleImagesViewExtension")]
[assembly: InternalsVisibleTo("DocumentationBrowserViewExtension")]
[assembly: InternalsVisibleTo("Notifications")]
[assembly: InternalsVisibleTo("NodeAutoCompleteViewExtension")]

// Disable PublicAPIAnalyzer errors for this type as they're already added to the public API text file
#pragma warning disable RS0016
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
using Autodesk.DesignScript.Geometry;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

namespace Dynamo.Search.SearchElements
{
/// <summary>
/// Data representing the request for ML node autocompletion service.
/// </summary>
[DataContract]
internal class MLNodeAutoCompletionRequest
{
internal MLNodeAutoCompletionRequest(string dynamoVersion, int numberOfResults)
{
DynamoVersion = dynamoVersion;
NumberOfResults = numberOfResults;
Node = new NodeRequest();
Port = new PortRequest();
Context = new ContextRequest();
Node = new NodeItem();
Port = new PortItem();
Context = new ContextItem();
Packages = new List<PackageItem>();
}

[DataMember(Name = "node")]
internal NodeRequest Node { get; set; }
internal NodeItem Node { get; set; }

[DataMember(Name = "port")]
internal PortRequest Port { get; set; }
internal PortItem Port { get; set; }

[DataMember(Name = "host")]
internal HostRequest Host { get; set; }
internal HostItem Host { get; set; }

[DataMember(Name = "dynamoVersion")]
internal string DynamoVersion { get; set; }
Expand All @@ -35,49 +40,52 @@ internal MLNodeAutoCompletionRequest(string dynamoVersion, int numberOfResults)
internal IEnumerable<PackageItem> Packages { get; set; }

[DataMember(Name = "context")]
internal ContextRequest Context { get; set; }
internal ContextItem Context { get; set; }
}

/// <summary>
/// Data representing node properties for ML autocomplete.
/// </summary>
[DataContract]
internal class NodeRequest
internal class NodeItem
{
internal NodeRequest()
internal NodeItem()
{
Type = new NodeTypeRequest();
Type = new NodeType();
}

internal NodeRequest(string id)
internal NodeItem(string id)
{
Id = id;
Type = new NodeTypeRequest();
Type = new NodeType();
}

[DataMember(Name = "id")]
internal string Id { get; set; }

[DataMember(Name = "type")]
internal NodeTypeRequest Type { get; set; }
internal NodeType Type { get; set; }

[DataMember(Name = "lacing")]
internal string Lacing { get; set; }
}

[DataContract]
internal class NodeTypeRequest
internal class NodeType
{
[DataMember(Name = "id")]
internal string Id { get; set; }
}

[DataContract]
internal class PortRequest
internal class PortItem
{
internal PortRequest()
internal PortItem()
{
//nothing
}

internal PortRequest(string name, string direction)
internal PortItem(string name, string direction)
{
Name = name;
Direction = direction;
Expand All @@ -86,6 +94,9 @@ internal PortRequest(string name, string direction)
[DataMember(Name = "name")]
internal string Name { get; set; }

[DataMember(Name = "index")]
internal int Index { get; set; }

[DataMember(Name = "direction")]
internal string Direction { get; set; }

Expand All @@ -96,10 +107,13 @@ internal PortRequest(string name, string direction)
internal string KeepListStructure { get; set; }
}

/// <summary>
/// Data representing the Host info.
/// </summary>
[DataContract]
internal class HostRequest
internal class HostItem
{
internal HostRequest(string name, string version)
internal HostItem(string name, string version)
{
Name = name;
Version = version;
Expand All @@ -112,24 +126,30 @@ internal HostRequest(string name, string version)
internal string Version { get; set; }
}

/// <summary>
/// Data representing the workflow context which has upstream and downstream nodes along with connections.
/// </summary>
[DataContract]
internal class ContextRequest
internal class ContextItem
{
internal ContextRequest()
internal ContextItem()
{
Connections = new List<ConnectionsRequest>();
Nodes = new List<NodeRequest>();
Connections = new List<ConnectionItem>();
Nodes = new List<NodeItem>();
}

[DataMember(Name = "nodes")]
internal IEnumerable<NodeRequest> Nodes { get; set; }
internal IEnumerable<NodeItem> Nodes { get; set; }

[DataMember(Name = "connections")]
internal IEnumerable<ConnectionsRequest> Connections { get; set; }
internal IEnumerable<ConnectionItem> Connections { get; set; }
}

/// <summary>
/// Data representing node connections for ML autocomplete.
/// </summary>
[DataContract]
internal class ConnectionsRequest
internal class ConnectionItem
{
[DataMember(Name = "from")]
internal ConnectorNodeItem StartNode { get; set; }
Expand All @@ -138,22 +158,42 @@ internal class ConnectionsRequest
internal ConnectorNodeItem EndNode { get; set; }
}

/// <summary>
/// Data representing the nodes in the connectors info.
/// </summary>
[DataContract]
internal class ConnectorNodeItem
{
internal ConnectorNodeItem()
{
// default constructor for deserialization.
}

internal ConnectorNodeItem(string nodeId, string portName)
{
NodeId = nodeId;
PortName = portName;
}

internal ConnectorNodeItem(string nodeId, int portIndex)
{
NodeId = nodeId;
PortIndex = portIndex;
}

[DataMember(Name = "nodeId")]
internal string NodeId { get; set; }

[DataMember(Name = "portName")]
internal string PortName { get; set; }

[DataMember(Name = "portIndex")]
internal int PortIndex { get; set; }
}

/// <summary>
/// Data representing the package info.
/// </summary>
[DataContract]
internal class PackageItem
{
Expand All @@ -170,6 +210,10 @@ internal PackageItem(string name, string version)
internal string Version { get; set; }
}

/// <summary>
/// Data representing the ML node autocomplete response.
/// Contains version, number of results and list of node suggestions.
/// </summary>
[DataContract]
internal class MLNodeAutoCompletionResponse
{
Expand All @@ -188,21 +232,90 @@ internal MLNodeAutoCompletionResponse()
internal IEnumerable<ResultItem> Results { get; set; }
}

/// <summary>
/// Data representing the ML node cluster autocomplete response.
/// Contains version, number of results and list of node cluster suggestions.
/// </summary>
[DataContract]
internal class MLNodeClusterAutoCompletionResponse
{
internal MLNodeClusterAutoCompletionResponse()
{
Results = new List<ClusterResultItem>();
}

[DataMember(Name = "version")]
internal string Version { get; set; }

[DataMember(Name = "numberOfResults")]
internal int NumberOfResults { get; set; }

[DataMember(Name = "results")]
internal IEnumerable<ClusterResultItem> Results { get; set; }
}

/// <summary>
/// Data representing the ML node suggestion.
/// </summary>
[DataContract]
internal class ResultItem
{
[DataMember(Name = "node")]
internal NodeResponse Node { get; set; }
internal NodeResponseItem Node { get; set; }

[DataMember(Name = "port")]
internal PortResponse Port { get; set; }
internal PortResponseItem Port { get; set; }

[DataMember(Name = "score")]
internal double Score { get; set; }
}

/// <summary>
/// Data representing the ML node cluster suggestion.
/// </summary>
[DataContract]
internal class ClusterResultItem
{
[DataMember(Name = "title")]
internal string Title { get; set; }

[DataMember(Name = "description")]
internal string Description { get; set; }

[DataMember(Name = "probability")]
internal string Probability { get; set; }

[DataMember(Name = "entryNodeIndex")]
internal int EntryNodeIndex { get; set; }

[DataMember(Name = "entryNodeInPort")]
internal int EntryNodeInPort { get; set; }

[DataMember(Name = "topology")]
internal TopologyItem Topology { get; set; }
}

/// <summary>
/// Data representing the nodes and connetions in node cluster suggestion.
/// </summary>
[DataContract]
internal class TopologyItem
{
internal TopologyItem()
{
Nodes = new List<NodeItem>();
Connections = new List<ConnectionItem>();
}

[DataMember(Name = "nodes")]
internal IEnumerable<NodeItem> Nodes { get; set; }

[DataMember(Name = "connections")]
internal IEnumerable<ConnectionItem> Connections { get; set; }
}

[DataContract]
internal class PortResponse
internal class PortResponseItem
{
[DataMember(Name = "name")]
internal string Name { get; set; }
Expand All @@ -212,9 +325,9 @@ internal class PortResponse
}

[DataContract]
internal class NodeResponse
internal class NodeResponseItem
{
internal NodeResponse()
internal NodeResponseItem()
{
Type = new NodeTypeResponse();
}
Expand Down Expand Up @@ -256,6 +369,7 @@ public override string ToString()
}
}

// List of host names.
internal enum HostNames
{
Revit,
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<configuration>
<appSettings>
<add key="MLNodeAutocomplete" value="https://autocomplete.dynamobim.org/autocomplete"/>
<add key="MLNodeClusterAutocomplete" value="https://c00rffy86i.execute-api.us-west-2.amazonaws.com/Prod/autocomplete_clusters"/>
<add key="VideoSettings" value="[
{
&quot;id&quot;: &quot;1&quot;,
Expand Down
5 changes: 3 additions & 2 deletions src/DynamoCoreWpf/Commands/PortCommands.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Dynamo.UI.Commands;
using Dynamo.UI.Commands;

namespace Dynamo.ViewModels
{
public partial class PortViewModel
{
private DelegateCommand connectCommand;
private DelegateCommand autoCompleteCommand;
private DelegateCommand nodeClusterAutoCompleteCommand;
private DelegateCommand portMouseEnterCommand;
private DelegateCommand portMouseLeaveCommand;
private DelegateCommand portMouseLeftButtonCommand;
Expand All @@ -32,7 +33,7 @@ public DelegateCommand NodeAutoCompleteCommand
get
{
if (autoCompleteCommand == null)
autoCompleteCommand = new DelegateCommand(AutoComplete, CanAutoComplete);
autoCompleteCommand ??= new DelegateCommand(NodeViewModel.WorkspaceViewModel.DynamoViewModel.IsDNAClusterPlacementEnabled ? AutoCompleteCluster : AutoComplete, CanAutoComplete);

return autoCompleteCommand;
}
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
[assembly: InternalsVisibleTo("UnitsUI")]
[assembly: InternalsVisibleTo("DynamoPlayer")]
[assembly: InternalsVisibleTo("DynamoConnector")]
[assembly: InternalsVisibleTo("NodeAutoCompleteViewExtension")]

// Disable PublicAPIAnalyzer errors for this type as they're already added to the public API text file
#pragma warning disable RS0016
Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/UI/Themes/Modern/InPorts.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dynui="clr-namespace:Dynamo.UI.Controls;assembly=DynamoCoreWpf"
xmlns:interactivity="clr-namespace:Dynamo.Microsoft.Xaml.Behaviors;assembly=Dynamo.Microsoft.Xaml.Behaviors"
Expand Down Expand Up @@ -202,4 +202,4 @@
SnapsToDevicePixels="True" />
</Grid>
</DataTemplate>
</ResourceDictionary>
</ResourceDictionary>
Loading

0 comments on commit b845513

Please sign in to comment.