-
Notifications
You must be signed in to change notification settings - Fork 635
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
T1.1 Python 2 Code Migration #10850
T1.1 Python 2 Code Migration #10850
Conversation
* add ScriptMigrator * Add visual difference viewer * Update PythonMigrationViewExtension.cs * Add tooltip description to migration assistant * updates * comment updates * comment updates
Thank you @SHKnudsen . This is exciting. @mjkkirschner will log a Jira task for our team to review your work soon |
src/PythonMigrationViewExtension/Controls/VisualDifferenceViewer.xaml
Outdated
Show resolved
Hide resolved
src/PythonMigrationViewExtension/MigrationAssistant/ScriptMigrator.cs
Outdated
Show resolved
Hide resolved
src/PythonMigrationViewExtension/PythonMigrationViewExtension.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to move things up a little, I commented the things I feel still need addressing. I'll summarize here:
- Delete third unit test (unless there is something I overlooked, LMK)
- Add new libraries to license files
- Fix bug related to unsaved code changes not showing in the migrator
Thanks for the reminder Martin - as it stands I would appreciate info on loading fixers if that’s something that was considered already, but if not I don’t want to hold up this pr for comments on a feature we may not use.
… On Jul 20, 2020, at 8:56 AM, Martin Misol Monzo ***@***.***> wrote:
@mmisol commented on this pull request.
Just to move things up a little, I commented the things I feel still need addressing. I'll summarize here:
Delete third unit test (unless there is something I overlooked, LMK)
Add new libraries to license files
Fix bug related to unsaved code changes not showing in the migrator
In test/DynamoCoreTests/PythonMigrationAssistantTests.cs:
> +
+ [Test]
+ public void MigrationWillNotChangeCodeAfterBeingConverted()
+ {
+ // Arrange
+ var originalPython2Code = @"for x in xrange(100): continue";
+ var expectedPython3CodeAfterMigration = @"for x in range(100): continue";
+
+ // Act
+ var migratedScript = ScriptMigrator.MigrateCode(originalPython2Code);
+ var migratedScript2 = ScriptMigrator.MigrateCode(migratedScript);
+
+ // Assert
+ Assert.AreEqual(expectedPython3CodeAfterMigration, migratedScript);
+ Assert.AreEqual(expectedPython3CodeAfterMigration, migratedScript2);
+ }
@radumg Since you mentioned idempotency let's get mathematical :) The second test shows that x = f(x) when x doesn't have Python 2 in it. The third tests shows that y = f(f(y)) with a y with the same characteristics as x in the previous test. The second test is already showing idempotency, therefore my argument to delete this third test.
In test/DynamoCoreTests/PythonMigrationAssistantTests.cs:
> + [Test]
+ public void MigrationWillNotChangeCodeAfterBeingConverted()
+ {
+ // Arrange
+ var originalPython2Code = @"for x in xrange(100): continue";
+ var expectedPython3CodeAfterMigration = @"for x in range(100): continue";
+
+ // Act
+ var migratedScript = ScriptMigrator.MigrateCode(originalPython2Code);
+ var migratedScript2 = ScriptMigrator.MigrateCode(migratedScript);
+
+ // Assert
+ Assert.AreEqual(expectedPython3CodeAfterMigration, migratedScript);
+ Assert.AreEqual(expectedPython3CodeAfterMigration, migratedScript2);
+ }
+ }
Brought this to standup the other day and I didn't get any remarks from Mike. Unless he comments otherwise, let's assume we don't need this for now, for the sake of unblocking this PR.
In src/PythonMigrationViewExtension/packages.config:
> @@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="DiffPlex" version="1.6.3" targetFramework="net48" />
+ <package id="DiffPlex.Wpf" version="1.1.1" targetFramework="net48" />
@SHKnudsen Please address this.
In src/Libraries/PythonNodeModelsWpf/ScriptEditorWindow.xaml.cs:
> @@ -167,6 +167,13 @@ private void OnRunClicked(object sender, RoutedEventArgs e)
}
}
+ private void OnMigrationAssistantClicked(object sender, RoutedEventArgs e)
+ {
+ if (nodeModel == null)
+ throw new NullReferenceException(nameof(nodeModel));
+
+ nodeModel.RequestCodeMigration(e);
+ }
Please address this bug before merging @SHKnudsen
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@mmisol addressed the last changes, sorry for the delay! Let me know if there is anything else. |
Thanks @SHKnudsen . I see the bug is fixed. Could I ask you to place diffplex in the license.rtf file so that it appears in alphabetical order in the about window? |
@mmisol order of the licence files are updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @SHKnudsen! Looks good to me
I couldn't reproduce the test failure locally. I have triggered a manual test run on a different server just in case this is just a flaky failure. If that works I'm merging this. |
Also got an error here https://master-15.jenkins.autodesk.com/view/DYN/job/DYN-DevCI_Self_Service/709/, although it seems unrelated (PackageDependencyTests). I think we can probably merge but I'll confirm with @QilongTang first. |
Purpose
This PR is the first step in adding a
Migration Assistant
that helps users automatically upgrade their Python code from Python 2 to Python 3. The PR focuses on adding the functionality to Migrate Python 2 code to Python 3 compatible code, using Pythons 2to3 library. It also adds a new VisualDifferenceViewer to show the changes being made by the migration.This is the biggest of the PRs concerning the Python 3 migration work, the following PRs will be smaller.
Declarations
Check these if you believe they are true
*.resx
filesReviewers
@mjkkirschner
@QilongTang
@radumg
FYIs
The
VisualDifferenceViewer
are using theDiffPlex
library. I know the decision on whether or not we want to include this dependency is still pending, but the rest of the code should be fine to review.The button icons on the
VisualDifferenceViewer
are also pending final confirmation, we can easily revert back to text if this turns out to be an issue.