Skip to content

Structure settings in modules#2499

Draft
niklasmohrin wants to merge 22 commits intoe-valuation:mainfrom
niklasmohrin:topological-settings
Draft

Structure settings in modules#2499
niklasmohrin wants to merge 22 commits intoe-valuation:mainfrom
niklasmohrin:topological-settings

Conversation

@niklasmohrin
Copy link
Copy Markdown
Member

@niklasmohrin niklasmohrin commented Aug 4, 2025

Since we are shipping EvaP via PyPI, using the evap.localsettings module doesn't really cut it anymore. We want to ship the majority of settings as default, but overwrite some of them in the deployment. Furthermore, we may want to have default config values that depend on values overwritten later, and we may want to mix in settings that add to previously defined values. Clearly, we need to implement the nix module system for our settings.

On production (with the current naming, which I want to still change later) it would be used like this:

from evap.settings import default, dev, local_services, open_id, test
from evap.settings_resolver import resolve_settings


class LocalSettings:
    DEBUG = False
    SECRET_KEY = "xxx"  # nosec
    # ... some more required fields


globals().update(resolve_settings([default, open_id, LocalSettings]))

Alternatively, one can also make two Python files, one containing what I put in the LocalSettings class namespace here, and the other just containing globals().update(...) which then also includes the other file.

wip

wip

move side effects out of settings

move driver code into own file and port more settings

working resolver

Use modules instead of classes

format

lint
@niklasmohrin
Copy link
Copy Markdown
Member Author

One can confirm that the same settings are generated by comparing the output of ./manage.py diffsettings before and after. For our local development setup, the settings are identical (up to some module renamings). For CI, the new evap.settings.cisettings have some more values set compared to our previous cp evap/settings_test.py evap/localsettings.py approach, but it does not seem significant and tests still pass, so I don't think we need to change anything.

@niklasmohrin niklasmohrin marked this pull request as ready for review September 23, 2025 15:34
@niklasmohrin
Copy link
Copy Markdown
Member Author

You don't all have to review, but would be good to have more eyes on this :)

Copy link
Copy Markdown
Member

@richardebeling richardebeling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly unpainful to read, given the mental complexity that I felt our discussions about this required. Nice, I like it!

I'll have to play around with it a bit locally when the first round of discussions is through, particularly it's super hard on github to check whether stuff was forgotten when moving code around.

Comment thread evap/development/cisettings.py
Comment thread evap/settings/local_services.py
Comment thread evap/settings/open_id.py
Comment on lines +11 to +12
OIDC_RP_CLIENT_ID = "evap"
OIDC_RP_CLIENT_SECRET = "evap-secret" # nosec
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next level: Can we make these required() iff ACTIVE_OPEN_ID_LOGIN is true? (If not, that's fine with me, just wondering, seems not too hard from my simple mind)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, sounds good

Comment thread evap/settings/schema.pyi
Comment thread evap/evaluation/tests/test_tools.py
Comment thread evap/evaluation/tests/test_tools.py
Comment thread evap/settings/open_id.py

ACTIVATE_OPEN_ID_LOGIN = required()

# replace 'example.com', OIDC_RP_CLIENT_ID and OIDC_RP_CLIENT_SECRET with real values in localsettings when activating
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the ones you would need to change should be part of localsettings.py, I think they don't really make sense in here. Any argument I'm missing for keeping them here?

Comment thread evap/settings_resolver.py
Comment thread evap/settings_resolver.py
Comment thread nix/services.nix
Comment on lines 70 to 71
git submodule update --init
./manage.py compilemessages --locale de
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
git submodule update --init
./manage.py compilemessages --locale de
git submodule update --init
export DJANGO_SETTINGS_MODULE=localsettings
./manage.py compilemessages --locale de

@niklasmohrin niklasmohrin marked this pull request as draft April 19, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants