chartwright 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chartwright-0.1.0/LICENSE +202 -0
- chartwright-0.1.0/NOTICE +5 -0
- chartwright-0.1.0/PKG-INFO +189 -0
- chartwright-0.1.0/README.md +160 -0
- chartwright-0.1.0/chartwright/__init__.py +7 -0
- chartwright-0.1.0/chartwright/absorb.py +93 -0
- chartwright-0.1.0/chartwright/apply.py +409 -0
- chartwright-0.1.0/chartwright/cli.py +222 -0
- chartwright-0.1.0/chartwright/client.py +227 -0
- chartwright-0.1.0/chartwright/compiler.py +601 -0
- chartwright-0.1.0/chartwright/dashdiff.py +208 -0
- chartwright-0.1.0/chartwright/decompile.py +625 -0
- chartwright-0.1.0/chartwright/ids.py +21 -0
- chartwright-0.1.0/chartwright/mcp_server.py +112 -0
- chartwright-0.1.0/chartwright/profiles.py +143 -0
- chartwright-0.1.0/chartwright/resolver.py +196 -0
- chartwright-0.1.0/chartwright/sketch.py +180 -0
- chartwright-0.1.0/chartwright/smoke.py +124 -0
- chartwright-0.1.0/chartwright/spec.py +597 -0
- chartwright-0.1.0/chartwright/testing.py +31 -0
- chartwright-0.1.0/chartwright.egg-info/PKG-INFO +189 -0
- chartwright-0.1.0/chartwright.egg-info/SOURCES.txt +42 -0
- chartwright-0.1.0/chartwright.egg-info/dependency_links.txt +1 -0
- chartwright-0.1.0/chartwright.egg-info/entry_points.txt +3 -0
- chartwright-0.1.0/chartwright.egg-info/requires.txt +9 -0
- chartwright-0.1.0/chartwright.egg-info/top_level.txt +1 -0
- chartwright-0.1.0/pyproject.toml +43 -0
- chartwright-0.1.0/setup.cfg +4 -0
- chartwright-0.1.0/tests/test_absorb.py +129 -0
- chartwright-0.1.0/tests/test_backup_layout.py +24 -0
- chartwright-0.1.0/tests/test_client.py +30 -0
- chartwright-0.1.0/tests/test_compiler.py +131 -0
- chartwright-0.1.0/tests/test_dashdiff.py +73 -0
- chartwright-0.1.0/tests/test_decompile.py +95 -0
- chartwright-0.1.0/tests/test_mcp_server.py +54 -0
- chartwright-0.1.0/tests/test_params_contract.py +33 -0
- chartwright-0.1.0/tests/test_pivot_formatting.py +160 -0
- chartwright-0.1.0/tests/test_profiles.py +154 -0
- chartwright-0.1.0/tests/test_property_roundtrip.py +44 -0
- chartwright-0.1.0/tests/test_range_filter.py +189 -0
- chartwright-0.1.0/tests/test_sketch.py +187 -0
- chartwright-0.1.0/tests/test_spec.py +89 -0
- chartwright-0.1.0/tests/test_spec_v2.py +73 -0
- chartwright-0.1.0/tests/test_time_filter.py +76 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
chartwright-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chartwright
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Build, verify, and maintain Apache Superset dashboards from small spec files.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/debabsah/chartwright
|
|
7
|
+
Project-URL: Documentation, https://github.com/debabsah/chartwright/tree/main/docs
|
|
8
|
+
Project-URL: Issues, https://github.com/debabsah/chartwright/issues
|
|
9
|
+
Keywords: superset,apache-superset,dashboards,dashboards-as-code,business-intelligence
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
License-File: NOTICE
|
|
21
|
+
Requires-Dist: pydantic>=2.7
|
|
22
|
+
Requires-Dist: requests>=2.31
|
|
23
|
+
Requires-Dist: pyyaml>=6.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
26
|
+
Provides-Extra: mcp
|
|
27
|
+
Requires-Dist: mcp>=1.0; extra == "mcp"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# Chartwright
|
|
31
|
+
|
|
32
|
+
A dashboard compiler for Apache Superset. Describe the dashboard once, in a
|
|
33
|
+
small text file called a spec, and the `chartwright` command line creates it,
|
|
34
|
+
verifies it, and keeps it that way.
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
*3.9 million yellow-taxi trips (NYC TLC trip records, May 2026), 11 verified
|
|
39
|
+
charts, three filters, one `chartwright apply`. An AI wrote
|
|
40
|
+
[the spec](https://github.com/debabsah/chartwright/blob/main/examples/nyc_taxi_operations.json) from a one-paragraph request:
|
|
41
|
+
[the request and rebuild steps](https://github.com/debabsah/chartwright/blob/main/examples/README.md).*
|
|
42
|
+
|
|
43
|
+
A dashboard that lives in a file gets the workflow code already has: review it
|
|
44
|
+
in a pull request, rebuild it identically, diff it against what is live, and
|
|
45
|
+
bring it back after a bad change. Write the spec yourself or ask an AI for one;
|
|
46
|
+
either way, every dataset, column, and metric the spec names is confirmed to
|
|
47
|
+
exist before anything is built, and every chart is checked to load with data
|
|
48
|
+
after.
|
|
49
|
+
|
|
50
|
+
## What a spec looks like
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"spec_version": "1",
|
|
55
|
+
"dashboard": {"title": "Sales Overview", "slug": "sales-overview"},
|
|
56
|
+
"charts": [
|
|
57
|
+
{
|
|
58
|
+
"name": "Total Sales",
|
|
59
|
+
"type": "big_number_total",
|
|
60
|
+
"dataset": {"database": "examples", "table": "cleaned_sales_data"},
|
|
61
|
+
"metric": "SUM(sales)"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "Sales Over Time",
|
|
65
|
+
"type": "timeseries_line",
|
|
66
|
+
"dataset": {"database": "examples", "table": "cleaned_sales_data"},
|
|
67
|
+
"metrics": ["SUM(sales)"],
|
|
68
|
+
"time_column": "order_date"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"layout": {"rows": [["Total Sales"], ["Sales Over Time"]]}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`chartwright apply` on this file signs in to your Superset, confirms the
|
|
76
|
+
`cleaned_sales_data` table and the `sales` and `order_date` columns exist,
|
|
77
|
+
builds a KPI card above a line chart, and finishes by running each chart's
|
|
78
|
+
query once to prove it shows data. A misspelled column or a missing table is a
|
|
79
|
+
clear error naming the problem, before anything is created.
|
|
80
|
+
|
|
81
|
+
## Quick start
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install chartwright
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Python 3.11 or newer; three dependencies; Windows, macOS, and Linux.
|
|
88
|
+
|
|
89
|
+
Create `~/.config/chartwright/profiles.toml` pointing at your Superset:
|
|
90
|
+
|
|
91
|
+
```toml
|
|
92
|
+
[prod]
|
|
93
|
+
base_url = "https://superset.your-company.com"
|
|
94
|
+
username = "your-username"
|
|
95
|
+
password_env = "CHARTWRIGHT_PROD_PASSWORD"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Point the example spec's `dataset` lines at a table your Superset already
|
|
99
|
+
knows, save it as `sales_overview.json`, then:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
chartwright check sales_overview.json --profile prod # read-only: verify every reference
|
|
103
|
+
chartwright apply sales_overview.json --profile prod # build, import, verify
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
No Superset to point at? Clone this repo: `sandbox/up.sh` boots a disposable
|
|
107
|
+
Superset 6.1.0 with example data on `localhost:8098` (Docker required;
|
|
108
|
+
sign-in is admin/admin), and `tests/fixtures/kitchen_sink.json` applies to it
|
|
109
|
+
as-is.
|
|
110
|
+
|
|
111
|
+
## What you get
|
|
112
|
+
|
|
113
|
+
- **Deterministic dashboards**: the same spec always produces the identical
|
|
114
|
+
dashboard. Diff it in git, review it in a PR.
|
|
115
|
+
- **Verified at every step**: every reference is checked before anything is
|
|
116
|
+
written, and every chart's query runs once to prove it shows data; failures
|
|
117
|
+
say what went wrong and where.
|
|
118
|
+
- **Dashboards as code, in both directions**: `chartwright decompile` turns any live
|
|
119
|
+
dashboard into a spec; `chartwright plan` shows what differs between the spec and
|
|
120
|
+
the live dashboard, ready as a CI gate; `chartwright compile` builds the import
|
|
121
|
+
bundle offline, no server needed.
|
|
122
|
+
- **Safety built in**: every apply backs up the previous state first; a failed
|
|
123
|
+
apply restores it automatically; the tool only ever overwrites dashboards it
|
|
124
|
+
created, and a hand-built dashboard is adopted by decompiling it into a spec
|
|
125
|
+
first.
|
|
126
|
+
- **The full design surface**: 14 chart types, metrics as you write them,
|
|
127
|
+
per-chart filters, a native filter bar, tabs, markdown notes, and layouts
|
|
128
|
+
you can draw as ASCII sketches.
|
|
129
|
+
- **Environment promotion**: specs name their data (connection, schema,
|
|
130
|
+
table), so the same file applies to dev, staging, and production unchanged.
|
|
131
|
+
|
|
132
|
+
Every capability, with the CLI verb reference: [docs/FEATURES.md](https://github.com/debabsah/chartwright/blob/main/docs/FEATURES.md).
|
|
133
|
+
|
|
134
|
+
## Creating dashboards with AI
|
|
135
|
+
|
|
136
|
+
- **Claude Code skill**: from a clone of this repo, `python install-skill.py`,
|
|
137
|
+
then ask for a dashboard in plain words; the AI writes the spec, and the
|
|
138
|
+
tool verifies and builds it.
|
|
139
|
+
- **MCP server**: `chartwright-mcp` (installed with `pip install "chartwright[mcp]"`)
|
|
140
|
+
exposes six tools covering the whole lifecycle, usable from any MCP client.
|
|
141
|
+
- **Open contract**: `chartwright schema` prints the spec's JSON Schema, so any LLM or
|
|
142
|
+
tool can generate valid specs.
|
|
143
|
+
- **Guardrails**: the AI proposes; the tool verifies, using your own Superset
|
|
144
|
+
login. Verification reads names (datasets, columns, metrics), not rows.
|
|
145
|
+
|
|
146
|
+
## Drawing layouts as text
|
|
147
|
+
|
|
148
|
+
The spec's `sketch` is the dashboard's shape, drawn with characters that you
|
|
149
|
+
and a model can both write: each letter is a chart, and repeating a sketch
|
|
150
|
+
line makes its charts taller.
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
KKKK LLLLLLLL
|
|
154
|
+
.... LLLLLLLL
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+

|
|
158
|
+
|
|
159
|
+
`L` spans both lines, so it renders twice as tall as `K`; the dots keep the
|
|
160
|
+
space under `K` deliberately empty. Every rule, drawn and explained:
|
|
161
|
+
[docs/LAYOUT-GUIDE.md](https://github.com/debabsah/chartwright/blob/main/docs/LAYOUT-GUIDE.md).
|
|
162
|
+
|
|
163
|
+
## Testing and evidence
|
|
164
|
+
|
|
165
|
+
Every push runs 125 tests on Linux and Windows, plus the full pipeline (apply,
|
|
166
|
+
lifecycle soak, stale-tab adversary, fault injection) against real Superset
|
|
167
|
+
4.1.4, 5.0.0, and 6.1.0 containers. Chart options are checked against
|
|
168
|
+
Superset's own source for every supported version, so a Superset change is
|
|
169
|
+
caught in our tests before it reaches your dashboards.
|
|
170
|
+
|
|
171
|
+
Full evidence: [docs/VERIFICATION.md](https://github.com/debabsah/chartwright/blob/main/docs/VERIFICATION.md). Source citations
|
|
172
|
+
for every Superset behavior the tool relies on:
|
|
173
|
+
[docs/CONTRACTS.md](https://github.com/debabsah/chartwright/blob/main/docs/CONTRACTS.md).
|
|
174
|
+
|
|
175
|
+
## Documentation
|
|
176
|
+
|
|
177
|
+
- [docs/FEATURES.md](https://github.com/debabsah/chartwright/blob/main/docs/FEATURES.md): every capability, with the CLI verb
|
|
178
|
+
reference
|
|
179
|
+
- [docs/LAYOUT-GUIDE.md](https://github.com/debabsah/chartwright/blob/main/docs/LAYOUT-GUIDE.md): drawing layouts as text,
|
|
180
|
+
every rule illustrated
|
|
181
|
+
- [docs/VERIFICATION.md](https://github.com/debabsah/chartwright/blob/main/docs/VERIFICATION.md): what is tested, what it
|
|
182
|
+
caught, and how to reproduce it
|
|
183
|
+
- [docs/CONTRACTS.md](https://github.com/debabsah/chartwright/blob/main/docs/CONTRACTS.md): the Superset behaviors the tool
|
|
184
|
+
depends on, cited to source at each supported version
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
Apache Superset, Superset, and the Superset logo are trademarks of the Apache
|
|
189
|
+
Software Foundation. No endorsement by the ASF is implied.
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Chartwright
|
|
2
|
+
|
|
3
|
+
A dashboard compiler for Apache Superset. Describe the dashboard once, in a
|
|
4
|
+
small text file called a spec, and the `chartwright` command line creates it,
|
|
5
|
+
verifies it, and keeps it that way.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
*3.9 million yellow-taxi trips (NYC TLC trip records, May 2026), 11 verified
|
|
10
|
+
charts, three filters, one `chartwright apply`. An AI wrote
|
|
11
|
+
[the spec](https://github.com/debabsah/chartwright/blob/main/examples/nyc_taxi_operations.json) from a one-paragraph request:
|
|
12
|
+
[the request and rebuild steps](https://github.com/debabsah/chartwright/blob/main/examples/README.md).*
|
|
13
|
+
|
|
14
|
+
A dashboard that lives in a file gets the workflow code already has: review it
|
|
15
|
+
in a pull request, rebuild it identically, diff it against what is live, and
|
|
16
|
+
bring it back after a bad change. Write the spec yourself or ask an AI for one;
|
|
17
|
+
either way, every dataset, column, and metric the spec names is confirmed to
|
|
18
|
+
exist before anything is built, and every chart is checked to load with data
|
|
19
|
+
after.
|
|
20
|
+
|
|
21
|
+
## What a spec looks like
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"spec_version": "1",
|
|
26
|
+
"dashboard": {"title": "Sales Overview", "slug": "sales-overview"},
|
|
27
|
+
"charts": [
|
|
28
|
+
{
|
|
29
|
+
"name": "Total Sales",
|
|
30
|
+
"type": "big_number_total",
|
|
31
|
+
"dataset": {"database": "examples", "table": "cleaned_sales_data"},
|
|
32
|
+
"metric": "SUM(sales)"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "Sales Over Time",
|
|
36
|
+
"type": "timeseries_line",
|
|
37
|
+
"dataset": {"database": "examples", "table": "cleaned_sales_data"},
|
|
38
|
+
"metrics": ["SUM(sales)"],
|
|
39
|
+
"time_column": "order_date"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"layout": {"rows": [["Total Sales"], ["Sales Over Time"]]}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`chartwright apply` on this file signs in to your Superset, confirms the
|
|
47
|
+
`cleaned_sales_data` table and the `sales` and `order_date` columns exist,
|
|
48
|
+
builds a KPI card above a line chart, and finishes by running each chart's
|
|
49
|
+
query once to prove it shows data. A misspelled column or a missing table is a
|
|
50
|
+
clear error naming the problem, before anything is created.
|
|
51
|
+
|
|
52
|
+
## Quick start
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install chartwright
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Python 3.11 or newer; three dependencies; Windows, macOS, and Linux.
|
|
59
|
+
|
|
60
|
+
Create `~/.config/chartwright/profiles.toml` pointing at your Superset:
|
|
61
|
+
|
|
62
|
+
```toml
|
|
63
|
+
[prod]
|
|
64
|
+
base_url = "https://superset.your-company.com"
|
|
65
|
+
username = "your-username"
|
|
66
|
+
password_env = "CHARTWRIGHT_PROD_PASSWORD"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Point the example spec's `dataset` lines at a table your Superset already
|
|
70
|
+
knows, save it as `sales_overview.json`, then:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
chartwright check sales_overview.json --profile prod # read-only: verify every reference
|
|
74
|
+
chartwright apply sales_overview.json --profile prod # build, import, verify
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
No Superset to point at? Clone this repo: `sandbox/up.sh` boots a disposable
|
|
78
|
+
Superset 6.1.0 with example data on `localhost:8098` (Docker required;
|
|
79
|
+
sign-in is admin/admin), and `tests/fixtures/kitchen_sink.json` applies to it
|
|
80
|
+
as-is.
|
|
81
|
+
|
|
82
|
+
## What you get
|
|
83
|
+
|
|
84
|
+
- **Deterministic dashboards**: the same spec always produces the identical
|
|
85
|
+
dashboard. Diff it in git, review it in a PR.
|
|
86
|
+
- **Verified at every step**: every reference is checked before anything is
|
|
87
|
+
written, and every chart's query runs once to prove it shows data; failures
|
|
88
|
+
say what went wrong and where.
|
|
89
|
+
- **Dashboards as code, in both directions**: `chartwright decompile` turns any live
|
|
90
|
+
dashboard into a spec; `chartwright plan` shows what differs between the spec and
|
|
91
|
+
the live dashboard, ready as a CI gate; `chartwright compile` builds the import
|
|
92
|
+
bundle offline, no server needed.
|
|
93
|
+
- **Safety built in**: every apply backs up the previous state first; a failed
|
|
94
|
+
apply restores it automatically; the tool only ever overwrites dashboards it
|
|
95
|
+
created, and a hand-built dashboard is adopted by decompiling it into a spec
|
|
96
|
+
first.
|
|
97
|
+
- **The full design surface**: 14 chart types, metrics as you write them,
|
|
98
|
+
per-chart filters, a native filter bar, tabs, markdown notes, and layouts
|
|
99
|
+
you can draw as ASCII sketches.
|
|
100
|
+
- **Environment promotion**: specs name their data (connection, schema,
|
|
101
|
+
table), so the same file applies to dev, staging, and production unchanged.
|
|
102
|
+
|
|
103
|
+
Every capability, with the CLI verb reference: [docs/FEATURES.md](https://github.com/debabsah/chartwright/blob/main/docs/FEATURES.md).
|
|
104
|
+
|
|
105
|
+
## Creating dashboards with AI
|
|
106
|
+
|
|
107
|
+
- **Claude Code skill**: from a clone of this repo, `python install-skill.py`,
|
|
108
|
+
then ask for a dashboard in plain words; the AI writes the spec, and the
|
|
109
|
+
tool verifies and builds it.
|
|
110
|
+
- **MCP server**: `chartwright-mcp` (installed with `pip install "chartwright[mcp]"`)
|
|
111
|
+
exposes six tools covering the whole lifecycle, usable from any MCP client.
|
|
112
|
+
- **Open contract**: `chartwright schema` prints the spec's JSON Schema, so any LLM or
|
|
113
|
+
tool can generate valid specs.
|
|
114
|
+
- **Guardrails**: the AI proposes; the tool verifies, using your own Superset
|
|
115
|
+
login. Verification reads names (datasets, columns, metrics), not rows.
|
|
116
|
+
|
|
117
|
+
## Drawing layouts as text
|
|
118
|
+
|
|
119
|
+
The spec's `sketch` is the dashboard's shape, drawn with characters that you
|
|
120
|
+
and a model can both write: each letter is a chart, and repeating a sketch
|
|
121
|
+
line makes its charts taller.
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
KKKK LLLLLLLL
|
|
125
|
+
.... LLLLLLLL
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+

|
|
129
|
+
|
|
130
|
+
`L` spans both lines, so it renders twice as tall as `K`; the dots keep the
|
|
131
|
+
space under `K` deliberately empty. Every rule, drawn and explained:
|
|
132
|
+
[docs/LAYOUT-GUIDE.md](https://github.com/debabsah/chartwright/blob/main/docs/LAYOUT-GUIDE.md).
|
|
133
|
+
|
|
134
|
+
## Testing and evidence
|
|
135
|
+
|
|
136
|
+
Every push runs 125 tests on Linux and Windows, plus the full pipeline (apply,
|
|
137
|
+
lifecycle soak, stale-tab adversary, fault injection) against real Superset
|
|
138
|
+
4.1.4, 5.0.0, and 6.1.0 containers. Chart options are checked against
|
|
139
|
+
Superset's own source for every supported version, so a Superset change is
|
|
140
|
+
caught in our tests before it reaches your dashboards.
|
|
141
|
+
|
|
142
|
+
Full evidence: [docs/VERIFICATION.md](https://github.com/debabsah/chartwright/blob/main/docs/VERIFICATION.md). Source citations
|
|
143
|
+
for every Superset behavior the tool relies on:
|
|
144
|
+
[docs/CONTRACTS.md](https://github.com/debabsah/chartwright/blob/main/docs/CONTRACTS.md).
|
|
145
|
+
|
|
146
|
+
## Documentation
|
|
147
|
+
|
|
148
|
+
- [docs/FEATURES.md](https://github.com/debabsah/chartwright/blob/main/docs/FEATURES.md): every capability, with the CLI verb
|
|
149
|
+
reference
|
|
150
|
+
- [docs/LAYOUT-GUIDE.md](https://github.com/debabsah/chartwright/blob/main/docs/LAYOUT-GUIDE.md): drawing layouts as text,
|
|
151
|
+
every rule illustrated
|
|
152
|
+
- [docs/VERIFICATION.md](https://github.com/debabsah/chartwright/blob/main/docs/VERIFICATION.md): what is tested, what it
|
|
153
|
+
caught, and how to reproduce it
|
|
154
|
+
- [docs/CONTRACTS.md](https://github.com/debabsah/chartwright/blob/main/docs/CONTRACTS.md): the Superset behaviors the tool
|
|
155
|
+
depends on, cited to source at each supported version
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
Apache Superset, Superset, and the Superset logo are trademarks of the Apache
|
|
160
|
+
Software Foundation. No endorsement by the ASF is implied.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""Absorb UI height polish back into the spec file: the scalpel to
|
|
2
|
+
decompile's bulldozer.
|
|
3
|
+
|
|
4
|
+
Workflow this serves (the owner's ruling, 2026-07-11): the sketch gets a
|
|
5
|
+
dashboard 90-95% built in one shot; the last few percent of fine-grain sizing
|
|
6
|
+
happens by hand in the Superset UI. Without absorb, the next `chartwright apply`
|
|
7
|
+
rebuilds the layout from the spec and destroys that polish. `chartwright absorb`
|
|
8
|
+
reads the LIVE dashboard's geometry and patches ONLY per-chart heights into
|
|
9
|
+
the existing spec file; sketch, legend, metrics, structure untouched.
|
|
10
|
+
|
|
11
|
+
Heights only, by design: Superset widths ARE twelfths, so the UI cannot
|
|
12
|
+
express any width the sketch can't; width changes belong in the drawing.
|
|
13
|
+
Width drift is therefore REPORTED as advice, never written. Heights are where
|
|
14
|
+
the UI has finer resolution (8px) than the sketch quantum (40px); absorbed
|
|
15
|
+
values are written as fractional 40px units in 0.2 steps (8px), so the
|
|
16
|
+
polished geometry round-trips EXACTLY through the next apply.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import copy
|
|
22
|
+
from dataclasses import asdict, dataclass, field
|
|
23
|
+
|
|
24
|
+
from . import ids
|
|
25
|
+
from .compiler import ROW_UNITS_PER_SPEC_UNIT, _position
|
|
26
|
+
from .spec import DashboardSpec
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass
|
|
30
|
+
class AbsorbReport:
|
|
31
|
+
ok: bool
|
|
32
|
+
absorbed: list[dict] = field(default_factory=list) # {chart, from_px, to_px, height}
|
|
33
|
+
width_advice: list[dict] = field(default_factory=list) # {chart, spec_width, live_width}
|
|
34
|
+
unmatched_live: list[str] = field(default_factory=list)
|
|
35
|
+
detail: str | None = None
|
|
36
|
+
|
|
37
|
+
def to_json(self) -> str:
|
|
38
|
+
return json.dumps({"stage": "absorb", **asdict(self)}, indent=2)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _exact_units(row_units: int) -> float | int:
|
|
42
|
+
"""Superset row units (8px) -> spec units (40px), exactly representable."""
|
|
43
|
+
units = row_units / ROW_UNITS_PER_SPEC_UNIT
|
|
44
|
+
return int(units) if units.is_integer() else round(units, 1)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def absorb_heights(spec: DashboardSpec, spec_data: dict, live_position: dict) -> tuple[dict, AbsorbReport]:
|
|
48
|
+
"""Pure core: returns (patched copy of spec_data, report). spec_data is the
|
|
49
|
+
raw JSON the spec file holds; only charts[*].height values are touched."""
|
|
50
|
+
report = AbsorbReport(ok=True)
|
|
51
|
+
slug = spec.dashboard.slug
|
|
52
|
+
|
|
53
|
+
compiled = {
|
|
54
|
+
v["meta"]["uuid"]: v["meta"]
|
|
55
|
+
for v in _position(spec).values()
|
|
56
|
+
if isinstance(v, dict) and v.get("type") == "CHART"
|
|
57
|
+
}
|
|
58
|
+
live = {
|
|
59
|
+
v["meta"]["uuid"]: v["meta"]
|
|
60
|
+
for v in live_position.values()
|
|
61
|
+
if isinstance(v, dict) and v.get("type") == "CHART" and (v.get("meta") or {}).get("uuid")
|
|
62
|
+
}
|
|
63
|
+
report.unmatched_live = sorted(
|
|
64
|
+
(m.get("sliceName") or u) for u, m in live.items() if u not in compiled
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
out = copy.deepcopy(spec_data)
|
|
68
|
+
charts_by_name = {c["name"]: c for c in out.get("charts", [])}
|
|
69
|
+
|
|
70
|
+
for chart in spec.charts:
|
|
71
|
+
u = str(ids.chart_uuid(slug, chart.name))
|
|
72
|
+
live_meta = live.get(u)
|
|
73
|
+
if live_meta is None:
|
|
74
|
+
continue # chart not on the live board (e.g. never applied); nothing to absorb
|
|
75
|
+
want, have = compiled[u], live_meta
|
|
76
|
+
if have.get("width") != want["width"]:
|
|
77
|
+
report.width_advice.append({
|
|
78
|
+
"chart": chart.name,
|
|
79
|
+
"spec_width": want["width"],
|
|
80
|
+
"live_width": have.get("width"),
|
|
81
|
+
"note": "widths are twelfths; redraw the sketch line (absorb writes heights only)",
|
|
82
|
+
})
|
|
83
|
+
live_h = have.get("height")
|
|
84
|
+
if not isinstance(live_h, int) or live_h == want["height"]:
|
|
85
|
+
continue
|
|
86
|
+
charts_by_name[chart.name]["height"] = _exact_units(live_h)
|
|
87
|
+
report.absorbed.append({
|
|
88
|
+
"chart": chart.name,
|
|
89
|
+
"from_px": want["height"] * 8,
|
|
90
|
+
"to_px": live_h * 8,
|
|
91
|
+
"height": charts_by_name[chart.name]["height"],
|
|
92
|
+
})
|
|
93
|
+
return out, report
|