"""
Something I would like to know more about is what adding a new feature
would look like on the technical side.
"""
Adding a new feature like a new card could be done entirely in python. The Pyodide coderunner handles the input expression provided by javascript and returns the cards in the form of a JS Map (equivalent to a Python dict). The javascipt loops over all the items in the Map, and evaluates any card if needed. Currently, it is hard-coded in Javascript which cards have to be evaluated. We can update the python logic to include a Boolean value in the dict whether the card needs any evaluation.
Eg: Currently, when JS recieves a card like this,
>>> s.eval('x**2')[2]
{'card': 'roots', 'var': 'x', 'title': 'Roots', 'input': 'solve(x**2 -1 , x)', 'pre_output': 'x', 'parameters': []}
It then sends the following code to run in Python
>>> s.eval_card('roots', 'x**2-x', 'x', {})
{'value': '[0, 1]', 'output': '<ul>\n<li><script type="math/tex; mode=display">0</script></li>\n<li><script type="math/tex; mode=display">1</script></li>\n</ul>'}
Here, the required html is provided to the JS and it is inserted into the proper div for the card.
The JS here follows the same routine for all cards. Hence, adding a new card should be possible to do entirely in python.
"""
Particularly how the pyodide will work and any challenges there.
"""
Pyodide runs on a browser on a service worker, and their documentation have provided a basic API to run Python code in JS.
In my source code, there is a "main" function which deals with the Pyodide API and returns the result. It can evaluate mathematical expressions in different flavours by changing the type parameter in the "main" function.
like for running a pure python command, we can set type = "input"
for generating cards using SymPyGamma object, we can set type = "eval"
and for evaluating a card we can set type = "eval-card"
The major challenge about using Pyodide is transferring Python objects to Javascript. Pyodide usually converts the basic types very well, like Python dicts to JS Maps. I have not experimented much and have currently stuck with strings to share information between JS and Python.
If some change to the UI is to be implemented, it will most probably have to be done in JS. Thankfully, Vue enables us to create components which can be reused. like the same component can be used for the search bar and the context menu (see
https://github.com/sympy/sympy_gamma/issues/188 ) and the expression recieved from each can be executed differently using the type parameter in main function.
In my opinion, we can certainly bring in new contributors for Gamma if we have some guides on how to navigate the code. Learning how to interface with Python codebase was much more work for me than to implement it using JS. Thats why, I have given Phase 2 of GSoC to majorly create documentation for new contributors.
I will update my proposal with some tasks to make it easier to implement features using Python.
Nevertheless, I totally understand if SymPy Gamma is discontinued in the future. I enjoyed working on this project.