-
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
Redirect python print to Dynamo console #11000
Conversation
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.
Looks pretty good. Only an issue with escaping '
and a couple of typos.
About Iron Python, you are correct @SHKnudsen , there is no such thing as a global scope, so your solution looks fine.
|
||
int amt = Math.Min(bindingNames.Count, bindingValues.Count); | ||
|
||
for (int i = 0; i < amt; i++) | ||
{ | ||
scope.Set((string)bindingNames[i], InputMarshaler.Marshal(bindingValues[i]).ToPython()); | ||
} | ||
|
||
scope.Exec($"sys.stdout.prefix = '{nodeName}'"); |
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.
I guess this code could run into problems when nodeName
contains a '
character. Could you escape it and maybe and an '
to a node name in the test so that we are covering it?
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.
i added the nodename as a variable to the PyScope, that seems to work better and works with all special characters.
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.
Looks good. Just one minor final comment.
Thanks @SHKnudsen ! I will just wait for the tests to run and merge this in. |
* redirect print to DynamoConsol + update unit test * comment updates * Update CPythonEvaluator.cs
* Redirect python print to Dynamo console (#11000) * redirect print to DynamoConsol + update unit test * comment updates * Update CPythonEvaluator.cs * Move Python print function to local scope (#11007) This fixes build issues that appeared after merging 'print' function changes for CPython3. Those changes moved the print function to the globalScope which caused the 'DynamoPrintLogsToConsole' test to fail. The reason for this is that Python unit tests, which don't use a model, still initialize the globalScope but do not provide a logger, making later logging tests fail. Co-authored-by: Sylvester Knudsen <[email protected]>
Purpose
This PR builds on the work of https://jira.autodesk.com/browse/DYN-2971, to add functionality to redirect Python
print
to the Dynamo console. It also removes the currentDynamoPrint()
function.Declarations
Check these if you believe they are true
*.resx
filesReviewers
@mmisol
FYIs
@mjkkirschner
@QilongTang
FYI @mmisol seems like the IronPythonEvaluator does not have a global scope, is that correctly understood? For redirecting prints in IronPython i simply
ProcessAdditionalBindings
in the local scope. Let me know if you are okay with that.