Skip to content

System side python code using %python and %%python magics#30

Merged
brentru merged 3 commits intoadafruit:masterfrom
qwertimer:master
Mar 17, 2021
Merged

System side python code using %python and %%python magics#30
brentru merged 3 commits intoadafruit:masterfrom
qwertimer:master

Conversation

@qwertimer
Copy link
Copy Markdown

CircuitPython REPLs are an excellent way to do testing of code during development. But once it is tested you need to save it to a code.py file. These magics allow you to run python code on the system rather than on the microcontroller. The main focus of this development was to incorporate the nbdev (https://github.com/fastai/nbdev) pipeline. nbdev automatically saves your code cells to a .py file when the notebook2script file is run. This script creation can be tailored to create code.py files for the microcontroller with cells being added to the file based on #export command. Further to this i envision this added functionality to allow the user to interact with the microcontroller by collecting and parsing data in real time and creating plots and figures from the data during development.

@brentru brentru self-requested a review March 15, 2021 13:11
@brentru
Copy link
Copy Markdown
Member

brentru commented Mar 15, 2021

@qwertimer Thank you for incorporating nbdev into this project! I have a few questions:

@qwertimer
Copy link
Copy Markdown
Author

@qwertimer Thank you for incorporating nbdev into this project! I have a few questions:

* Your instructions mention installing nbdev - should we require nbdev as a dependency in the setup.py (https://github.com/adafruit/circuitpython_jupyter_kernel/blob/master/setup.py)?

There is not a requirement to install nbdev. The development of these magics is to allow python code to be run on the host. I am utilising this magic to implement nbdev based development.

* Are the `%python` and `%%python` eval magics part of Jupyter, or did you name them?

The python magics arent part of jupyter as the circuitpython kernel catches all commands and so i built my own magics similar to %python and %%python in the jupyter kernel. However the jupyter kernel magics run a suubprocess and i ultimately want this code to allow both system side and circuit python code to be run together.

for example - starting a microcontroller collect of a series of sensors then sending these to the notebook through the serial link in the jupyter notebook through the %%python magic the user can then plot in real time sensor data being collected. Further the user can then on the fly modify the uplink data and run a new set of plots.

This is my goal. However at the moment the magics dont output the result to the notebook display and i need to work out how to store the information in the global scope.

@brentru
Copy link
Copy Markdown
Member

brentru commented Mar 17, 2021

Thank you for the clarification. The goal of linking this kernel with CPython is something I've been curious about.

@brentru brentru merged commit b4e1743 into adafruit:master Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants