The following sections are aimed at developers trying to contribute to MegaQC.
Please follow the Development guidelines to install a development ready version of MegaQC. You should also be aware of the detailed megaqc package and MegaQC API Reference. Next, some technical details regarding the front and backend are explained.
The Python backend is written in flask, which determines the structure of the project.
MegaQC uses SQLAlchemy to handle database access, which means it can integrate with any SQL database that it supports. For development this will likely be SQLite.
Database schema migrations¶
You need to generate a new migration whenever the database schema (ie any models class) changes. To generate a migration:
cd megaqc export FLASK_APP=wsgi.py flask db upgrade # Update to the latest migration flask db migrate
MegaQC actually has two APIs. The first, older API is accessed at
/api, and the code for this API is located in megaqc/api.
This API is implemented using regular flask views.
However, all future development should be done on the newer REST API.
This is accessed at
/rest_api/v1, and the code for it is located in
megaqc/rest_api. This API is composed of views, located in
views.py. These view classes, which rely on flapison, each
define an SQLAlchemy model that defines how to access the data, and a
Marshmallow schema, which defines how to serialize and deserialize the
data to JSON. The Marshmallow schemas themselves are defined in
schemas.py. For more information, refer to the flapison documentation.
Python tests are located in the python_tests folder. Please note that
pytest test. Every new URL should be tested, although since new
pages are likely to rely on React and the REST API, testing can mostly
be done inside test_api.py, which tests all REST API endpoints.
However, the newer React pages instead render a special template, called react.html, which is a very simple page that acts as the entry point for the React code, which handles all layout and logic.
directory, which currently has one root-level
.js file for each
React page that then imports other components to use.
Note that all new pages going forward should be written using React, to improve the maintainability of the frontend.
Building the documentation locally¶
The MegaQC documentation requires
An installation of MegaQC to fetch the API endpoints and the Click commands.
All dependencies specified in the docs requirements.txt. Install them by invoking:
pip install -r docs/requirements.txt.
After having installed all requirements run
make api-docs && make html in the
html files are found in the
Simply open a generated
html file in your favorite browser to read the documentation.
Publishing the documentation¶
On pushes to the
master branch, the documentation is automatically built and pushed
gh-pages branch. The static html files on this branch are then deployed
to Github Pages and displayed to the outside world.
All of this is done with the Publish Docs Github Actions workflow <https://github.com/ewels/MegaQC/blob/master/.github/workflows/publish_docs.yaml>.
MegaQC Modules Overview¶
- megaqc package
- megaqc.api package
- megaqc.model package
- megaqc.public package
- megaqc.report_plot package
- megaqc.rest_api package
- megaqc.rest_api.content module
- megaqc.rest_api.fields module
- megaqc.rest_api.filters module
- megaqc.rest_api.outlier module
- megaqc.rest_api.plot module
- megaqc.rest_api.schemas module
- megaqc.rest_api.utils module
- megaqc.rest_api.views module
- megaqc.rest_api.webarg_parser module
- Module contents
- megaqc.user package
- megaqc.utils package
- megaqc.app module
- megaqc.cli module
- megaqc.commands module
- megaqc.compat module
- megaqc.database module
- megaqc.extensions module
- megaqc.scheduler module
- megaqc.settings module
- megaqc.wsgi module
- Module contents