varfish-org / varfish-server

VarFish: comprehensive DNA variant analysis for diagnostics and research
MIT License
43 stars 11 forks source link

Create a consistent configuration cascade/design for existing configuration parameters #1631

Closed xiamaz closed 2 days ago

xiamaz commented 2 months ago

Is your feature request related to a problem? Please describe. Currently certain settings are set site wide, project wide or per user. This is often an issue, as in different scenarious configuration settings might need to be preset at different levels. A more consistent design is needed here to serve different needs that might arise.

Describe the solution you'd like Configurations should be available on site, project, user level. Each should override the previous one.

Describe alternatives you've considered Only defining configurations at site level might not be sufficient for customization.

Only defining configurations at user level does not allow projects to enforce that certain configurations are applied.

Additional context

xiamaz commented 2 months ago

@xiamaz Complete ticket and create more specific tickets for actual design.

xiamaz commented 2 months ago

General configuration design

Currently configuration parameters are defined in many different locations. In the future, a consistent interface should exist to define configuration parameters at the following levels:

Implementation remarks

Configuration models should be defined once and be linked to either site level, project level or user level. When accessing configuration parameters, always the user level should be obtained and this will take project level configuration if no specific user configurations are defined.

stolpeo commented 1 month ago

Current Status

Open Ends

xiamaz commented 1 month ago

Who should be able to edit issues is clear now.

Way forward for complex data types is JSON, we just need to find the correct data type to store in SODAR core.

Configuration cascade is:

We should collect configuration parameters in documentation and define their configurability regarding these four aspects. New configuration parameters need to always update documentation first.

Currently open tasks:

stolpeo commented 1 month ago

RE: datatypes in SODAR core: https://github.com/bihealth/sodar-core/issues/1439

stolpeo commented 1 month ago

Currently existing configurations and where they live

Site-wide (environment variables - require server restart)

Site-wide (SiteAppPlugin)

Project-specific (ProjectAppPlugin scope PROJECT)

Project-specific (other)

Project-user-specific (ProjectAppPlugin scope PROJECT_USER)

User-specific (SiteAppPlugin or ProjectAppPlugin scope USER)

stolpeo commented 1 month ago
stolpeo commented 1 month ago

RE: datatypes in SODAR core: apparently JSON already exists. String max length is 255 but will be bumped in the next version.

stolpeo commented 1 month ago

Editing SODAR core app settings is possible via the AppSettingAPI. This allows us to build an interface around that. The more complex SiteApp settings can receive a link-out.

from projectroles.app_settings import AppSettingAPI
app_settings = AppSettingAPI()
app_settings.get('app_name', 'setting_name', project_object)
stolpeo commented 1 month ago

Technically all settings can that can fit in a JSON dict can be registered as settings in an ProjectAppPlugin or SiteAppPlugin. The hierarchy can be derived from the scope. Currently there are no interfering settings where this would come into play.

stolpeo commented 4 weeks ago

Implementation draft

holtgrewe commented 3 weeks ago

Dimensions of sodar-core configuration:

  1. Where does a setting name/key live? Choices: site-wide app, or project-app
  2. What is the scope? Choices: project, user, project AND user
    • site-wide app (always implicit: project=None)
      • user=obj => editable by user
      • user=None => global configuration setting editable by admin only
    • project-wide app
      • project=None, user=obj => editable by user
      • project=obj, user=obj => editable by user
      • project=obj, user=None => editable by project owner/delegate

What are default values not stored in the database?

  1. Factory defaults hard-coded in Python (change requires container rebuild & redeploy)
  2. Overrides for factory defaults configured in environment variables (change requires server restart)
xiamaz commented 3 weeks ago

Discussion 27.06.2024

stolpeo commented 2 weeks ago

I just pushed the first implementation of the cascaded configuration parameter design (WIP).

It is based on parameter names in SODAR core app_settings that end on

__site | __user | __project_user | __user

This allows us to use the same parameter name throughout all levels and establish a cascade of what value is returned, depending if a parameter is being set on a certain level. The cascade is as follows:

site < user < project < project_user

Currently, it is accessible through an REST API which defines 6 endpoints:

All endpoints except the api/all ones have also PUT and PATCH methods and can take a ?a=reset with the GET which deletes all settings in the scope which will make it return default values set in the app_settings. The api/all endpoints only return values and differentiate whether a project uuid has been passed or not. In that case it will return project-specific and project-user-specific values, otherwise defaults.

The Settings API has different functions to return setting objects to:

For now the implementation is stalled because I need more input:

What remains is when a parameter is configured across all scopes, when should it return a setting and when a default? The SODAR core AppSettingsAPI returns a value when a parameter is queried, either the set value or the default. It is only distinguishable with a trick (looking up the existence in the AppSetting table).

I could construct something that looks whether a parameter is set on a level and if not return the default of the lowest (least worth) level possible, but I don't know if this intended or if we currently run into something that is not solvable easily. Maybe parameters shouldn't live across all scope levels, or only project and project-user are connected and site and user.

@holtgrewe @xiamaz

xiamaz commented 2 days ago

Discussion 18.07.2024

First focus on improving filter presets:

After discussion, this can be closed.

Post-mortem: complex tickets only with very specific use cases in the future