Hi Chris,
I’m doing some refactoring of our python experiment code now, so I’m thinking a bit more about MWorks and Python.
It’s now been a number of years since I sent the below, and you’ve implemented many of these. 1 and 2 below have turned out to be very helpful for us.
I have one small and one larger point to ask about.
Small: did you ever get to my third bullet below – a Python conduit function that returns the current state of a variable? Right now I register a callback for every variable and record all of their values, in Python. That would probably be better done in C++ on the Python side of the conduit (as I assume the client does with the stream of events from the server). Do you agree?
Large: Before I dig into Python over the next few days, I want to consider my lab’s next steps with MWorks and Python over the next 1-3 years. I see three options.
- Keep slogging along along with the Python bridge/conduit.
- Put our Python code inside MWServer (using the feature you implemented to let MWServer run Python code).
- Think about ways to run experiments, and define and call MWorks objects/actions from Python.
Details, pros/cons:
-
Keep slogging along along with the Python bridge/conduit.
Pro: Minimal engineering work for me up front
Con: Latency between Client and Python is long (50 ms with a sometimes longer tail). Lots of variable callbacks, putting load on the single-threaded Py interpreter. (fixable, see small pt above). Syncing XML and Python is cumbersome and errorprone.
Still have to deal with non-Python syntax and parser, which slows down our development. -
Put our Python code inside MWServer (using the feature you implemented to let MWServer run Python code).
Pro: Hopefully Python call latency is much shorter (but needs testing). Variable callback processing load goes away.
Con: Engineering up front for me. Need to figure out system python packages, install and sync across machines. Might Python need to be called at parse time? If so need to work with Chris. Have to debug timing - will all Python dispatch and simple statements be as fast as the XML?
Still have to deal with non-Python syntax in XML and parser. -
Think about ways to run expts and call MWorks objects from Python
Con: Engineering up front for me. Chris and Jim don’t really want to do this. Even if they agree, takes potentially a lot of Chris’s time (my lab can deal with a few months delay, though). Python syntax not a great fit for state machine. Have to debug timing - will all Python dispatch and simple statements be as fast as the XML?
Pro: Can probably use anaconda, which is newer and easier to sync across machines. Can use Python syntax to do conditionals, variable assignment, loops, subfunctions, numpy – makes our experiments much more maintainable and readable. Latency issues go away (but timing issues same as (2)).
Any comments? Happy to talk. Arash if you’d like to be part of the convo please let us know.
Mark