You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "mistercrunch (via GitHub)" <gi...@apache.org> on 2025/07/17 17:56:21 UTC
[PR] feat: enhance flask config system with derived class providing database support + refactor [superset]
mistercrunch opened a new pull request, #34210:
URL: https://github.com/apache/superset/pull/34210
## Summary
This PR augments the Flask-based configuration framework for Superset
that modernizes how configuration is handled, documented, and accessed.
The new system provides multi-layered configuration support with
structured metadata and improved developer/operator experience.
## Key Changes
### 🔧 Enhanced Configuration System
- **SupersetConfig class** - Extends Flask's Config with rich metadata
support
- **Environment variable integration** - Uses Flask's
`from_prefixed_env()` with `SUPERSET__` prefix
- **Configuration priority** - Defaults → Environment variables → User
config files
- **Structured metadata** - Replaces comment-based docs with JSON schemas
### 📚 Dynamic Documentation
- **Auto-generated tables** - Configuration reference built from metadata
- **Environment variable examples** - Ready-to-use export statements
- **CLI introspection** - `superset config show/get/env-examples` commands
- **Source tracking** - Shows where each setting comes from
### 🗃️ Database Integration Foundation
- **Settings model** - Database table for runtime configuration
- **Settings DAO** - Following existing Superset patterns
- **Database migration** - Creates settings table structure
### 🔧 Code Quality Improvements
- **Consistent JSON handling** - Uses `superset.utils.json` throughout
- **Proper git history** - Used `git mv` to preserve file history
- **Linter compliance** - Follows Superset coding standards
## Examples
### Environment Variables
```bash
# Basic settings
export SUPERSET__ROW_LIMIT=100000
export SUPERSET__SQLLAB_TIMEOUT=60
# Complex JSON values
export SUPERSET__FEATURE_FLAGS='{"ENABLE_TEMPLATE_PROCESSING": true}'
# Nested configuration
export SUPERSET__THEME_DEFAULT__token__colorPrimary="#1890ff"
CLI Commands
# Show all configuration with sources
superset config show --verbose
# Get environment variable examples
superset config env-examples
# Get specific setting
superset config get ROW_LIMIT
Dynamic Documentation
- Configuration tables auto-generate from metadata
- Environment variable examples with copy-to-clipboard
- Category-based filtering and organization
Test Plan
- Environment variables load correctly with SUPERSET__ prefix
- Configuration precedence works as expected
- CLI commands function properly
- Database migration creates settings table
- Documentation builds with dynamic tables
- Linter passes with proper JSON imports
- Git history preserved for moved files
Future Considerations
- Database-backed settings - Complete runtime configuration without restarts
- Admin UI - Web interface for configuration management
- Settings validation - Enforce metadata constraints
- API endpoints - REST API for configuration access
- Settings caching - Performance optimization for database settings
- Migration tools - CLI commands for settings import/export
This foundation enables future enhancements while maintaining complete
backward compatibility and following Superset's established patterns.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat: enhance flask config system with derived class providing database support + refactor [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch closed pull request #34210: feat: enhance flask config system with derived class providing database support + refactor
URL: https://github.com/apache/superset/pull/34210
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat: enhance flask config system with derived class providing database support + refactor [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #34210:
URL: https://github.com/apache/superset/pull/34210#issuecomment-3090996976
Noting that this is very drafty still ... Might change quite a bit as I bump into walls.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat: enhance flask config system with derived class providing database support + refactor [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #34210:
URL: https://github.com/apache/superset/pull/34210#issuecomment-3097702397
@claude can you summarize what is happening in this PR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat: enhance flask config system with derived class providing database support + refactor [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on code in PR #34210:
URL: https://github.com/apache/superset/pull/34210#discussion_r2244125312
##########
docs/docs/configuration/configuring-superset.mdx:
##########
@@ -97,6 +114,102 @@ for more information on how to configure it.
At the very least, you'll want to change `SECRET_KEY` and `SQLALCHEMY_DATABASE_URI`. Continue reading for more about each of these.
+## Environment Variables Configuration
+
+For containerized deployments and CI/CD pipelines, Superset supports configuration through environment variables. This is particularly useful for:
+
+- **Docker deployments** - Configure containers without rebuilding images
+- **Kubernetes environments** - Use ConfigMaps and Secrets
+- **CI/CD pipelines** - Set configuration dynamically based on environment
+- **Development workflows** - Override settings locally without changing files
+
+### Environment Variable Format
+
+All Superset environment variables must use the `SUPERSET__` prefix (note the double underscore):
+
+```bash
+# Basic settings
+export SUPERSET__ROW_LIMIT=100000
+export SUPERSET__SQLLAB_TIMEOUT=60
Review Comment:
one challenge with env vars is you might want to configure a master `.env` file that configures multiple services and there can be collisions. Though prefixing for the new config system would be great. We do have support for SOME env vars, but I think they're all hard-coded. Good point though that we'll need to support those, maybe a deprecated env var mapping system with warning lie "`DB_NAME` is getting deprecated, please user SUPERSET__METADATA_DB_NAME" or something like that
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat: enhance flask config system with derived class providing database support + refactor [superset]
Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #34210:
URL: https://github.com/apache/superset/pull/34210#discussion_r2216061361
##########
docs/docs/configuration/configuring-superset.mdx:
##########
@@ -97,6 +114,102 @@ for more information on how to configure it.
At the very least, you'll want to change `SECRET_KEY` and `SQLALCHEMY_DATABASE_URI`. Continue reading for more about each of these.
+## Environment Variables Configuration
+
+For containerized deployments and CI/CD pipelines, Superset supports configuration through environment variables. This is particularly useful for:
+
+- **Docker deployments** - Configure containers without rebuilding images
+- **Kubernetes environments** - Use ConfigMaps and Secrets
+- **CI/CD pipelines** - Set configuration dynamically based on environment
+- **Development workflows** - Override settings locally without changing files
+
+### Environment Variable Format
+
+All Superset environment variables must use the `SUPERSET__` prefix (note the double underscore):
+
+```bash
+# Basic settings
+export SUPERSET__ROW_LIMIT=100000
+export SUPERSET__SQLLAB_TIMEOUT=60
Review Comment:
I think this was for backwards compatibility with existing config files and not to mess with other env variables, but shouldn't the same configuration options have the same name?
##########
docs/docs/configuration/configuring-superset.mdx:
##########
@@ -7,13 +7,30 @@ version: 1
# Configuring Superset
-## superset_config.py
+## Configuration Overview
+
+Superset provides a flexible, multi-layered configuration system that supports:
+
+1. **File-based configuration** - Traditional Python configuration files
+2. **Environment variables** - For containerized deployments and CI/CD
+3. **Database-backed settings** - Runtime configuration changes (coming soon)
+4. **Structured metadata** - Rich documentation and validation schemas
+
+### Configuration Priority
+
+Configuration values are loaded in the following order (later values override earlier ones):
+
+1. **Default configuration** - Built-in defaults from `superset/config_defaults.py`
+2. **Environment variables** - Values prefixed with `SUPERSET__`
+3. **User configuration file** - Your custom `superset_config.py` file
Review Comment:
I think order of these two should be swapped
##########
superset/cli/config.py:
##########
@@ -0,0 +1,171 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Configuration introspection CLI commands."""
+
+import re
+from typing import Any
+
+import click
+import yaml
+from flask.cli import with_appcontext
+
+from superset import app
+
+
+def serialize_config_value(value: Any) -> Any:
+ """Serialize config values for YAML output, handling callables and objects."""
+ if callable(value):
+ name = value.__name__ if hasattr(value, "__name__") else repr(value)
+ return f"<callable: {name}>"
+ elif hasattr(value, "__module__") and hasattr(value, "__name__"):
+ return f"<object: {value.__module__}.{value.__name__}>"
+ elif isinstance(value, type):
+ return f"<class: {value.__module__}.{value.__name__}>"
+ else:
+ try:
+ # Try to serialize with yaml to check if it's serializable
+ yaml.safe_dump(value)
+ return value
+ except yaml.YAMLError:
+ return repr(value)
+
+
+def get_config_source(key: str) -> str:
+ """Determine where a config value comes from."""
+ import os
+
+ # Check if it's from environment variables (with double underscore prefix)
+ env_key = f"SUPERSET__{key}"
Review Comment:
Oh, it also works to differentiate between env and config files
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat: enhance flask config system with derived class providing database support + refactor [superset]
Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on PR #34210:
URL: https://github.com/apache/superset/pull/34210#issuecomment-3141076605
@rusackas I am looking at your pull request. The description will be updated shortly. In the meantime, please do not edit the description until I have finished writing mine.
[](67fe7a14-3ee2-4ee2-b24b-3055580a3ade)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat: enhance flask config system with derived class providing database support + refactor [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #34210:
URL: https://github.com/apache/superset/pull/34210#issuecomment-3141076239
/korbit-generate-pr-description
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat: enhance flask config system with derived class providing database support + refactor [superset]
Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on PR #34210:
URL: https://github.com/apache/superset/pull/34210#issuecomment-3084945253
Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment `/korbit-review`.
> Your admin can change your review schedule in the [Korbit Console](https://app.korbit.ai/settings)
[](36b784e1-f76c-40e8-be69-286ab69abc7d)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat: enhance flask config system with derived class providing database support + refactor [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #34210:
URL: https://github.com/apache/superset/pull/34210#issuecomment-3141071837
I wonder if @dosu can recap the PR for us.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org