Skip to content

Commit

Permalink
when extension is late loaded run the graph to resolve the new engine.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkkirschner committed Jan 3, 2024
1 parent 02efa74 commit 6529beb
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions IronPythonExtension/IronPythonExtension.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dynamo.Extensions;
using Dynamo.Graph.Workspaces;
using Dynamo.Logging;
using Dynamo.PythonServices;
using System;
Expand Down Expand Up @@ -60,15 +61,30 @@ public void Startup(StartupParams sp)
/// Action to be invoked when the Dynamo has started up and is ready
/// for user interaction.
/// </summary>
/// <param name="sp"></param>
public void Ready(ReadyParams sp)
/// <param name="rp"></param>
public void Ready(ReadyParams rp)
{
var extraPath = Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.Parent.FullName, "extra");
var alc = new IsolatedPythonContext(Path.Combine(extraPath,"DSIronPython.dll"));
var dsIronAssem = alc.LoadFromAssemblyName(new AssemblyName("DSIronPython"));
var alc = new IsolatedPythonContext(Path.Combine(extraPath,$"{PythonEvaluatorAssembly}.dll"));
var dsIronAssem = alc.LoadFromAssemblyName(new AssemblyName(PythonEvaluatorAssembly));

//load the engine into Dynamo ourselves.
LoadPythonEngine(dsIronAssem);

//we used to do this:
//but it's not neccesary to load anything into the VM.
//instead we skip all the extra work and trigger the side effect we want
//which is re executing the graph after the dsIronPython evaluator is loaded into the PythonEngineManager.
//rp.StartupParams.LibraryLoader.LoadNodeLibrary(dsIronAssem);

if(rp.CurrentWorkspaceModel is HomeWorkspaceModel hwm)
{
foreach (var n in hwm.Nodes)
{
n.MarkNodeAsModified(true);
}
hwm.Run();
}
}

/// <summary>
Expand Down

0 comments on commit 6529beb

Please sign in to comment.