-
Notifications
You must be signed in to change notification settings - Fork 102
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
Programming Example with IPython Notebook #1909
Conversation
Note to self: look into github commit hook to scrub jupyter notebook outputs automatically |
The pre-commit setup I used is a little annoying (it's very visible during the commit process) but it's also quite functional, uses popular tools, and the output is easy to understand. There are also some other cool built-in hooks that could be useful if added in a future PR, such as:
I know I've had problems with these things in some PRs. |
Re: VS Code, I am able to import the python directly be using a However, this does not give me all of the environment variables needed to compile from the python notebook. I need to find a way to run the env setup script in a way that percolates that environment to the environment seen by jupyter. |
@STFleming Have you been able to get Jupyter notebooks working in VSCode? |
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 really like the notebook style for examples, this would be a huge improvement for the programming guide examples in particular.
The VSCode integration could be a WIP. It should be documented in the guide/examples the steps to set up the server and connect though.
Tested in jupyter lab environment and seemed to work well! My current plan is to merge even without the notebook working in VS Code, once a few more people look at the PR. |
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.
Works for me! For vscode I was able to start jupyterlab from the command line then tell vscode to connect to the existing server. Then the notebook ran ok. Trying to use the ipython kernel directly in vscode I have some LD_LIBRARY_PATH issue. Standalone jupyter I had no issues (but without following directions or using quick_setup)
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.
Could you comment the new additions to the setup scripts? (A follow on PR will document the existing.)
@jgmelber Comments have been added to setup script! |
First attempt at an ipython notebook for a programming example.
I'm not attempting to solve all problems with ipython notebooks, but rather provide a basis that might become a more comprehensive solution with further development.
How it works:
aie2.py
) and test code (test.py
)aiecc
, not through the python interface, but through!
commands in the notebook which are executed directly. So this is not an end-to-end python solution - I do this purposefully to demonstrate that using notebooks does not demand an end-to-end python (even though that would be the ideal experience for the programming examples, in my opinion).ipykernel
which is build around thevenv
(eithersandbox
orironenv
); I've updated thequick_setup.sh
script and thesetup_python_packages.sh
to do this automatically.jupyter nbconvert
to convert the notebook into a python script, and then run it through new makefile targets(make run_notebook
andmake clean_notebook
), which are then called in a lit test..pre-commit-config.yaml
) using the pre-commit tool. The pre-commit will scrub notebooks of output and most metadata, but allow one to check the scrubbing before the commit can succeed. The action uses the nbstripout tool. The pre-commit that is installed depends on thevenv
, so I standardized thevenv
name between the two setup paths (quick_setup.sh
andsetup_python_packages.sh
); this will also help standardize information in READMEs about choosing theipykernel
name used for ipython notebooks.VSCode
Even with creating an
ipykernel
based on the mlir-aievenv
, I have not successfully found out how to run the notebook in VS Code. It does work for me locally using a jupyter server started at the root ofmlir-aie
in a terminal where I've run the env setup script.There are two problems: Python path finding
mlir-aie/install/python
and other environment variables set byenv_steup.sh
. The first problem is fairly easily solved through using a.pth
file in thesite-packages
directory of the venv.The other environment variables are more problematic. Things I have tried to get vscode working:
setup_env.sh
script: