oarepo_config.rdm_defaults
oarepo_config.rdm_defaults
InvenioRDM flavour defaults that only make sense for a deployed repository.
Upstream InvenioRDM ships its instance-wide defaults in
invenio_app_rdm.config, which is registered as an invenio_config.module
entry point and therefore loaded into every InvenioRDM instance. OARepo does
not load that module (it would also drag in the stock RDM record UI, routes
and templates that OARepo replaces), so every setting from it that OARepo
still relies on has to be re-applied explicitly:
- inert and corrective defaults (error handlers, schemas, thumbnail sizes,
per-endpoint rate limits, ...) live in
oarepo.initial_rdm_config, and the sitemap of OARepo records inoarepo_rdm.initial_config. Both are entry point configuration modules, so every OARepo application gets them; - this module carries the rest - defaults that switch on enforcement
(CSRF protection, permission caching, account rate limits, database pool
limits) or that depend on the deployment's environment (where the rate
limiter keeps its counters). Applying those to every application would
change the behaviour of each OARepo library's test suite, so they are
applied by
configure_generic_parameters, which only a repository'sinvenio.cfgcalls.
Kept deliberately different from upstream (do not "fix" this):
DB_VERSIONING_USER_MODEL- upstream sets it toNone. It decides whether the SQLAlchemy-Continuumtransactiontable carries auser_idcolumn, i.e. it is baked into the database schema of existing deployments and must not be flipped by a library upgrade.
ratelimit_storage_uri(env: Mapping[str, Any]) -> str
Return the Redis URL the rate limiter should keep its counters in.
Resolution order:
INVENIO_RATELIMIT_STORAGE_URI- used verbatim;INVENIO_CACHE_REDIS_URL(an externally managed Redis) - same server, with the database swapped forINVENIO_REDIS_RATELIMIT_DB;INVENIO_REDIS_HOST/INVENIO_REDIS_PORTandINVENIO_REDIS_RATELIMIT_DB.
INVENIO_REDIS_RATELIMIT_DB defaults to 4.
Source code in oarepo_config/rdm_defaults.py
sqlalchemy_engine_options(env: Mapping[str, Any]) -> dict[str, Any]
Return the database connection (pool) options.
Mirrors upstream InvenioRDM, plus two things taken from Zenodo's
production configuration: the connection is labelled with the host name
(so that it can be told apart in pg_stat_activity) and connection
pooling can be handed over to PgBouncer.
INVENIO_PGBOUNCER_ENABLED=True- do not pool connections in the application at all (NullPool), PgBouncer does it.INVENIO_SQLALCHEMY_ENGINE_OPTIONS- a JSON object merged over the result, e.g.{"pool_size": 10, "pool_pre_ping": true}. Itsconnect_argsare merged key by key.
Source code in oarepo_config/rdm_defaults.py
rdm_defaults(env: Mapping[str, Any]) -> dict[str, Any]
Return the InvenioRDM flavour defaults a deployed repository should run with.
Called by configure_generic_parameters;
anything returned here can still be overridden by a plain assignment
further down in invenio.cfg.