SimonBiggs / scriptedforms

Quickly create live-update GUIs for Python packages using Markdown and simple HTML elements.
Apache License 2.0
508 stars 34 forks source link

Compatibility with micropython #162

Closed SimonBiggs closed 6 years ago

SimonBiggs commented 6 years ago

Hi @pfalcon,

I've noticed a few users of micropython have also shown interest in ScriptedForms. Is there anything I can do to make the use of ScriptedForms easier with micropython? One thing I can think of is ensuring support for Python 3.4. Would that be correct?

I don't use micropython myself, so I'm not even sure if ScriptedForms works on it at this current point in time. I just figured it was worth reaching out given the number of people who seem to be finding ScriptedForms who appear to be users of micropython.

Cheers, Simon

robmarkcole commented 6 years ago

Is the idea that scriptedforms could be used as an interactive display for a micropython board on the network?

pfalcon commented 6 years ago

@SimonBiggs, interesting, I thought this was a reply to my ticket, because I have a habit of dropping such tickets around like "can this run with MicroPython?" ;-).

Well, I did find ScriptedForms some time ago, surely find it interesting and my first motion in such cases is usually to look what would it take to run such a project on MicroPython. In this case, it was immediately clear that there're no chance to run ScriptedForms on MicroPython (using it as an interpreter), due to dependencies: https://github.com/SimonBiggs/scriptedforms/blob/master/setup.py#L36 .

It might be possible to use ScriptedForms with MicroPython, i.e. use it to pull data and/or make requests to a MicroPython-powered board/system. I'm not sure how exactly to do that, it would depend on a particular usecase.

Also, for reference, there were some work on using MicroPython boards with Jupyter Notebook (I'm not sure if that helps, as I'm not sure about the internal ScriptedForms architecture):

SimonBiggs commented 6 years ago

If the dependency issues are numpy, pandas, and matplotlib, it could be possible to have a reduced functionality base version of ScriptedForms which does not have those dependencies.

The loss of functionality would primarily be the loss of the "table" variable.

The watchdog package provides the section-filechange feature as well as the feature that auto redraws the page when the template file changes. It is conceivable the features that require watchdog could also be pulled out into a plugin style package. It would take quite a bit of reworking, but it is reworking that should happen to make the code more modular anyway.

The only hard dependency in theory is notebook, which you've shown from those forum posts that people have got working...

Would it be worth my while trying to make it compatible? It wouldn't be a small task teasing the dependent parts into plugin packages. But if it is worthwhile do let me know.

SimonBiggs commented 6 years ago

@robmarkcole if it is possible, then yes I think that's the idea...

SimonBiggs commented 6 years ago

So, from briefly scanning some of those forum posts it seems the key is that the most successful method for the Jupyter Notebook was still running the notebook server on a computer, and then connecting to the board.

https://github.com/hoihu/projects/blob/master/uPy/jupyter/uPy-tutorial1.ipynb

So even the foundational dependency of notebook is a show stopper for running on the board.

SimonBiggs commented 6 years ago

Running connected to the board does sound very interesting. I have a little boy, 4 years old. I think that's a good as an excuse as any to pick up a micropython board and do a bit of fiddling.

@pfalcon would something like this be a good one to pick up?

https://www.adafruit.com/product/3213

robmarkcole commented 6 years ago

I can recommend the pycom boards which I used here https://www.hackster.io/robin-cole/micropython-leak-detector-with-adafruit-and-home-assistant-a2fa9e

I also have a https://www.adafruit.com/product/3727

SimonBiggs commented 6 years ago

Also, just confirming, notebook and its dependencies won't work on micropython correct?

https://github.com/jupyter/notebook/blob/e321c80776542b8d6f3411af16f9e21e51e27687/setup.py#L79

If it is at all possible that the notebook server could run on micropython then the Jupyter Notebook team should be contacted as they are currently deciding to drop Python 2.7 support, and possibly 3.4 support. If jupyterlab Notebook can run on micropython however that is a good reason to keep 3.4 support around...

SimonBiggs commented 6 years ago

@robmarkcole That article about making the leak detector is quite awesome :). Thanks for sharing. I really should do some things like that with my kids :).

Have you ever tried connecting to micropython with a notebook server running on your computer? (https://github.com/hoihu/projects/blob/master/uPy/jupyter/uPy-tutorial1.ipynb)

robmarkcole commented 6 years ago

@SimonBiggs Yes interacting with the board via Jupyter is straightforward see https://www.youtube.com/watch?v=UFc0pR2ehiw&t=966s

For medical phys I would imagine having some measurement device (e.g. chamber with voltage readout/serial port) connected to the micropython board, and then use a scriptedform to display the realtime state of the chamber

SimonBiggs commented 6 years ago

I honestly was just thinking it'd be cool to have a few sliders control some lights and make the lights in my sons eyes glow :) But yes, there definitely is opportunities within Medical Physics.

I haven't investigated what readout options our electrometers have...

And yeah, I'm watching that video now :)

SimonBiggs commented 6 years ago

Will wait for further interest.