This PR includes changes necessary for updating to Python 3 and Django 2.2 LTS to work with the newest RMG.
The update can be divided into several stages:
Futurize and PEP-8 formatting change.
This stage was mostly done by the futurize module and IDE autopep8 module. Python3 updates are changes mainly corresponding to dict Class, encoding/decoding, etc. For renaming for PEP-8, most variables names were changed to lowercase_with_underscore, while the method names are still kept as Camel format.
Renaming
This stage was done with the assist of rmg2to3 module. The major changes are correcting the names of the RMG dependent functions and modules.
Fixes before update Django
In this stage, a lot of effort had been put on fixing the bugs related to name changes, including wrong RMG dependence names, inconsistent variable names among template/model/view. Besides, I double-checked the encoding/decoding process and made several changes according to Django py2/3 transition section https://docs.djangoproject.com/en/1.11/topics/python3/. After this stage, the most function of the website was working, and only several minor issues remained.
Update to Django 2.2 LTS
The most effort was put on making sure we were using the right way to call the Django modules and functions. Some references, like https://eldarion.com/blog/2017/12/26/10-tips-upgrading-django-20/, helped me figure out what could be the major changes. In Django 2.2, it is easier and more flexible to assign URL patterns with path and re_path. Currently, I only changed all url method to re_path method, since they work in the same way (taking regex). In the future, we can simplify the URL patterns with path indeed. Afterward, the website worked almost the same as the website before Django updating.
Fixes before deploying the website on the server
According to the website unit test and my manual test. Two major thing needs to be fixed. (1) the molecule image (both png/svg). According to the test, there exists an incompatibility between the Django (python3 module) and cairocffi regardless of the package versions we are using. surface object created by cairocffi cannot write to the httpResponse in a desirable way. (2) The flux diagram generation module is influenced by the website database status. The issue was concealed in the previous unit test, only because the past unit test was taking in a different sequence (tests of the database first, which actually makes the database loaded). Besides, requirements, Travis and environment files are changed.
Fixes after deploying the website on the server
Some bugs didn't found from unit tests and manual tests. Besides, support of ArrheniusBM Class was added in a similar way as ArrheniusEP.
Current Status:
This branch is now running on the rmg server (https://rmg.mit.edu) with RMG-Py (Python 3 version) and Django 2.2 backend.
This PR includes changes necessary for updating to Python 3 and Django 2.2 LTS to work with the newest RMG.
The update can be divided into several stages:
Futurize and PEP-8 formatting change.
dict
Class, encoding/decoding, etc. For renaming for PEP-8, most variables names were changed to lowercase_with_underscore, while the method names are still kept as Camel format.Renaming
Update to Django 2.2 LTS
path
andre_path
. Currently, I only changed allurl
method tore_path
method, since they work in the same way (taking regex). In the future, we can simplify the URL patterns withpath
indeed. Afterward, the website worked almost the same as the website before Django updating.Fixes before deploying the website on the server
Django
(python3 module) andcairocffi
regardless of the package versions we are using.surface
object created bycairocffi
cannot write to thehttpResponse
in a desirable way. (2) Theflux diagram generation
module is influenced by the website database status. The issue was concealed in the previous unit test, only because the past unit test was taking in a different sequence (tests of the database first, which actually makes the database loaded). Besides, requirements, Travis and environment files are changed.Fixes after deploying the website on the server
ArrheniusBM
Class was added in a similar way asArrheniusEP
.Current Status: This branch is now running on the rmg server (https://rmg.mit.edu) with RMG-Py (Python 3 version) and Django 2.2 backend.