-
Notifications
You must be signed in to change notification settings - Fork 0
Services
To easy development we separated each class into services that could easily be called upon to before any actions we need across the application. The services are as follows
The Parser will use LibCST to interpret the python code the user will type into the User interface. After LibCST has converted the information we can easily use it in our Node-to-Json service to later store the information in the DB and use it for various other purposes.
The executor calls on the built in python method exec()
. It will execute each part of python code that has been passed to the Backend and return either errors of the successful execution with the relevant variables. We will then store this information in the database so they are easy accessible for future use.
To ensure we have the correct information we also execute the code in a Jupyter notebook. We found it easer for the user if the information is returned from a Jupyter notebook, because the individual cells produce output in an IPython-format. This is the same as from the console.
LibCST is used to parse the user input. The information is structured in a way that we can benefit from when creating the nodes. We use it to create usable JSON data which can be used in the further process of creating the edges as well. We can then store and return this information in a more readable format to the user.
As soon as the nodes are stored in the database, the nesting is lost (since each node is a seperate object). Therefore, we implemented a service that can recreate the nested nodes as a JSON when retrieved from the database, which is used in order to execute it properly using different services.
The Edge Creator identifies the connection in-between the nodes, e.g if a > 1:
& print("A is large")
. It uses the generated source code from the parser (so the nodes in JSON format) and will link will all the nodes. Furhtermore, it executes code on-the-go in order to highlight the execution path. The output can be used to create models from the edges which can then be stored in the database.
These classes are primarily for converting information into useable formats when working together with the database models.