Skip to content

Conversation

@ivaylo-matov
Copy link
Contributor

Purpose

PR in response to DYN-9388.

  • for testing UX scenarios
  • pythonnet3 loaded as built-in package
  • for now cpython is still present but does not load
  • to be discussed what to do with python tests. Note that test will fail now as they still rely on built-in cpython logic.
  • when users open old graph with cpython nodes, they get updated to PythonNet3 and toast is displayed. On save another text box appears to explain the changes. Should reflect latest Figma design
image image image

Declarations

Check these if you believe they are true

Release Notes

Make PythonNet3 default python engine as built-in package

Reviewers

@zeusongit
@DynamoDS/eidos

FYIs

@dnenov
@achintyabhat

Copilot AI review requested due to automatic review settings September 30, 2025 09:06
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-9388

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR makes PythonNet3 the default Python engine as a built-in package, replacing CPython3. It provides automatic migration of existing CPython nodes to PythonNet3 with user notifications and adds preferences to control these notifications.

Key changes:

  • Switches default Python engine from CPython3 to PythonNet3 across the codebase
  • Implements automatic node migration with toast notifications and dialog boxes
  • Adds user preference controls for hiding migration notifications

Reviewed Changes

Copilot reviewed 66 out of 77 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/PythonMigrationViewExtension/PythonMigrationViewExtension.cs Adds CPython to PythonNet3 migration logic with notifications and automatic node upgrading
src/NodeServices/PythonServices.cs Updates default engine references and removes automatic CPython loading
src/Libraries/PythonNodeModels/PythonNode.cs Changes default engine from CPython3 to PythonNet3 and adds ShowAutoUpgradedBar property
src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs Implements UI handlers for Python engine change notifications and dialogs
src/DynamoCore/Configuration/PreferenceSettings.cs Adds HideCPython3Notifications preference setting
extern/PythonNet3Engine/ Adds PythonNet3 engine as built-in package with all necessary configuration files
Files not reviewed (3)
  • src/DynamoCoreWpf/Properties/Resources.Designer.cs: Language not supported
  • src/Libraries/PythonNodeModels/Properties/Resources.Designer.cs: Language not supported
  • src/PythonMigrationViewExtension/Properties/Resources.Designer.cs: Language not supported
Comments suppressed due to low confidence (5)

@ivaylo-matov
Copy link
Contributor Author

What should we do with the new DSPytnotNet3 versions?

image

<data name="ResetCPythonButtonText" xml:space="preserve">
<value>Reimposta CPython</value>
<data name="ResetPythonNet3ButtonText" xml:space="preserve">
<value>Reimposta PythonNet3</value>
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to update the strings for all locale(s) they are updated by some automation we have setup afterwards. We just need to update them in Resources.Designer.cs and Resources.resx files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted the changes now

@zeusongit
Copy link
Contributor

What should we do with the new DSPytnotNet3 versions?

image

We can add them to the excluded files list here: https://github.com/DynamoDS/Dynamo/blob/master/.github/scripts/check_file_version.ps1#L15

@zeusongit zeusongit requested review from a team and twastvedt September 30, 2025 14:54
@ivaylo-matov ivaylo-matov force-pushed the DYN-9388-Net3-package-does-not-load branch from 68456d0 to e5f81c1 Compare September 30, 2025 17:45
@zeusongit zeusongit requested a review from Copilot September 30, 2025 19:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 67 out of 78 changed files in this pull request and generated no new comments.

Files not reviewed (3)
  • src/DynamoCoreWpf/Properties/Resources.Designer.cs: Language not supported
  • src/Libraries/PythonNodeModels/Properties/Resources.Designer.cs: Language not supported
  • src/PythonMigrationViewExtension/Properties/Resources.Designer.cs: Language not supported
Comments suppressed due to low confidence (5)

@zeusongit
Copy link
Contributor

@twastvedt @mjkkirschner I think this is ready for another look, the changes from other PR as well as the Nuget is merged in this

@zeusongit
Copy link
Contributor

@avidit @QilongTang The self serve job fails repeatedly with instance being killed, cannot figure out if tests are failing/causing it or something else

<DllExtra Include="$(LibDir)DSPythonNet3Extension_ExtensionDefinition.xml" Condition="Exists('$(LibDir)DSPythonNet3Extension_ExtensionDefinition.xml')" />
</ItemGroup>
<Copy SourceFiles="@(DllExtra)" DestinationFolder="$(DestExtra)" SkipUnchangedFiles="True" />
</Target>
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reasoning for needing this to know so much about the exact files it's copying, and where they go? Why can't the package created by the PythonNet3 engine repo come formatted correctly, with all the files in a single known folder ready to copy into Built-in packages? That way DynamoCore wouldn't need to know about the inner workings of the Python package, and thus need to be updated if the package structure changes.

