You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please read and comment on this issue if you are a developer or user of RMG - we need lots of input!
The purpose of this issue is to centralize discussion around a significant change that @JacksonBurns and @jonwzheng are proposing for RMG-database.
Also see the first RIP here: #2684
This issue is styled after the Python Enhancement Proposal (see PEP 733 for an example), thus the name 'RMG Improvement Proposal', or RIP for short.
RMG-database Today
RMG-database is a collection of Python files organized in a layout reflecting their contents. This includes:
statmech, transport, thermo, and solvation- contains libraries of literature results for individual molecules and then groups for making estimates
kinetics - similar to the above, except that groups belong to families which also contain rules and training data for generating said groups and rules.
surface - limited library with some surface data.
reference_sets - actually not Python files, but yml files containing "vetted" values for RMG/Arkane to fit data to perform BACs
quantum_corrections - Python dictionaries containing frequency scale factors, BACs, and AECs
In order to interact with RMG-database, one must have a working installation of RMG-Py and use its associated data classes to access numbers stored here. RMG-Py itself runs Python exec function on these files to load them into global memory, once per process.
Challenges with Today's RMG-database
This format introduces many 'hard' and 'soft' challenges, which are detailed below:
Security risk, because it involves executing arbitrary user input code
It relies on using the global state, which is difficult to debug and itself considered bad coding practice
Accessing RMG-database is only possible via RMG-Py, whose dependency requirements are so restrictive that it functionally forbids running RMG-database with anything else installed
Contributing to RMG-database is difficult since it requires formatted Python files, does not interface with any common data munging software, and as mentioned before is difficult to debug
Loading the entire database is slow, which can be seen when loading a database page for the first time since restart in RMG-website
Much of what we validate in the unit tests for RMG-database can be had for free with a SQL database, examples:
kinetics_check_siblings_for_parents checks that siblings nodes are not also parent nodes, which can easily be validated at creation time in a SQL database
@jonwzheng and I (@JacksonBurns) propose we overhaul RMG-database from the ground up as a SQL database.
To that end, a working demo has been built showing how statmech could be converted into a SQL database, see this repository: https://github.com/JacksonBurns/rmgdb
In short, we do the following for each of the sub-databases in RMG-database that follow the library + family/group setup:
Define a set of Tables which represent each of the RMG Classes that are called within RMG-database, such as LinearRotor, and a 'base' table to hold all the calls to entry in each of the sub-databases. The aforementioned validation can be implemented here using SQL constructs like Triggers, Constraints, Key Relationships, etc
Example of libraries schema
Example of groups schema
exec the files in RMG-database, but trick them into generating our new Tables rather than RMG classes.
Dump the database into a plaintext format like .yml which would replace the Python source files we currently have, like this:
Load the database from the .yml files, enabling users to contribute to RMG-database by just editing the .yml files (proper configuration and formatting can be enforced by GitHub actions).
Critically, this would allow the users to run one-liner commands with only pandas installed to then interact with the RMG-database, like this:
(rmgdb) (base) jackson@jackson-Precision-7540:~/rmgdb/data/rmgdatabase/statmech$ python
Python 3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:23:07) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license"for more information.
>>> import pandas as pd
>>> pd.read_sql("SELECT * FROM statmech_libraries_view", "sqlite:///statmech.db")
id name short_description long_description label ... harmonic_freq_8 harmonic_freq_9 harmonic_freq_10 harmonic_freq_11 harmonic_freq_12
0 0 halogens_G4 B3LYP/GTBas3 HF ... NaN NaN NaN NaN NaN
1 1 halogens_G4 B3LYP/GTBas3 HBr ... NaN NaN NaN NaN NaN
2 2 halogens_G4 B3LYP/GTBas3 HCl ... NaN NaN NaN NaN NaN
3 3 halogens_G4 B3LYP/GTBas3 F2 ... NaN NaN NaN NaN NaN
4 4 halogens_G4 B3LYP/GTBas3 FCl ... NaN NaN NaN NaN NaN
.. ... ... ... ... ... ... ... ... ... ... ...
189 189 halogens_G4 B3LYP/GTBas3 BrC(Br)DC(Br)Br ... 496.116 632.671 752.302 866.301 1587.25
190 190 halogens_G4 B3LYP/GTBas3 ClC(Cl)DC(Cl)Cl ... 538.764 775.262 891.705 968.279 1625.20
191 191 halogens_G4 B3LYP/GTBas3 ClC(Br)DC(Br)Br ... 507.498 664.464 795.117 899.928 1596.78
192 192 halogens_G4 B3LYP/GTBas3 ClC(Cl)DC(Br)Br ... 520.415 715.925 810.937 933.346 1606.58
193 193 halogens_G4 B3LYP/GTBas3 ClC(Cl)DC(Cl)Br ... 528.548 737.885 864.898 949.118 1616.44
[194 rows x 33 columns]
This would make it trivially easy to access RMG-database and its wealth of chemical data.
There are further benefits on the RMG-Py side of things.
Navigating the decision tree structure is dramatically faster than the current setup because it uses the SQL adjacency list layout for storing hierarchical data, enabling tree navigation by simple matching of integers.
Accessing the data in this way will also have a massive positive impact on RMG-Py's memory consumption - the current setup requires each parallel process to load the entire database into memory, whereas this would be shared among all processes and allow easy loading of only the required data.
Next Steps, Drawbacks, and Open Questions
The amount of value of the data (and how difficult it is to get to it) in RMG-database makes this step worth doing on its own.
Part of the reason that the linked demo already exists is because @jonwzheng and I will likely see it to its end even if just for our own usage, since we would like to be able to access RMG-database in other projects.
The purpose for this issue, then, is to discuss what issues this could bring up with RMG-Py and how we can mitigate them during the design process.
Difficulty of Integration with RMG-Py and RMG-website
The database is arguably the most important piece of the RMG-Py-puzzle, and so it is used throughout the source code in many different functions.
This is not a critical issue, since re-implementing any of the needed functionality will just be a matter of effort, but it is worth mentioning.
Also promising is that most of this functionality never changes (i.e., we will always need to find all the ancestors for a given node, a function which would never change), so once we implement it in SQL and wrap it in Python it can just sit.
We would need to update all of our new user documentation. Workshop materials from previous years will also become out-of-date.
More serious is the integration with the various notebooks and scripts people have assembled over the years to create RMG-database. While we can do the best we can to provide examples of changing the main RMG code to work with the new database, things like the group fitting notebooks will need serious overhauls both on the main branch and for people locally, as well as the RMG-website source code.
On that note...
Backwards Compatibility
This would be totally backwards incompatible with previous versions.
Outstanding PRs, as well, would need to be restarted completely in order to work.
...and...
What do we Keep?
This is perhaps the biggest open question.
From our understanding, the libraries (used as lookup tables during RMG simulations) in each of the sub-databases contain data scraped from literature/simulated by us for various chemicals and chemicals reactions - we would definitely keep those.
The training directories, as well as the rules and groups files are less obvious to handle.
We believe that the training reactions can be generated automatically from the libraries, though that has not been done for all meaning that some of them are hand constructed.
Similarly, some of the rules and groups appear to be hand-built whereas others are machine generated.
We ask this question for two reasons - it will inform the design of the database, and because it will determine the scope of the work.
If it turns out that we want a way to automatically refit all the trees whenever we push new data, thus replacing the rules, groups, and training (?), we could incorporate that into this larger effort.
Please let us know your thoughts and any suggestions you have about how to best approach this - especially those related to the kinetics database, specifically the workflow of library -> training -> rules/groups.
After this issue has been opened, we will schedule a board meeting to discuss the way forward.
Thank you!
Important
Please read and comment on this issue if you are a developer or user of RMG - we need lots of input!
The purpose of this issue is to centralize discussion around a significant change that @JacksonBurns and @jonwzheng are proposing for
RMG-database.Also see the first RIP here: #2684
This issue is styled after the Python Enhancement Proposal (see PEP 733 for an example), thus the name 'RMG Improvement Proposal', or RIP for short.
RMG-databaseTodayRMG-databaseis a collection of Python files organized in a layout reflecting their contents. This includes:statmech,transport,thermo, andsolvation- containslibrariesof literature results for individual molecules and thengroupsfor making estimateskinetics- similar to the above, except thatgroupsbelong tofamilieswhich also containrulesandtrainingdata for generating saidgroupsandrules.surface- limited library with some surface data.reference_sets- actually not Python files, butymlfiles containing "vetted" values for RMG/Arkane to fit data to perform BACsquantum_corrections- Python dictionaries containing frequency scale factors, BACs, and AECsIn order to interact with
RMG-database, one must have a working installation ofRMG-Pyand use its associateddataclasses to access numbers stored here.RMG-Pyitself runs Pythonexecfunction on these files to load them into global memory, once per process.Challenges with Today's
RMG-databaseThis format introduces many 'hard' and 'soft' challenges, which are detailed below:
execin this context (and in general) is bad coding practiceRMG-databaseis only possible viaRMG-Py, whose dependency requirements are so restrictive that it functionally forbids runningRMG-databasewith anything else installedRMG-databaseis difficult since it requires formatted Python files, does not interface with any common data munging software, and as mentioned before is difficult to debugRMG-websitekinetics_check_siblings_for_parentschecks that siblings nodes are not also parent nodes, which can easily be validated at creation time in a SQL databasecheck_surface_thermo_libraries_have_surface_attributeschecks that certain entries have expected rows, which we can enforce by simple construction in a SQL databaseOur Proposal and a Working Demo
@jonwzheng and I (@JacksonBurns) propose we overhaul
RMG-databasefrom the ground up as a SQL database.To that end, a working demo has been built showing how
statmechcould be converted into a SQL database, see this repository: https://github.com/JacksonBurns/rmgdbIn short, we do the following for each of the sub-databases in RMG-database that follow the library + family/group setup:
Define a set of Tables which represent each of the RMG Classes that are called within


