[WIP] using pypes within jupyter notebooks#271
Merged
Conversation
…upport since the simplenamespace object is not included
Member
Author
|
I have rebased this PR off of the latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is some initial work conducted to allow pypes to be run within jupyter notebook. This PR focuses on allowing arbitrary python objects to be inserted into a pype string as input members.
Syntax
I have adopted a syntax similar to python
f-stringformatting to indicate the names within the input string which should be replaced with objects. Any name within{curly braces}is assumed to be the name of a python object to insert as a member in the Pype. Though similar in synatx, the representation should not be an actualf-stringinstance.Implementation
The core structure of
PypeShas been largely preserved. In order to implement this,kwargshave been added for thePypeRunandSetArgumentStringroutines. When{curly braces}are detected in the input string, the variable name enclosed by the{curly braces}is extracted, and thekwargsdict queried for the matching key/value pair. TheArgumentslist is then modified, replacing element previously holding the{curly braces}with the live python object.In order for the Pype instance to access python objects from the calling scope, we specify the
locals()dict as thekwargsto thepype.VmtkRun()function. I'm hoping to find a cleaner way of doing this. Minor modifications have been made the the ScriptObject argument parsing to accommodate these changes.Example
The following code seems to run without a problem within a jupyter notebook.