Copy link
Member

Choose a reason for hiding this comment

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

yeah pretty much agree, the less code here the better...

  1. it appears you are just copying everything from bin, so just copy the contents of lib, are you excluding something?
  2. is there not a net10 version of pythonNet? Then you could do Lib\$(TargetFramework)

catch(Exception ex)

// Set PythonNet3 as the default engine if it is isntalled and no other valid engine is set as default
var eng = e.NewItems[0] as PythonServices.PythonEngine;
Copy link
Member

Choose a reason for hiding this comment

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

is it a problem that this might get fired at some time in the future when a user installs a package that includes a python engine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, I postponed this for after all engines are loaded.

/// <returns></returns>
internal static string MigrateCode(string code)
{
DSCPython.CPythonEvaluator.InstallPython();
Copy link
Member

Choose a reason for hiding this comment

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

how does this work with the new package - where / how does the runtime get installed?

Copy link
Contributor Author

@ivaylo-matov ivaylo-matov Oct 15, 2025

Choose a reason for hiding this comment

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

PythonNet3 bootstraps the runtime itself and wires the engine up when the package loads.
On startup PackageLoader loads built-in packages. After a package is loaded it calls LoadPythonEngine() to discover and register engine classes from those assemblies.

{
PythonEngine.ReleaseLock(gs);
}
finally { }
Copy link
Member

Choose a reason for hiding this comment

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

not really useful...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed now.
Switched to using (Py.GIL()) because pythonnet3 removed AcquireLock/ReleaseLock and we must explicitly hold the GIL. Also PythonEngine.BeginAllowThreads() because that’s for releasing the GIL during long .NET-only work.

@mjkkirschner
Copy link
Member

@ivaylo-matov a few comments and one potentially bigger change:
WRT to the IronPython package that is embedded for testing, could we reference a build somewhere instead of copying the files in? Even just embedding a zip (if it's small enough) might be preferrable to the loose files in the git repo - just easier to update and reference a specific build - which makes it easier for the next dev IMO.

Also I ran into a problem running IronPython3 package under net10 - did you see the same issue with IronPython2?

@ivaylo-matov
Copy link
Contributor Author

ivaylo-matov commented Oct 15, 2025

@ivaylo-matov a few comments and one potentially bigger change: WRT to the IronPython package that is embedded for testing, could we reference a build somewhere instead of copying the files in? Even just embedding a zip (if it's small enough) might be preferrable to the loose files in the git repo - just easier to update and reference a specific build - which makes it easier for the next dev IMO.

Also I ran into a problem running IronPython3 package under net10 - did you see the same issue with IronPython2?

Done - zipped the loose package files and added an MSBuild target in DynamoPythonTests.csproj to unzip during test builds. Also added a local .gitignore in to whitelist PythonEnginePackage.zip. Hope that's okay.

@mjkkirschner
Copy link
Member

10:30:51  C:\Jenkins\workspace\Dynamo\DynamoSelfServe\pullRequestValidation>pwsh.exe -ExecutionPolicy ByPass -File .\CICDTools\scripts\RunTests.ps1 
10:30:51  Using dotnet test
10:30:51  The test type to execute is all tests
10:30:51  Execute Serial tests
10:30:51  Starting run 1
11:08:43  Cannot contact CDA-VS22-DT_7668: java.lang.InterruptedException
11:17:04  Agent CDA-VS22-DT_7668 was deleted; cancelling node body
11:17:04  Could not connect to CDA-VS22-DT_7668 to send interrupt signal to process

maybe you can try running the same test script locally and see if the test runner crashes?

Copy link
Contributor

@zeusongit zeusongit left a comment

Choose a reason for hiding this comment

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

@ivaylo-matov thank you for the updates, I have been testing the PR, and it seems to be in a good state, I will merge this now so that QAs can push testing further.
@mjkkirschner @twastvedt thank you for the review, if their are some outstanding comments, they will be addressed in separate PRs, however I think most of them have already been addressed, free to take another look.

@zeusongit zeusongit merged commit 38f5741 into DynamoDS:master Oct 15, 2025
26 of 27 checks passed
reddyashish pushed a commit to reddyashish/Dynamo that referenced this pull request Oct 16, 2025
@reddyashish reddyashish mentioned this pull request Oct 16, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants