| --- | |
| title: Development How-tos | |
| sidebar_position: 7 | |
| --- | |
| <!-- | |
| 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. | |
| --> | |
| # Development How-tos | |
| This guide contains specific instructions for common development tasks in Superset. | |
| ## Contributing to Documentation | |
| The documentation site is built using [Docusaurus](https://docusaurus.io/). All documentation lives in the `docs` folder, written in Markdown format. | |
| ### Local Development | |
| To set up your local environment for documentation development: | |
| ```bash | |
| cd docs | |
| npm install | |
| npm run start | |
| ``` | |
| The site will be available at http://localhost:3000 | |
| ### Build | |
| To create a production build: | |
| ```bash | |
| npm run build | |
| npm run serve # Test the build locally | |
| ``` | |
| ### Deployment | |
| Documentation is automatically deployed when changes are merged to master. | |
| ## Creating Visualization Plugins | |
| Visualization plugins allow you to add custom chart types to Superset. They are built as npm packages that integrate with the Superset frontend. | |
| ### Prerequisites | |
| - Node.js 18+ | |
| - npm or yarn | |
| - A local Superset development environment | |
| ### Creating a simple Hello World viz plugin | |
| 1. **Install the Superset Yeoman generator**: | |
| ```bash | |
| npm install -g @superset-ui/generator-superset | |
| ``` | |
| 2. **Create a new plugin**: | |
| ```bash | |
| mkdir superset-plugin-chart-hello-world | |
| cd superset-plugin-chart-hello-world | |
| yo @superset-ui/superset | |
| ``` | |
| 3. **Follow the prompts**: | |
| - Package name: `superset-plugin-chart-hello-world` | |
| - Chart type: Choose your preferred type | |
| - Include storybook: Yes (recommended for development) | |
| 4. **Develop your plugin**: | |
| The generator creates a complete plugin structure with TypeScript, React components, and build configuration. | |
| 5. **Test your plugin locally**: | |
| ```bash | |
| npm run dev | |
| ``` | |
| 6. **Link to your local Superset**: | |
| ```bash | |
| npm link | |
| # In your Superset frontend directory: | |
| npm link superset-plugin-chart-hello-world | |
| ``` | |
| 7. **Import and register in Superset**: | |
| Edit `superset-frontend/src/visualizations/presets/MainPreset.ts` to include your plugin. | |
| ### Sharing colors in composed charts | |
| `ChartProps.colorScale` accepts an optional `CategoricalColorScale`. A parent | |
| visualization can pass the same scale to its child chart transforms so categories | |
| use consistent colors across the composition. Create a fresh scale for each parent | |
| transformation using the selected color scheme. Child plugins must explicitly use | |
| the supplied scale, falling back to their own scale when it is absent. | |
| Cartodiagram uses this contract with Pie charts to coordinate category colors | |
| across map locations in Explore. | |
| ## Testing | |
| ### Python Testing | |
| Run Python tests using pytest: | |
| ```bash | |
| # Run all tests | |
| pytest | |
| # Run specific test file | |
| pytest tests/unit_tests/test_specific.py | |
| # Run with coverage | |
| pytest --cov=superset | |
| # Run only unit tests | |
| pytest tests/unit_tests | |
| # Run only integration tests | |
| pytest tests/integration_tests | |
| ``` | |
| #### Testing with local Presto connections | |
| To test against Presto: | |
| ```bash | |
| # Start Presto locally using Docker | |
| docker run -p 8080:8080 \ | |
| --name presto \ | |
| -d prestodb/presto | |
| # Configure in superset_config.py | |
| SQLALCHEMY_DATABASE_URI = 'presto://localhost:8080/hive/default' | |
| ``` | |
| ### Frontend Testing | |
| Run frontend tests using Jest: | |
| ```bash | |
| cd superset-frontend | |
| # Run all tests | |
| npm run test | |
| # Run with coverage | |
| npm run test -- --coverage | |
| # Run in watch mode | |
| npm run test -- --watch | |
| # Run specific test file | |
| npm run test -- MyComponent.test.tsx | |
| # Cap the worker pool (default is 80% of cores) on a shared or busy machine | |
| JEST_MAX_WORKERS=2 npm run test -- MyComponent.test.tsx | |
| ``` | |
| ### E2E Integration Testing | |
| We use Playwright for end-to-end testing. | |
| #### Playwright | |
| ```bash | |
| # Navigate to frontend directory | |
| cd superset-frontend | |
| # Run all Playwright tests | |
| npm run playwright:test | |
| # or: npx playwright test | |
| # Run with interactive UI for debugging | |
| npm run playwright:ui | |
| # or: npx playwright test --ui | |
| # Run in headed mode (see browser) | |
| npm run playwright:headed | |
| # or: npx playwright test --headed | |
| # Run specific test file | |
| npx playwright test tests/auth/login.spec.ts | |
| # Run with debug mode (step through tests) | |
| npm run playwright:debug tests/auth/login.spec.ts | |
| # or: npx playwright test --debug tests/auth/login.spec.ts | |
| # Generate test report | |
| npm run playwright:report | |
| ``` | |
| ### Debugging Server App | |
| For debugging the Flask backend: | |
| #### Using PyCharm/IntelliJ | |
| 1. Create a new Python configuration | |
| 2. Set script path to `superset/app.py` | |
| 3. Set environment variables: | |
| - `FLASK_ENV=development` | |
| - `SUPERSET_CONFIG_PATH=/path/to/superset_config.py` | |
| 4. Set breakpoints and run in debug mode | |
| #### Using VS Code | |
| 1. Add to `.vscode/launch.json`: | |
| ```json | |
| { | |
| "version": "0.2.0", | |
| "configurations": [ | |
| { | |
| "name": "Python: Flask", | |
| "type": "python", | |
| "request": "launch", | |
| "module": "flask", | |
| "env": { | |
| "FLASK_APP": "superset/app.py", | |
| "FLASK_ENV": "development" | |
| }, | |
| "args": ["run", "--no-debugger", "--no-reload"], | |
| "jinja": true | |
| } | |
| ] | |
| } | |
| ``` | |
| 2. Set breakpoints and press F5 to debug | |
| ### Debugging Server App in Kubernetes Environment | |
| To debug Flask running in a POD inside a kubernetes cluster, you'll need to make sure the pod runs as root and is granted the `SYS_PTRACE` capability. These settings should not be used in production environments. | |
| ```yaml | |
| securityContext: | |
| capabilities: | |
| add: ['SYS_PTRACE'] | |
| ``` | |
| See [set capabilities for a container](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-capabilities-for-a-container) for more details. | |
| Once the pod is running as root and has the `SYS_PTRACE` capability it will be able to debug the Flask app. | |
| You can follow the same instructions as in `docker compose`. Enter the pod and install the required library and packages: gdb, netstat and debugpy. | |
| Often in a Kubernetes environment nodes are not addressable from outside the cluster. VSCode will thus be unable to remotely connect to port 5678 on a Kubernetes node. In order to do this you need to create a tunnel that port forwards 5678 to your local machine. | |
| ```bash | |
| kubectl port-forward pod/superset-<some random id> 5678:5678 | |
| ``` | |
| You can now launch your VSCode debugger with the same config as above. VSCode will connect to 127.0.0.1:5678 which is forwarded by kubectl to your remote kubernetes POD. | |
| ### Storybook | |
| See the dedicated [Storybook documentation](../testing/storybook.md) for information on running Storybook locally and adding new stories. | |
| ## Contributing Translations | |
| Superset uses Flask-Babel for internationalization. | |
| ### Enabling language selection | |
| Edit `superset_config.py`: | |
| ```python | |
| LANGUAGES = { | |
| 'en': {'flag': 'us', 'name': 'English'}, | |
| 'fr': {'flag': 'fr', 'name': 'French'}, | |
| 'zh': {'flag': 'cn', 'name': 'Chinese'}, | |
| } | |
| ``` | |
| ### Creating a new language dictionary | |
| ```bash | |
| # Initialize a new language | |
| pybabel init -i superset/translations/messages.pot -d superset/translations -l de | |
| ``` | |
| ### Extracting new strings for translation | |
| ```bash | |
| # Extract backend and frontend strings into messages.pot, then update every | |
| # language catalog from it | |
| ./scripts/translations/babel_update.sh | |
| ``` | |
| Run the script rather than `pybabel extract` directly. It passes the keywords | |
| the frontend uses (`t`, `tn`, `tct`), extracts `i18n:` translator comments, | |
| and stamps do-not-translate markers. A bare | |
| `pybabel extract` does none of these. CI's template drift check | |
| (`scripts/translations/check_pot_drift.py`) fails when the template's strings | |
| differ from what the script's extraction finds. | |
| ### Adding context for translators | |
| A translatable string arrives in a catalog with no surrounding code, so a term | |
| that is unambiguous in context can be guessed wrong in isolation. Shipped | |
| examples include `Slug` rendered as the animal, `Host` as a guest, and `Backend` | |
| as a driver. | |
| To attach context, put a comment tagged `i18n:` on the line directly above the | |
| call: | |
| ```python | |
| # i18n: the short identifier in a dashboard's URL, not the animal | |
| "slug": _("Slug"), | |
| ``` | |
| ```tsx | |
| // i18n: the kind of system behind a connection: a database engine | |
| // (PostgreSQL, MySQL) or a semantic layer; not a server tier or a driver | |
| Header: t('Backend'), | |
| ``` | |
| `babel_update.sh` extracts these with `--add-comments=i18n:`, so they land on the | |
| entry in `messages.pot` as `#. i18n: ...` and `pybabel update` propagates them | |
| into every language catalog, the same way the do-not-translate marker described | |
| below does: | |
| ``` | |
| #. i18n: the short identifier in a dashboard's URL, not the animal | |
| msgid "Slug" | |
| msgstr "" | |
| ``` | |
| Where the comment goes decides whether it is extracted: | |
| - A blank line between the comment and the call drops the comment. | |
| - A comment inside the call's parentheses is dropped. | |
| - In Python, the comment is dropped when the string starts on the line after | |
| `_(` and only a comment, such as `# noqa: E501`, or nothing follows the | |
| string. Put the string on the same line as `_(`, or follow it with a comma. | |
| A wrapped `t(` call in TypeScript keeps the comment. | |
| - When two calls are on one line, only the first call gets the comment. Put | |
| each call on its own line. | |
| - Every comment line between the `i18n:` line and the call is published with | |
| the note. Put lint directives and other comments above the `i18n:` line. | |
| A dropped comment raises no error, and the drift check cannot see it. After | |
| `babel_update.sh`, confirm the note is on its entry, for example with | |
| `grep -B3 'msgid "Slug"' superset/translations/messages.pot`. | |
| Write the comment for someone who cannot see the code: say what the term refers | |
| to, and where a translation would plausibly go wrong. A note only guides the | |
| translation; to keep a string untranslated, add it to the do-not-translate | |
| registry described below. | |
| For terms that apply to a whole language, see the | |
| [Translation Guide](./translation-guide.md). | |
| `scripts/translations/backfill_po.py` also sends the comment to the model as a | |
| developer note. In a live run, the note did not change the model's choice when | |
| every reference translation used another sense, so review machine translations | |
| of noted strings. After changing a comment, re-run `babel_update.sh`: CI's | |
| template drift check fails when a string's `i18n:` comment in source no longer | |
| matches `messages.pot`. | |
| Per-string context disambiguates one entry. It does not enforce consistency | |
| across entries — one term used for two concepts across a catalog is a | |
| catalog-wide problem and needs a per-language terminology decision instead. | |
| ### Updating language files | |
| `babel_update.sh` updates every language catalog from `messages.pot`. Do not | |
| run `pybabel update` on its own: babel adds a `python-format` flag to labels | |
| such as `% calculation`, and `msgfmt` then rejects their translations. The | |
| script removes that flag after its update pass. | |
| ### Applying translations | |
| ```bash | |
| # Frontend | |
| cd superset-frontend | |
| npm run build-translation | |
| # Backend | |
| pybabel compile --use-fuzzy -d superset/translations | |
| ``` | |
| `--use-fuzzy` includes `#, fuzzy` entries in the compiled `.mo` files. Superset | |
| serves fuzzy translations on purpose: the frontend build (`npm run | |
| build-translation`, via `scripts/po2json.js`) already includes them, | |
| `flask fab babel-compile` (used by the release images) | |
| compiles with `-f`, and the production `Dockerfile` compiles with `--use-fuzzy` | |
| as well. This keeps machine-generated (and other draft) translations visible in | |
| the UI rather than falling back to English while they await review. | |
| ### Backfilling missing translations with AI | |
| For languages with many untranslated strings, the repo includes a script that | |
| uses Claude AI to generate draft translations for any missing entries. All | |
| AI-generated strings are marked `#, fuzzy` and tagged with an attribution | |
| comment so that human reviewers know they need to be checked. | |
| Note that `#, fuzzy` marks a translation as _needing review_, not as _withheld_: | |
| both the frontend and backend builds serve fuzzy entries (see [Applying | |
| translations](#applying-translations) above), so an AI-generated string is shown | |
| in the UI as soon as it is built and deployed. Reviewers should verify each | |
| entry and remove the `#, fuzzy` flag to promote it to a confirmed translation. | |
| The script never touches entries that must stay literal — icon names, enum | |
| values, SQL keywords, API field names, and example placeholders. These are | |
| registered in `superset/translations/do-not-translate.txt`; | |
| `scripts/translations/apply_do_not_translate.py` stamps them in `messages.pot` | |
| with a `#. do-not-translate` extracted comment (run automatically | |
| from `babel_update.sh`), which `pybabel update` then propagates to every | |
| catalog. To mark a new string do-not-translate, add its msgid to the registry. | |
| The backfill also honors that marker and any legacy do-not-translate translator | |
| comment (e.g. the `ru` catalog's `# Не переводить`), leaving such entries | |
| untranslated so they fall back to the source token. | |
| #### Prerequisites | |
| ```bash | |
| pip install -r superset/translations/requirements.txt | |
| ``` | |
| Claude Code must be installed and authenticated (`claude --version` should | |
| work). The script calls `claude -p` internally — no separate API key is needed. | |
| #### Step 1 — Build the translation index | |
| The index captures every already-translated string in every language and | |
| serves as cross-language context for the AI. Rebuild it whenever `.po` files | |
| change significantly: | |
| ```bash | |
| python scripts/translations/build_translation_index.py | |
| # Writes: superset/translations/translation_index.json | |
| ``` | |
| #### Step 2 — Preview with a dry run | |
| Check what would be translated without writing anything: | |
| ```bash | |
| python scripts/translations/backfill_po.py --lang fr --limit 20 --dry-run | |
| ``` | |
| Output shows each string, its translation, and a context tag: | |
| - No tag — 3+ reference languages available (high confidence) | |
| - `[ctx:N]` — only N other languages have this string (lower confidence) | |
| - `[ctx:0]` — no other language has this string yet; English alone used | |
| #### Step 3 — Run the backfill | |
| ```bash | |
| python scripts/translations/backfill_po.py --lang fr | |
| ``` | |
| Options: | |
| | Flag | Default | Description | | |
| | ----------------- | --------- | ---------------------------------------------------------------- | | |
| | `--lang LANG` | required | ISO language code (`fr`, `de`, `ja`, …) | | |
| | `--batch-size N` | 50 | Strings per Claude request | | |
| | `--limit N` | unlimited | Stop after N entries | | |
| | `--min-context N` | 0 | Skip entries with fewer than N reference translations | | |
| | `--model MODEL` | `sonnet` | Claude model ID, or an alias such as `sonnet` for the latest one | | |
| | `--dry-run` | off | Print without writing | | |
| | `--no-fuzzy` | off | Don't mark entries as fuzzy | | |
| A model alias is resolved to its concrete model ID once per run, and that ID is | |
| what appears in each entry's `# Machine-translated via backfill_po.py (…)` | |
| comment. After writing, the script re-serializes the catalog with Babel in the | |
| same format `babel_update.sh` produces, so the diff contains only the new | |
| translations. | |
| Use `--min-context 2` to skip strings that have fewer than 2 reference | |
| translations in other languages. Those strings are more likely to be ambiguous | |
| (short labels, UI fragments) where the correct meaning can't be inferred | |
| without additional context. | |
| #### Step 4 — Review and commit | |
| Open the target `.po` file and search for `fuzzy`. For each generated entry: | |
| 1. Verify the translation is correct for the UI context. | |
| 2. Remove the `# Machine-translated via backfill_po.py` comment and the | |
| `#, fuzzy` flag line once you are satisfied. | |
| 3. If the translation is wrong, correct the `msgstr` before removing the flag. | |
| 4. Commit the `.po` file — do **not** commit `translation_index.json` (it is | |
| gitignored and regenerated locally). | |
| #### Running via npm | |
| From `superset-frontend/`: | |
| ```bash | |
| # Rebuild index | |
| npm run translations:build-index | |
| # Backfill (pass arguments after --) | |
| npm run translations:backfill -- --lang fr --dry-run | |
| ``` | |
| To backfill several languages at once, eight in parallel, use | |
| `scripts/translations/backfill_all.sh` (every catalog except `en` when no | |
| languages are given): | |
| ```bash | |
| scripts/translations/backfill_all.sh fr de ja | |
| ``` | |
| It can also run through [Apache LLMAO](https://llm.apache.org), the ASF's | |
| model gateway, with a personal LLMAO key in `LLMAO_KEY`: | |
| ```bash | |
| LLMAO_KEY=... scripts/translations/backfill_all.sh --provider llmao fr | |
| ``` | |
| LLMAO uses `gemma4-26b` by default, in batches of 20 to stay under the | |
| gateway's 8,192-token output cap. With `LLMAO_KEY` set, a default run on | |
| Claude also falls back to LLMAO when Claude can't be reached, and retries | |
| there any language Claude left with failed entries. Pass `--no-fallback` to | |
| turn that off. | |
| #### Scheduled backfill in CI | |
| The `Backfill Translations` workflow | |
| (`.github/workflows/backfill-translations.yml`) runs the backfill over every | |
| catalog each Tuesday, the day after the weekly catalog sync, and opens a PR | |
| with the result. It skips the run while a previous backfill PR is still open, | |
| so review it and merge (or close) it to let the next week's run proceed. It | |
| translates with Claude through the `ANTHROPIC_API_KEY` secret and falls back to | |
| Apache LLMAO (the `LLMAO_KEY` secret) the same way `backfill_all.sh` does. It | |
| can also be started by hand from the Actions tab, optionally limited to | |
| specific languages, or with a different provider or model. | |
| ## Linting | |
| ### Python | |
| We use Ruff for Python linting and formatting: | |
| ```bash | |
| # Auto-format using ruff | |
| ruff format . | |
| # Lint check with ruff | |
| ruff check . | |
| # Lint fix with ruff | |
| ruff check --fix . | |
| ``` | |
| Pre-commit hooks run automatically on `git commit` if installed. | |
| ### TypeScript / JavaScript | |
| We use a hybrid linting approach combining OXC (Oxidation Compiler) for standard rules and a custom AST-based checker for Superset-specific patterns. | |
| #### Quick Commands | |
| ```bash | |
| cd superset-frontend | |
| # Run both OXC and custom rules | |
| npm run lint:full | |
| # Run OXC linter only (faster for most checks) | |
| npm run lint | |
| # Fix auto-fixable issues with OXC | |
| npm run lint-fix | |
| # Run custom rules checker only | |
| npm run check:custom-rules | |
| # Run tsc (typescript) checks | |
| npm run type | |
| # Format with Oxfmt | |
| npm run format | |
| ``` | |
| #### Architecture | |
| The linting system consists of two components: | |
| 1. **OXC Linter** (`oxlint`) - A Rust-based linter that's 50-100x faster than ESLint | |
| - Handles all standard JavaScript/TypeScript rules | |
| - Configured via `oxlint.json` | |
| - Runs via `npm run lint` or `npm run lint-fix` | |
| 2. **Custom Rules Checker** - A Node.js AST-based checker for Superset-specific patterns | |
| - Enforces no literal colors (use theme colors) | |
| - Prevents FontAwesome usage (use @superset-ui/core Icons) | |
| - Validates i18n template usage (no template variables) | |
| - Runs via `npm run check:custom-rules` | |
| #### Why This Approach? | |
| - **50-100x faster linting** compared to ESLint for standard rules via OXC | |
| - **Apache-compatible** - No custom binaries, ASF-friendly | |
| - **Maintainable** - Custom rules in JavaScript, not Rust | |
| - **Flexible** - Can evolve as OXC adds plugin support | |
| #### Troubleshooting | |
| **"Plugin 'basic-custom-plugin' not found" Error** | |
| Ensure you're using the explicit config: | |
| ```bash | |
| npx oxlint --config oxlint.json | |
| ``` | |
| **Custom Rules Not Running** | |
| Verify the AST parsing dependencies are installed: | |
| ```bash | |
| npm ls @babel/parser @babel/traverse glob | |
| ``` | |
| #### Adding New Custom Rules | |
| 1. Edit `scripts/check-custom-rules.js` | |
| 2. Add a new check function following the AST visitor pattern | |
| 3. Call the function in `processFile()` | |
| 4. Test with `npm run check:custom-rules` | |
| ## GitHub Ephemeral Environments | |
| For every PR, an ephemeral environment is automatically deployed for testing. | |
| Access pattern: `https://pr-{PR_NUMBER}.superset.apache.org` | |
| Features: | |
| - Automatically deployed on PR creation/update | |
| - Includes sample data | |
| - Destroyed when PR is closed | |
| - Useful for UI/UX review | |
| ## Tips and Tricks | |
| ### Using Docker for Development | |
| ```bash | |
| # Rebuild specific service | |
| docker compose build superset | |
| # View logs | |
| docker compose logs -f superset | |
| # Execute commands in container | |
| docker compose exec superset bash | |
| # Reset database | |
| docker compose down -v | |
| docker compose up | |
| ``` | |
| ### Hot Reloading | |
| **Frontend**: Webpack dev server provides hot module replacement automatically. | |
| **Backend**: Use Flask debug mode: | |
| ```bash | |
| FLASK_ENV=development superset run -p 8088 --with-threads --reload | |
| ``` | |
| ### Performance Profiling | |
| For Python profiling: | |
| ```python | |
| # In superset_config.py | |
| PROFILING = True | |
| ``` | |
| For React profiling: | |
| - Use React DevTools Profiler | |
| - Enable performance marks in Chrome DevTools | |
| ### Database Migrations | |
| ```bash | |
| # Create a new migration | |
| superset db migrate -m "Description of changes" | |
| # Apply migrations | |
| superset db upgrade | |
| # Downgrade | |
| superset db downgrade | |
| ``` | |
| ### Useful Aliases | |
| Add to your shell profile: | |
| ```bash | |
| alias sdev='FLASK_ENV=development superset run -p 8088 --with-threads --reload' | |
| alias stest='pytest tests/unit_tests' | |
| alias slint='pre-commit run --all-files' | |
| alias sfront='cd superset-frontend && npm run dev-server' | |
| ``` | |
| ## Common Issues and Solutions | |
| ### Node/npm Issues | |
| ```bash | |
| # Clear npm cache | |
| npm cache clean --force | |
| # Reinstall dependencies | |
| rm -rf node_modules package-lock.json | |
| npm install | |
| ``` | |
| ### Python Environment Issues | |
| ```bash | |
| # Recreate virtual environment | |
| deactivate | |
| rm -rf venv | |
| python3 -m venv venv | |
| source venv/bin/activate | |
| pip install -r requirements/development.txt | |
| pip install -e . | |
| ``` | |
| ### Database Issues | |
| ```bash | |
| # Reset local database | |
| superset db downgrade -r base | |
| superset db upgrade | |
| superset init | |
| ``` | |
| ### Port Already in Use | |
| ```bash | |
| # Find process using port | |
| lsof -i :8088 | |
| # Kill process | |
| kill -9 [PID] | |
| ``` | |
| ## Reporting Security Vulnerabilities | |
| Please report security vulnerabilities to **private@superset.apache.org**. | |
| In the event a community member discovers a security flaw in Superset, it is important to follow the [Apache Security Guidelines](https://www.apache.org/security/committers.html) and release a fix as quickly as possible before public disclosure. Reporting security vulnerabilities through the usual GitHub Issues channel is not ideal as it will publicize the flaw before a fix can be applied. | |
| ## SQL Lab Async Configuration | |
| It's possible to configure a local database to operate in `async` mode, to work on `async` related features. | |
| To do this, you'll need to: | |
| - Add an additional database entry. We recommend you copy the connection string from the database labeled `main`, and then enable `SQL Lab` and the features you want to use. Don't forget to check the `Async` box | |
| - Configure a results backend, here's a local `FileSystemCache` example, not recommended for production, but perfect for testing (stores cache in `/tmp`) | |
| ```python | |
| from flask_caching.backends.filesystemcache import FileSystemCache | |
| RESULTS_BACKEND = FileSystemCache('/tmp/sqllab') | |
| ``` | |
| - Start up a celery worker | |
| ```bash | |
| celery --app=superset.tasks.celery_app:app worker -O fair | |
| ``` | |
| Note that: | |
| - for changes that affect the worker logic, you'll have to restart the `celery worker` process for the changes to be reflected. | |
| - The message queue used is a `sqlite` database using the `SQLAlchemy` experimental broker. Ok for testing, but not recommended in production | |
| - In some cases, you may want to create a context that is more aligned to your production environment, and use the similar broker as well as results backend configuration | |
| ## Async Chart Queries | |
| It's possible to configure database queries for charts to operate in `async` mode. This is especially useful for dashboards with many charts that may otherwise be affected by browser connection limits. To enable async queries for dashboards and Explore, the following dependencies are required: | |
| - Redis 5.0+ (the feature utilizes [Redis Streams](https://redis.io/topics/streams-intro)) | |
| - Cache backends enabled via the `CACHE_CONFIG` and `DATA_CACHE_CONFIG` config settings | |
| - Celery workers configured and running to process async tasks | |
| ## Need Help? | |
| - Check the [FAQ](https://superset.apache.org/docs/frequently-asked-questions) | |
| - Ask in [Slack](https://apache-superset.slack.com) | |
| - Search [GitHub Issues](https://github.com/apache/superset/issues) | |
| - Post in [GitHub Discussions](https://github.com/apache/superset/discussions) |