RMG-database, such asLinearRotor, and a 'base' table to hold all the calls toentryin each of the sub-databases. The aforementioned validation can be implemented here using SQL constructs like Triggers, Constraints, Key Relationships, etcExample of libraries schema
Example of groups schema
execthe files inRMG-database, but trick them into generating our new Tables rather than RMG classes.Dump the database into a plaintext format like
.ymlwhich would replace the Python source files we currently have, like this:.ymlfiles, enabling users to contribute toRMG-databaseby just editing the.ymlfiles (proper configuration and formatting can be enforced by GitHub actions).Critically, this would allow the users to run one-liner commands with only pandas installed to then interact with the
RMG-database, like this:This would make it trivially easy to access
RMG-databaseand its wealth of chemical data.There are further benefits on the
RMG-Pyside of things.Navigating the decision tree structure is dramatically faster than the current setup because it uses the SQL adjacency list layout for storing hierarchical data, enabling tree navigation by simple matching of integers.
Accessing the data in this way will also have a massive positive impact on
RMG-Py's memory consumption - the current setup requires each parallel process to load the entire database into memory, whereas this would be shared among all processes and allow easy loading of only the required data.Next Steps, Drawbacks, and Open Questions
The amount of value of the data (and how difficult it is to get to it) in
RMG-databasemakes this step worth doing on its own.Part of the reason that the linked demo already exists is because @jonwzheng and I will likely see it to its end even if just for our own usage, since we would like to be able to access
RMG-databasein other projects.The purpose for this issue, then, is to discuss what issues this could bring up with
RMG-Pyand how we can mitigate them during the design process.Difficulty of Integration with
RMG-PyandRMG-websiteThe database is arguably the most important piece of the
RMG-Py-puzzle, and so it is used throughout the source code in many different functions.This is not a critical issue, since re-implementing any of the needed functionality will just be a matter of effort, but it is worth mentioning.
Also promising is that most of this functionality never changes (i.e., we will always need to find all the ancestors for a given node, a function which would never change), so once we implement it in SQL and wrap it in Python it can just sit.
We would need to update all of our new user documentation. Workshop materials from previous years will also become out-of-date.
More serious is the integration with the various notebooks and scripts people have assembled over the years to create
RMG-database. While we can do the best we can to provide examples of changing themainRMG code to work with the new database, things like the group fitting notebooks will need serious overhauls both on themainbranch and for people locally, as well as theRMG-websitesource code.On that note...
Backwards Compatibility
This would be totally backwards incompatible with previous versions.
Outstanding PRs, as well, would need to be restarted completely in order to work.
...and...
What do we Keep?
This is perhaps the biggest open question.
From our understanding, the
libraries(used as lookup tables during RMG simulations) in each of the sub-databases contain data scraped from literature/simulated by us for various chemicals and chemicals reactions - we would definitely keep those.The
trainingdirectories, as well as therulesandgroupsfiles are less obvious to handle.We believe that the
trainingreactions can be generated automatically from the libraries, though that has not been done for all meaning that some of them are hand constructed.Similarly, some of the
rulesandgroupsappear to be hand-built whereas others are machine generated.We ask this question for two reasons - it will inform the design of the database, and because it will determine the scope of the work.
If it turns out that we want a way to automatically refit all the trees whenever we push new data, thus replacing the
rules,groups, andtraining(?), we could incorporate that into this larger effort.Please let us know your thoughts and any suggestions you have about how to best approach this - especially those related to the kinetics database, specifically the workflow of library -> training -> rules/groups.
After this issue has been opened, we will schedule a board meeting to discuss the way forward.
Thank you!