Skip to content
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

Graph Preview States For New Node #12908

Merged
merged 3 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/DynamoCore/Graph/Workspaces/HomeWorkspaceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ internal void GetExecutingNodes(bool showRunPreview)
scheduler.ScheduleForExecution(task);
}
}
//Show node exection is checked but the graph has not RUN
//Show node execution is checked but the graph has not RUN
else
{
var deltaComputeStateArgs = new DeltaComputeStateEventArgs(new List<Guid>(), graphExecuted);
Expand All @@ -889,13 +889,12 @@ internal void GetExecutingNodes(bool showRunPreview)

private void OnPreviewGraphCompleted(AsyncTask asyncTask)
{
var updateTask = asyncTask as PreviewGraphAsyncTask;
if (updateTask != null)
if (asyncTask is PreviewGraphAsyncTask updateTask)
{
var nodeGuids = updateTask.previewGraphData;
var deltaComputeStateArgs = new DeltaComputeStateEventArgs(nodeGuids,graphExecuted);
OnSetNodeDeltaState(deltaComputeStateArgs);
}
var deltaComputeStateArgs = new DeltaComputeStateEventArgs(nodeGuids, graphExecuted);
OnSetNodeDeltaState(deltaComputeStateArgs);
}
}


Expand Down
26 changes: 16 additions & 10 deletions src/DynamoCore/Scheduler/PreviewGraphAsyncTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PreviewGraphAsyncTask : AsyncTask
private IEnumerable<NodeModel> modifiedNodes;
private bool verboseLogging;
public List<Guid> previewGraphData;

public override TaskPriority Priority
{
get { return TaskPriority.Normal; }
Expand Down Expand Up @@ -55,13 +55,13 @@ internal List<Guid> Initialize(EngineController controller, WorkspaceModel works
try
{
engineController = controller;
TargetedWorkspace = workspace;
modifiedNodes = ComputeModifiedNodes(workspace);
previewGraphData = engineController.PreviewGraphSyncData(modifiedNodes,verboseLogging);
TargetedWorkspace = workspace;
modifiedNodes = ComputeModifiedNodes(workspace);
previewGraphData = engineController.PreviewGraphSyncData(modifiedNodes, verboseLogging);
Copy link
Contributor Author

@QilongTang QilongTang May 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aparajit-pratap @mjkkirschner @sm6srw @pinzart90 I have a question, if a graph(in manual mode) has been run once, then the user add a new node, what should this function return? I would expect this function to return me the new node's node id, but it is currently returning an empty set and causing a bug.

Copy link
Member

@mjkkirschner mjkkirschner May 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was PreviewGraphSyncData returning empty list before your change to ComputeModifiedNodes? To clarify - which function were you referring to?

Copy link
Contributor Author

@QilongTang QilongTang May 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjkkirschner Previously the function PreviewGraphSyncData is also returning empty. modifiedNodes were always all of the nodes in workspace so I would not trust the return value at all. As you can see from the comment from Ben, that TODO from 7 years ago never finished. Right now I am setting the modified nodes as an example, and in my case, I am adding a new node to the existing workspace, but this function does not return the expected results.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the description of the PreviewGraphSyncData function is This is called on the main thread from PreviewGraphSyncData to generate the list of node id's that will be executed on the next run. I would expect it to return the id of newly added node.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to Turbo Team who fixed this API, this is now working

return previewGraphData;
}
catch (Exception e)
{
catch (Exception)
{
return null;
}
}
Expand All @@ -72,25 +72,31 @@ internal List<Guid> Initialize(EngineController controller, WorkspaceModel works

protected override void HandleTaskExecutionCore()
{

}

protected override void HandleTaskCompletionCore()
{

}

#endregion

#region Public Class Properties
internal WorkspaceModel TargetedWorkspace { get; private set; }
internal WorkspaceModel TargetedWorkspace { get; private set; }
#endregion

#region Private Class Helper Methods

private static IEnumerable<NodeModel> ComputeModifiedNodes(WorkspaceModel workspace)
{
return workspace.Nodes; // TODO(Ben): Implement dirty node subsetting.
// Try to calculate dirty nodes on UI side.
// This is only for UI feature. If this list inaccurate, it will not affect how VM works.
return (workspace.Nodes as List<NodeModel>).FindAll(
delegate (NodeModel node)
{
return node.IsModified;
});
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private void UpdateNodesDeltaState(List<Guid> nodeGuids, bool graphExecuted)
}
}

//if the graph is executed then set the node preview to false , provided
//if the graph is executed then set the node preview to false, provided
// there is no error on that node.
if (nodeGuids.Count == 0 && graphExecuted)
{
Expand Down