Skip to content

Add a basic configuration database

Louis Moureaux requested to merge feature/configuration-database-2022 into main

Description

This adds Python code, based on SQLAlchemy and Alembic, to setup a configuration database and manage it. The database itself is currently a stub and will be expanded later (this MR being the opportunity to discuss how Python code should behave in cmsgemos). I borrowed the Python setup from cmsgemos-analysis, with the understanding that it will eventually be merged into cmsgemos and documentation about Python will be inherited from the merge.

I named the Python module gem because I had run out of imagination and assumed this would be discussed anyway 😉

A new command is introduced, gem-configdb, that will become the main entry point for all database operation on the command line. At the moment, it only exposes a wrapper around the alembic management tool that adds the necessary argument for the configuration to be found.

Related Issue

Couldn't find one for this specific task, is this policy still enforced?

How Has This Been Tested?

Testing will modify your database!

Tested creating the database, adding tables, and rolling back on gem904daq04 using my user database. The relevant command that can be tested with the code from this PR are:

$ poetry run gem-configdb alembic upgrade
$ poetry run gem-configdb alembic current
$ poetry run gem-configdb alembic history

This should work out of the box on gem904daq04, using your own database. Another database can be specified by setting the GEM_CONFIG_DB environment variable to the connection URL (ie something like postgresql://user:password@host:port/database).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Merge request reports

Loading