0
# CLI Commands
1
2
Command-line interface for Apache Superset application management, providing tools for initialization, user management, data loading, and development tasks.
3
4
## Capabilities
5
6
### Application Management
7
8
Core commands for initializing and managing the Superset application.
9
10
```python { .api }
11
def init() -> None:
12
"""
13
Initialize the Superset application.
14
15
Sets up database tables, adds default permissions, and synchronizes role definitions.
16
Must be run before first use of Superset.
17
"""
18
19
def version(verbose: bool = False) -> None:
20
"""
21
Print current version number.
22
23
Args:
24
verbose: Show additional version information including build details
25
"""
26
27
def fab_create_admin() -> None:
28
"""
29
Create an admin user interactively.
30
31
Prompts for username, first name, last name, email, and password.
32
Creates user with Admin role permissions.
33
"""
34
35
def run(host: str = "127.0.0.1", port: int = 8088,
36
with_threads: bool = False, reload: bool = False,
37
debugger: bool = False) -> None:
38
"""
39
Start development server.
40
41
Args:
42
host: Host address to bind to
43
port: Port number to bind to
44
with_threads: Enable threaded mode
45
reload: Enable auto-reload on code changes
46
debugger: Enable interactive debugger
47
"""
48
```
49
50
**Usage Examples:**
51
52
```bash
53
# Initialize application
54
superset init
55
56
# Create admin user
57
superset fab create-admin
58
59
# Start development server
60
superset run -h 0.0.0.0 -p 8088 --with-threads --reload --debugger
61
```
62
63
### Data Management
64
65
Commands for loading, importing, and exporting data and configurations.
66
67
```python { .api }
68
def load_examples() -> None:
69
"""
70
Load example datasets, charts, and dashboards.
71
72
Includes birth names data, energy consumption data, flight data,
73
and World Bank data with corresponding visualizations.
74
"""
75
76
def load_test_users() -> None:
77
"""
78
Load test users for development and testing.
79
80
Creates users with different permission levels for testing
81
role-based access control functionality.
82
"""
83
84
def export_dashboards(dashboard_file: str, print_stdout: bool = False) -> None:
85
"""
86
Export dashboard configurations to file.
87
88
Args:
89
dashboard_file: Path to output file
90
print_stdout: Print export data to stdout instead of file
91
"""
92
93
def export_datasources(datasource_file: str, print_stdout: bool = False,
94
back_references: bool = False) -> None:
95
"""
96
Export datasource configurations to file.
97
98
Args:
99
datasource_file: Path to output file
100
print_stdout: Print export data to stdout instead of file
101
back_references: Include back references in export
102
"""
103
104
def import_dashboards(dashboard_file: str, sync: List[str] = None,
105
update_refresh_periods: bool = False) -> None:
106
"""
107
Import dashboard configurations from file.
108
109
Args:
110
dashboard_file: Path to import file
111
sync: Synchronization strategy for existing objects
112
update_refresh_periods: Update refresh periods on import
113
"""
114
115
def import_datasources(datasource_file: str, sync: List[str] = None,
116
recursive: bool = False) -> None:
117
"""
118
Import datasource configurations from file.
119
120
Args:
121
datasource_file: Path to import file
122
sync: Synchronization strategy for existing objects
123
recursive: Recursively import dependencies
124
"""
125
```
126
127
**Usage Examples:**
128
129
```bash
130
# Load example data
131
superset load-examples
132
133
# Export dashboards
134
superset export-dashboards -f /tmp/dashboards.json
135
136
# Import dashboards
137
superset import-dashboards -f /tmp/dashboards.json
138
```
139
140
### Database Operations
141
142
Commands for managing database connections and metadata.
143
144
```python { .api }
145
def set_database_uri(database_name: str, uri: str) -> None:
146
"""
147
Update database URI for existing database connection.
148
149
Args:
150
database_name: Name of database to update
151
uri: New SQLAlchemy database URI
152
"""
153
154
def refresh_druid(datasource: str = None, merge: bool = True) -> None:
155
"""
156
Refresh Druid datasource metadata.
157
158
Args:
159
datasource: Specific datasource to refresh (refreshes all if None)
160
merge: Merge with existing metadata instead of replacing
161
"""
162
163
def update_datasources_cache() -> None:
164
"""
165
Update datasource metadata cache.
166
167
Refreshes column information, table schemas, and other metadata
168
for all configured datasources.
169
"""
170
171
def sync_tags() -> None:
172
"""
173
Synchronize tags across the system.
174
175
Updates tag relationships and ensures consistency across
176
dashboards, charts, and other tagged objects.
177
"""
178
```
179
180
**Usage Examples:**
181
182
```bash
183
# Update database connection
184
superset set-database-uri -d "MyDB" -u "postgresql://user:pass@host/db"
185
186
# Refresh Druid metadata
187
superset refresh-druid --merge
188
189
# Update datasource cache
190
superset update-datasources-cache
191
```
192
193
### Background Task Management
194
195
Commands for managing Celery workers and background processing.
196
197
```python { .api }
198
def worker(concurrency: int = None, loglevel: str = "info") -> None:
199
"""
200
Start Celery worker for background task processing.
201
202
Args:
203
concurrency: Number of concurrent worker processes
204
loglevel: Logging level (debug, info, warning, error)
205
"""
206
207
def flower(port: int = 5555, address: str = "0.0.0.0") -> None:
208
"""
209
Start Celery Flower monitoring interface.
210
211
Args:
212
port: Port for Flower web interface
213
address: Address to bind Flower interface
214
"""
215
216
def compute_thumbnails(dashboard_ids: List[int] = None,
217
chart_ids: List[int] = None,
218
force: bool = False) -> None:
219
"""
220
Generate thumbnails for dashboards and charts.
221
222
Args:
223
dashboard_ids: Specific dashboard IDs to process
224
chart_ids: Specific chart IDs to process
225
force: Force regeneration of existing thumbnails
226
"""
227
```
228
229
**Usage Examples:**
230
231
```bash
232
# Start Celery worker
233
superset worker --concurrency=4
234
235
# Start Flower monitoring
236
superset flower --port=5555
237
238
# Generate thumbnails
239
superset compute-thumbnails --force
240
```
241
242
### Development and Testing
243
244
Commands for development, testing, and maintenance tasks.
245
246
```python { .api }
247
def update_api_docs() -> None:
248
"""
249
Update OpenAPI documentation files.
250
251
Generates updated API documentation based on current
252
Flask-RESTX endpoints and schemas.
253
"""
254
255
def alert(action: str, report_id: int = None) -> None:
256
"""
257
Manage alerting system operations.
258
259
Args:
260
action: Action to perform (list, test, run)
261
report_id: Specific report ID for targeted actions
262
"""
263
264
def shell_context() -> Dict[str, Any]:
265
"""
266
Provide shell context with common objects.
267
268
Returns:
269
Dictionary containing app, db, and other common objects
270
for interactive shell sessions
271
"""
272
```
273
274
**Usage Examples:**
275
276
```bash
277
# Update API documentation
278
superset update-api-docs
279
280
# Test alerts
281
superset alert test --report-id=123
282
283
# Start interactive shell
284
superset shell
285
```
286
287
## Command Categories
288
289
### Essential Setup Commands
290
- `superset init` - Initialize application
291
- `superset fab create-admin` - Create admin user
292
- `superset load-examples` - Load sample data
293
294
### Development Commands
295
- `superset run` - Start development server
296
- `superset shell` - Start interactive shell
297
- `superset update-api-docs` - Update documentation
298
299
### Data Commands
300
- `superset load-test-users` - Load test users
301
- `superset export-dashboards` - Export dashboard configs
302
- `superset import-dashboards` - Import dashboard configs
303
- `superset export-datasources` - Export datasource configs
304
- `superset import-datasources` - Import datasource configs
305
306
### Maintenance Commands
307
- `superset refresh-druid` - Refresh Druid metadata
308
- `superset update-datasources-cache` - Update metadata cache
309
- `superset sync-tags` - Synchronize tags
310
- `superset compute-thumbnails` - Generate thumbnails
311
312
### Background Processing
313
- `superset worker` - Start Celery worker
314
- `superset flower` - Start Celery monitoring