Settings in Edgy¶
Have you ever wished you could centrally control migrations, media files, shell behavior, and runtime tuning? Edgy was built with that in mind.
Settings are plain Pydantic BaseSettings classes, so they are typed, extensible, and easy to override.
Edgy Settings Module¶
Edgy uses one environment variable to locate its settings class:
- EDGY_SETTINGS_MODULE
EDGY_SETTINGS_MODULE¶
Edgy reads EDGY_SETTINGS_MODULE in the format:
path.to.module.SettingsClass
If it is not set, Edgy uses the internal default EdgySettings.
Custom Settings¶
To create your own settings, inherit from EdgySettings (or TenancySettings for tenancy-focused projects) and override only what you need.
from typing import Optional
from edgy import EdgySettings
from ravyn.conf.enums import EnvironmentType
class MyCustomSettings(EdgySettings):
"""
My settings overriding default values and add new ones.
"""
environment: Optional[str] = EnvironmentType.TESTING
# new settings
my_new_setting: str = "A text"
Practical Preload Example¶
If your app instance is set in myproject.main, you can preload it once and run commands without passing --app every time.
from edgy.conf import EdgySettings
class MyCustomSettings(EdgySettings):
preloads = ("myproject.main",)
Then run:
$ EDGY_SETTINGS_MODULE=myproject.configs.settings.MyCustomSettings edgy shell
$ EDGY_SETTINGS_MODULE=myproject.configs.settings.MyCustomSettings edgy makemigrations
For discovery behavior details, see Application Discovery.
Runtime Resolution Map¶
flowchart TD
A["Process starts"] --> B{"EDGY_SETTINGS_MODULE set?"}
B -- Yes --> C["Load custom settings class"]
B -- No --> D["Load default EdgySettings"]
C --> E["Apply preloads and extensions"]
D --> E
E --> F{"Instance already set?"}
F -- Yes --> G["Reuse instance"]
F -- No --> H["Use --app / EDGY_DEFAULT_APP / autodiscovery"]
Danger
Exercise caution when overriding settings, as it may break functionality.
What You Can Configure¶
Core Runtime¶
-
preloads: Modules loaded early. Supports
moduleandmodule:callable.Default:
() -
extensions: Monkay extensions loaded by Edgy.
Default:
() -
allow_auto_compute_server_defaults: Enables implicit server-default handling for supported fields.
Default:
True
Migration Settings¶
-
allow_automigrations: Allow automatic migration execution during registry startup when configured.
Default:
True -
multi_schema: Multi-schema migration mode (
False,True, or regex/pattern string).Default:
False -
ignore_schema_pattern: Pattern for ignored schemas during multi-schema operations.
Default:
"information_schema" -
migrate_databases: Databases included in migrations (
Nonemeans default/main DB).Default:
(None,) -
migration_directory: Path to your migration directory.
Default:
"migrations/" -
alembic_ctx_kwargs: Extra kwargs forwarded to Alembic context.
Default:
{"compare_type": True, "render_as_batch": True}
Media & Storage Settings¶
-
file_upload_temp_dir: Optional temporary upload directory.
Default:
None -
file_upload_permissions: Default file mode for uploaded files.
Default:
0o644 -
file_upload_directory_permissions: Default directory mode for upload folders.
Default:
None -
media_root: Filesystem location where media is stored.
Default:
"media/" -
media_url: URL prefix used by storages for generated file URLs.
Default:
"" -
storages: Storage backend mapping. The
defaultstorage is used by file/image fields unless overridden.Default backend:
edgy.core.files.storage.filesystem.FileSystemStorage
ORM Concurrency Settings¶
-
orm_concurrency_enabled: Global switch for internal ORM concurrency limits.
Default:
True -
orm_concurrency_limit: Max concurrency for high-level fan-out operations (prefetch/lazy relation loading).
Default:
10 -
orm_row_prefetch_limit: Concurrency limit for row-level prefetch workloads.
Default:
5 -
orm_clauses_concurrency_limit: Concurrency limit for dynamic clause evaluation.
Default:
20 -
orm_registry_ops_limit: Concurrency limit for registry-level operations.
Default:
10
Shell Settings¶
-
ipython_args: Arguments passed to IPython in
edgy shell.Default: derived from
IPYTHON_ARGUMENTS, fallback"--no-banner" -
ptpython_config_file: Configuration file for
edgy shell --kernel ptpython.Default:
"~/.config/ptpython/config.py"
Admin Settings¶
- admin_config: Lazy-loaded
AdminConfigobject with admin-related options such as:admin_prefix_url,admin_extra_templates,title,menu_title,dashboard_title,favicon,sidebar_bg_colour,SECRET_KEY.
For details see Admin.
Tenancy Settings¶
If you inherit from TenancySettings, you also get tenancy-specific settings like:
auto_create_schemaauto_drop_schematenant_schema_defaulttenant_modeldomaindomain_nameauth_user_model
For details see Contrib Tenancy.
How to Use It¶
Using the example above (myproject.configs.settings.MyCustomSettings):
$ EDGY_SETTINGS_MODULE=myproject.configs.settings.MyCustomSettings edgy <COMMAND>
Optional prerequisite: set one of the preload imports to the application path. This way you can skip providing the --app parameter or EDGY_DEFAULT_APP.
Practical Calls¶
Starting the default shell:
$ EDGY_SETTINGS_MODULE=myproject.configs.settings.MyCustomSettings edgy shell
Starting PTPython shell:
$ EDGY_SETTINGS_MODULE=myproject.configs.settings.MyCustomSettings edgy shell --kernel ptpython
Creating the migrations folder:
$ EDGY_SETTINGS_MODULE=myproject.configs.settings.MyCustomSettings edgy init
Generating migrations:
$ EDGY_SETTINGS_MODULE=myproject.configs.settings.MyCustomSettings edgy makemigrations
Applying migrations:
$ EDGY_SETTINGS_MODULE=myproject.configs.settings.MyCustomSettings edgy migrate