Skip to content

jbyuki/ntpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ntpy

ntpy is a server which runs literate python designed for the experimentation of realtime applications.

work-in-progress

Motivation

Code experimentation with tools such as Jupyter notebook has proved its usefulness in everyday programming many times that I'm fully convinced by it for quick and dirty experimentation. It provides sort of a middle ground between, on one end, the simple REPL and on the other end, the .py script file. It still keeps all its state like the REPL but also provides the means to write relatively complex code in a single cell. State keeping is critical for experimentation as it provides a way to endlessly manipulate the data until we are satisfied without the need to rerun the entire process everytime. However one critcally lacking feature in my opinion is the ability to experiment with realtime applications. Realtime application by principle, usually contain a main loop which needs to run endlessly. Obviously running directly a endless loop in a cell is a bad idea. There are ways to workaround this such as running the loop in a separate thread and display the realtime application in a widget for instance, if possible. However this adds a heavy abstraction layer which hinders direct manipulation of the said realtime application.

The main idea of ntpy is to instead run literate python code. For example, the code block for a main loop (written using the v2 ntangle syntax as explained here):

;; main loop
while True:
	; read io
	; process
	; show
	ntpy.sleep()

In a first phase the code block for the main loop is sent, subsequently, the user could define the read io section and send the corresponding code:

;; read io
x,y,z = sensor.read()

The read io reference in the main loop section would now point to the newly added read io section and execute it on its next iteration, thus effectively modifying the realtime code while its running. This shows the basic principle behind ntpy.

Releases

No releases published

Packages

No packages published

Languages