Redirect python print to Dynamo console#11000
Conversation
mmisol
left a comment
There was a problem hiding this comment.
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.
| scope.Set((string)bindingNames[i], InputMarshaler.Marshal(bindingValues[i]).ToPython()); | ||
| } | ||
|
|
||
| scope.Exec($"sys.stdout.prefix = '{nodeName}'"); |
There was a problem hiding this comment.
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.
i added the nodename as a variable to the PyScope, that seems to work better and works with all special characters.
mmisol
left a comment
There was a problem hiding this comment.
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
printto the Dynamo console. It also removes the currentDynamoPrint()function.Declarations
Check these if you believe they are true
*.resxfilesReviewers
@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
ProcessAdditionalBindingsin the local scope. Let me know if you are okay with that.