Skip to content

Global Store and Configuration Implementation

Luis Aleixo requested to merge feature/global_store into master

References: #347 (closed)

This MR introduces the global store and implements a configuration class to manage application-wide data. The Configuration class contains the default values used in the model - upon connection with the Data Service, these values are updated to the most recent configuration.

The key changes are:

  • Singleton Pattern Implementation: The global store now follows the Singleton design pattern to ensure a single instance of the store throughout the application's lifecycle.

  • Configuration Class: A new Configuration class has been introduced to manage application-wide data. This class is responsible for fetching data from the external Data Service and making it accessible to other modules.

  • Data Fetching from API: The populate_from_api method has been enhanced to fetch data from the data service API. Data is retrieved based on environment variables (DATA_SERVICE_CLIENT_EMAIL and DATA_SERVICE_CLIENT_PASSWORD) when the Data Service is enabled.

  • Constants Update: The constants files has been updated to ensure compatibility with the new configuration setup.

Data from GlobalStore is widely imported in the modules.

Additionally, auxiliary methods have been implemented to handle custom distributions with references to other variables and to accommodate schema updates. These methods streamline the data retrieval process and ensure integration with the existing codebase.

During the development process, the data schema has been periodically updated to enhance the configurability of the model. These updates have been integrated into the codebase to ensure compatibility and maintain consistency among pre-defined variables.

This MR enhances code maintainability and improves data handling across the application.

Usage Example (

from import config


class SlidingWindow(WindowOpening):
    Sliding window, or side-hung window (with the hinge perpendicular to
    the horizontal plane).
    def discharge_coefficient(self) -> _VectorisedFloat:
        Average measured value of discharge coefficient for sliding or
        side-hung windows.
        return config.ventilation['natural']['discharge_factor']['sliding']

Usage Example (monte_carlo/

from import config
viable_to_RNA_ratio_distribution = Uniform(
    config.viable_to_RNA_ratio_distribution['low'], config.viable_to_RNA_ratio_distribution['high'])
Edited by Luis Aleixo

Merge request reports