aibi-toolkit 1.2.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.
Files changed (50) hide show
  1. aibi_toolkit-1.2.0/LICENSE +21 -0
  2. aibi_toolkit-1.2.0/PKG-INFO +218 -0
  3. aibi_toolkit-1.2.0/README.md +167 -0
  4. aibi_toolkit-1.2.0/pyproject.toml +44 -0
  5. aibi_toolkit-1.2.0/setup.cfg +4 -0
  6. aibi_toolkit-1.2.0/src/aibi_toolkit/__init__.py +44 -0
  7. aibi_toolkit-1.2.0/src/aibi_toolkit/__main__.py +12 -0
  8. aibi_toolkit-1.2.0/src/aibi_toolkit/audit.py +46 -0
  9. aibi_toolkit-1.2.0/src/aibi_toolkit/autofix.py +47 -0
  10. aibi_toolkit-1.2.0/src/aibi_toolkit/cli.py +79 -0
  11. aibi_toolkit-1.2.0/src/aibi_toolkit/cli_internal.py +97 -0
  12. aibi_toolkit-1.2.0/src/aibi_toolkit/config.py +73 -0
  13. aibi_toolkit-1.2.0/src/aibi_toolkit/csvio.py +54 -0
  14. aibi_toolkit-1.2.0/src/aibi_toolkit/dax.py +88 -0
  15. aibi_toolkit-1.2.0/src/aibi_toolkit/diagram.py +28 -0
  16. aibi_toolkit-1.2.0/src/aibi_toolkit/filters.py +28 -0
  17. aibi_toolkit-1.2.0/src/aibi_toolkit/integrity.py +47 -0
  18. aibi_toolkit-1.2.0/src/aibi_toolkit/lint.py +34 -0
  19. aibi_toolkit-1.2.0/src/aibi_toolkit/measure.py +131 -0
  20. aibi_toolkit-1.2.0/src/aibi_toolkit/metadata.py +92 -0
  21. aibi_toolkit-1.2.0/src/aibi_toolkit/naming.py +136 -0
  22. aibi_toolkit-1.2.0/src/aibi_toolkit/profile.py +61 -0
  23. aibi_toolkit-1.2.0/src/aibi_toolkit/py.typed +0 -0
  24. aibi_toolkit-1.2.0/src/aibi_toolkit/report.py +79 -0
  25. aibi_toolkit-1.2.0/src/aibi_toolkit/sample.py +54 -0
  26. aibi_toolkit-1.2.0/src/aibi_toolkit/tables.py +43 -0
  27. aibi_toolkit-1.2.0/src/aibi_toolkit.egg-info/PKG-INFO +218 -0
  28. aibi_toolkit-1.2.0/src/aibi_toolkit.egg-info/SOURCES.txt +48 -0
  29. aibi_toolkit-1.2.0/src/aibi_toolkit.egg-info/dependency_links.txt +1 -0
  30. aibi_toolkit-1.2.0/src/aibi_toolkit.egg-info/entry_points.txt +2 -0
  31. aibi_toolkit-1.2.0/src/aibi_toolkit.egg-info/requires.txt +8 -0
  32. aibi_toolkit-1.2.0/src/aibi_toolkit.egg-info/top_level.txt +1 -0
  33. aibi_toolkit-1.2.0/tests/test_audit.py +25 -0
  34. aibi_toolkit-1.2.0/tests/test_autofix.py +16 -0
  35. aibi_toolkit-1.2.0/tests/test_cli.py +87 -0
  36. aibi_toolkit-1.2.0/tests/test_config.py +35 -0
  37. aibi_toolkit-1.2.0/tests/test_csvio.py +19 -0
  38. aibi_toolkit-1.2.0/tests/test_dax.py +28 -0
  39. aibi_toolkit-1.2.0/tests/test_diagram.py +8 -0
  40. aibi_toolkit-1.2.0/tests/test_filters.py +11 -0
  41. aibi_toolkit-1.2.0/tests/test_integrity.py +42 -0
  42. aibi_toolkit-1.2.0/tests/test_lint.py +13 -0
  43. aibi_toolkit-1.2.0/tests/test_measure.py +51 -0
  44. aibi_toolkit-1.2.0/tests/test_metadata.py +47 -0
  45. aibi_toolkit-1.2.0/tests/test_naming.py +65 -0
  46. aibi_toolkit-1.2.0/tests/test_profile.py +23 -0
  47. aibi_toolkit-1.2.0/tests/test_readme.py +38 -0
  48. aibi_toolkit-1.2.0/tests/test_report.py +23 -0
  49. aibi_toolkit-1.2.0/tests/test_sample.py +18 -0
  50. aibi_toolkit-1.2.0/tests/test_tables.py +20 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sourin Rakshit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,218 @@
1
+ Metadata-Version: 2.4
2
+ Name: aibi-toolkit
3
+ Version: 1.2.0
4
+ Summary: Clean up Power BI / Tableau semantic-model metadata: naming, format strings, DAX snippets, hygiene auditing, linting, diagrams and reports
5
+ Author: Sourin Rakshit
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Sourin Rakshit
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/SourinRakshit-ai/aibi-toolkit
29
+ Project-URL: Changelog, https://github.com/SourinRakshit-ai/aibi-toolkit/blob/main/CHANGELOG.md
30
+ Project-URL: Issues, https://github.com/SourinRakshit-ai/aibi-toolkit/issues
31
+ Keywords: powerbi,tableau,dax,tmdl,semantic-model,lint
32
+ Classifier: Development Status :: 5 - Production/Stable
33
+ Classifier: Environment :: Console
34
+ Classifier: Operating System :: OS Independent
35
+ Classifier: Programming Language :: Python :: 3.10
36
+ Classifier: Programming Language :: Python :: 3.11
37
+ Classifier: Programming Language :: Python :: 3.12
38
+ Classifier: Programming Language :: Python :: 3.13
39
+ Classifier: Topic :: Software Development :: Quality Assurance
40
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
41
+ Requires-Python: >=3.10
42
+ Description-Content-Type: text/markdown
43
+ License-File: LICENSE
44
+ Provides-Extra: dev
45
+ Requires-Dist: pytest; extra == "dev"
46
+ Requires-Dist: mypy; extra == "dev"
47
+ Requires-Dist: ruff; extra == "dev"
48
+ Provides-Extra: docs
49
+ Requires-Dist: mkdocs-material; extra == "docs"
50
+ Dynamic: license-file
51
+
52
+ # aibi-toolkit
53
+
54
+ *aibi* — CLI + library for cleaning up Power BI / Tableau semantic-model
55
+ metadata. Companion to [aibi-dax](https://github.com/SourinRakshit-ai/aibi-dax):
56
+ where aibi-dax checks the DAX expressions inside your measures, aibi-toolkit
57
+ checks the model around them — naming conventions, format strings, duplicate
58
+ measures, empty tables, relationships, hygiene.
59
+
60
+ [![CI](https://github.com/SourinRakshit-ai/aibi-toolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/SourinRakshit-ai/aibi-toolkit/actions/workflows/ci.yml)
61
+ [![Lint](https://github.com/SourinRakshit-ai/aibi-toolkit/actions/workflows/lint.yml/badge.svg)](https://github.com/SourinRakshit-ai/aibi-toolkit/actions/workflows/lint.yml)
62
+ [![Python](https://img.shields.io/badge/python-3.10–3.13-blue)](pyproject.toml)
63
+ [![Types](https://img.shields.io/badge/mypy-strict-blue)](pyproject.toml)
64
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](.github/workflows/lint.yml)
65
+ [![Docs](https://img.shields.io/badge/docs-live-informational)](https://sourinrakshit-ai.github.io/aibi-toolkit/)
66
+ ![License](https://img.shields.io/badge/license-MIT-green)
67
+
68
+ Runnable walkthroughs live in [`examples/`](examples/#readme).
69
+
70
+ ## Why this exists
71
+
72
+ A semantic model is a shared asset, and it always drifts. Measure names pick
73
+ up stray spaces, missing format strings, duplicate definitions that nobody
74
+ deletes, and DAX smells that pass casual review. Nobody catches it, because
75
+ each file is small but the model is large, and nobody wants to be the one
76
+ recounting the measures by hand.
77
+
78
+ That is the failure mode aibi-toolkit was built for. It reads the dump, runs
79
+ the checks, gives you a score, and names the findings. The first pass
80
+ usually looks like: score 38, a dozen missing format strings, six duplicate
81
+ measures.
82
+
83
+ ## What it does
84
+
85
+ - **`aibi audit`** — measure hygiene findings and a 0-100 score.
86
+ Checks format strings, case-insensitive duplicate names, and measure
87
+ name length. Exit 1 when anything is found, 0 when the model is clean,
88
+ so a CI gate is one command.
89
+ - **`aibi lint`** — static checks on the DAX expressions: raw `/` without
90
+ `DIVIDE`, no-argument `ALLSELECTED()`, `CALCULATE([])`, and `IFERROR`
91
+ masking.
92
+ - **`aibi fix`** — applies naming and format-string fixes with `--dry-run`
93
+ so you always see what would change before it changes.
94
+ - **`aibi summary`** — object counts; **`aibi tables`** — table list.
95
+ - **`aibi report`** — markdown audit report: score, finding counts,
96
+ examples, for your own paper trail or a PR description.
97
+ - **`aibi diagram`** — mermaid ER diagram straight from the model.
98
+ - **`aibi profile`** — expression complexity: count, average, max weight,
99
+ and the heaviest measures named.
100
+ - **`aibi synth`** — generate a sample model for trying the tool.
101
+ - **`aibi export`** — measures to CSV for external row-checks.
102
+
103
+ Full module map:
104
+
105
+ | Area | Module |
106
+ | ------------------ | --------------- |
107
+ | Naming | `naming` |
108
+ | Format strings | `measure` |
109
+ | DAX snippets | `dax`, `filters`|
110
+ | Model inspection | `metadata` |
111
+ | Auditing + linting | `audit`, `lint` |
112
+ | Integrity | `integrity` |
113
+ | Autofixes | `autofix` |
114
+ | Diagrams | `diagram` |
115
+ | Reports | `report` |
116
+ | Demo data | `sample` |
117
+ | Renderers | `tables` |
118
+ | Configuration | `config` |
119
+ | Profiling | `profile` |
120
+ | CSV round-trip | `csvio` |
121
+
122
+ ## Install
123
+
124
+ Not on PyPI yet; install from the repository. Issue [#5](https://github.com/SourinRakshit-ai/aibi-toolkit/issues/5) tracks the trusted-publishing release:
125
+
126
+ ```bash
127
+ git clone https://github.com/SourinRakshit-ai/aibi-toolkit.git
128
+ cd aibi-toolkit
129
+ pip install .
130
+ aibi --help
131
+ ```
132
+
133
+ ## Quick start
134
+
135
+ Generate a sample model, then check it:
136
+
137
+ ```bash
138
+ aibi synth model.json # write a sample model
139
+ aibi summary model.json # object counts
140
+ aibi audit model.json # hygiene findings + 0-100 score
141
+ aibi lint model.json # DAX rule findings
142
+ aibi audit model.json --json # machine-readable output (also: lint, profile)
143
+ aibi report model.json out.md # markdown audit report
144
+ aibi fix --dry-run model.json # preview fixes before writing anything
145
+ ```
146
+
147
+ Audit returns exit `1` when findings exist, `0` when clean, so a pipeline
148
+ that already has `set -e` fails immediately. Pass `--json` to `audit`,
149
+ `lint` or `profile` when you want a machine-readable result.
150
+
151
+ ## How it helps
152
+
153
+ - **One number first.** The 0–100 score tells you whether the model
154
+ deserves attention before you read a single measure. Score 38 usually
155
+ means "regenerate formats and delete the dead duplicates"; score 92
156
+ means "quick answer, move on".
157
+ - **Names and formats are the fix.** Around 90% of findings in real
158
+ models are `missing_format` and duplicates after a bulk edit; both
159
+ are auto-fixable by `aibi fix` with `--dry-run` for confirmation.
160
+ - **Exit codes mean CI.** `aibi audit model.json` returns 1 with any
161
+ finding and 0 clean, so the release pipeline it belongs in fails where
162
+ the merge should wait for you.
163
+ - **The report is the artifact.** `aibi report` gives a reviewer the
164
+ score and a short list of examples, which is usually enough for the
165
+ release meeting.
166
+
167
+ ## What it is not
168
+
169
+ - **Not an aibi-dax substitute.** It lints DAX for narrowly-scoped
170
+ patterns (raw `/`, no-arg `ALLSELECTED()`, `CALCULATE([])`, `IFERROR`
171
+ hiding). For deep complexity scoring and anti-pattern detection,
172
+ that is what [aibi-dax](https://github.com/SourinRakshit-ai/aibi-dax)
173
+ is for.
174
+ - **Not a full TMDL/PBIP authoring tool.** It reads shared-schema
175
+ model dumps; it does not write them back to disk yet
176
+ (tracked in [#6](https://github.com/SourinRakshit-ai/aibi-toolkit/issues/6)).
177
+ - **Not a bug finder for DAX logic.** It checks static patterns; it
178
+ cannot tell you your total is wrong. That still needs `EVALUATE`
179
+ checks and your eyes.
180
+ - **Not a performance tool.** It has no cost model for queries; it
181
+ flags patterns, not benchmarks.
182
+
183
+ ## Commands
184
+
185
+ | Command | Purpose |
186
+ | ------- | ------- |
187
+ | `aibi summary model.json` | object counts |
188
+ | `aibi tables model.json` | list tables |
189
+ | `aibi audit model.json` | hygiene findings + 0-100 score |
190
+ | `aibi lint model.json` | DAX rule findings |
191
+ | `aibi fix --dry-run model.json` | preview naming/format fixes (omit `--dry-run` to apply) |
192
+ | `aibi profile model.json` | expression complexity: count, avg, max, heavy |
193
+ | `aibi diagram model.json` | mermaid ER diagram |
194
+ | `aibi export model.json out.csv` | measures to CSV |
195
+ | `aibi report model.json out.md` | markdown audit report |
196
+ | `aibi synth model.json` | generate a sample model |
197
+
198
+ ## Docs and support
199
+
200
+ - **Docs site:** [sourinrakshit-ai.github.io/aibi-toolkit](https://sourinrakshit-ai.github.io/aibi-toolkit/) (`mkdocs gh-deploy`)
201
+ - **Issues:** [https://github.com/SourinRakshit-ai/aibi-toolkit/issues](https://github.com/SourinRakshit-ai/aibi-toolkit/issues)
202
+ - **Status:** `v1.2.0` on main. Not yet published to PyPI; trusted publishing
203
+ for the repo is tracked in [#5](https://github.com/SourinRakshit-ai/aibi-toolkit/issues/5),
204
+ with the pattern now proven by [aibi-dax](https://github.com/SourinRakshit-ai/aibi-dax).
205
+ - **Releases:** tagged `v*` triggers the `publish.yml` workflow once
206
+ trusted publishing is configured.
207
+
208
+ ## Development
209
+
210
+ ```bash
211
+ make install # pip install -e ".[dev]"
212
+ make test # pytest -q
213
+ make typecheck # mypy --strict src/aibi_toolkit/
214
+ make lint # ruff check src/ tests/
215
+ make serve-docs # mkdocs serve
216
+ ```
217
+
218
+ MIT licensed. Roadmap lives in the issue tracker.
@@ -0,0 +1,167 @@
1
+ # aibi-toolkit
2
+
3
+ *aibi* — CLI + library for cleaning up Power BI / Tableau semantic-model
4
+ metadata. Companion to [aibi-dax](https://github.com/SourinRakshit-ai/aibi-dax):
5
+ where aibi-dax checks the DAX expressions inside your measures, aibi-toolkit
6
+ checks the model around them — naming conventions, format strings, duplicate
7
+ measures, empty tables, relationships, hygiene.
8
+
9
+ [![CI](https://github.com/SourinRakshit-ai/aibi-toolkit/actions/workflows/ci.yml/badge.svg)](https://github.com/SourinRakshit-ai/aibi-toolkit/actions/workflows/ci.yml)
10
+ [![Lint](https://github.com/SourinRakshit-ai/aibi-toolkit/actions/workflows/lint.yml/badge.svg)](https://github.com/SourinRakshit-ai/aibi-toolkit/actions/workflows/lint.yml)
11
+ [![Python](https://img.shields.io/badge/python-3.10–3.13-blue)](pyproject.toml)
12
+ [![Types](https://img.shields.io/badge/mypy-strict-blue)](pyproject.toml)
13
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](.github/workflows/lint.yml)
14
+ [![Docs](https://img.shields.io/badge/docs-live-informational)](https://sourinrakshit-ai.github.io/aibi-toolkit/)
15
+ ![License](https://img.shields.io/badge/license-MIT-green)
16
+
17
+ Runnable walkthroughs live in [`examples/`](examples/#readme).
18
+
19
+ ## Why this exists
20
+
21
+ A semantic model is a shared asset, and it always drifts. Measure names pick
22
+ up stray spaces, missing format strings, duplicate definitions that nobody
23
+ deletes, and DAX smells that pass casual review. Nobody catches it, because
24
+ each file is small but the model is large, and nobody wants to be the one
25
+ recounting the measures by hand.
26
+
27
+ That is the failure mode aibi-toolkit was built for. It reads the dump, runs
28
+ the checks, gives you a score, and names the findings. The first pass
29
+ usually looks like: score 38, a dozen missing format strings, six duplicate
30
+ measures.
31
+
32
+ ## What it does
33
+
34
+ - **`aibi audit`** — measure hygiene findings and a 0-100 score.
35
+ Checks format strings, case-insensitive duplicate names, and measure
36
+ name length. Exit 1 when anything is found, 0 when the model is clean,
37
+ so a CI gate is one command.
38
+ - **`aibi lint`** — static checks on the DAX expressions: raw `/` without
39
+ `DIVIDE`, no-argument `ALLSELECTED()`, `CALCULATE([])`, and `IFERROR`
40
+ masking.
41
+ - **`aibi fix`** — applies naming and format-string fixes with `--dry-run`
42
+ so you always see what would change before it changes.
43
+ - **`aibi summary`** — object counts; **`aibi tables`** — table list.
44
+ - **`aibi report`** — markdown audit report: score, finding counts,
45
+ examples, for your own paper trail or a PR description.
46
+ - **`aibi diagram`** — mermaid ER diagram straight from the model.
47
+ - **`aibi profile`** — expression complexity: count, average, max weight,
48
+ and the heaviest measures named.
49
+ - **`aibi synth`** — generate a sample model for trying the tool.
50
+ - **`aibi export`** — measures to CSV for external row-checks.
51
+
52
+ Full module map:
53
+
54
+ | Area | Module |
55
+ | ------------------ | --------------- |
56
+ | Naming | `naming` |
57
+ | Format strings | `measure` |
58
+ | DAX snippets | `dax`, `filters`|
59
+ | Model inspection | `metadata` |
60
+ | Auditing + linting | `audit`, `lint` |
61
+ | Integrity | `integrity` |
62
+ | Autofixes | `autofix` |
63
+ | Diagrams | `diagram` |
64
+ | Reports | `report` |
65
+ | Demo data | `sample` |
66
+ | Renderers | `tables` |
67
+ | Configuration | `config` |
68
+ | Profiling | `profile` |
69
+ | CSV round-trip | `csvio` |
70
+
71
+ ## Install
72
+
73
+ Not on PyPI yet; install from the repository. Issue [#5](https://github.com/SourinRakshit-ai/aibi-toolkit/issues/5) tracks the trusted-publishing release:
74
+
75
+ ```bash
76
+ git clone https://github.com/SourinRakshit-ai/aibi-toolkit.git
77
+ cd aibi-toolkit
78
+ pip install .
79
+ aibi --help
80
+ ```
81
+
82
+ ## Quick start
83
+
84
+ Generate a sample model, then check it:
85
+
86
+ ```bash
87
+ aibi synth model.json # write a sample model
88
+ aibi summary model.json # object counts
89
+ aibi audit model.json # hygiene findings + 0-100 score
90
+ aibi lint model.json # DAX rule findings
91
+ aibi audit model.json --json # machine-readable output (also: lint, profile)
92
+ aibi report model.json out.md # markdown audit report
93
+ aibi fix --dry-run model.json # preview fixes before writing anything
94
+ ```
95
+
96
+ Audit returns exit `1` when findings exist, `0` when clean, so a pipeline
97
+ that already has `set -e` fails immediately. Pass `--json` to `audit`,
98
+ `lint` or `profile` when you want a machine-readable result.
99
+
100
+ ## How it helps
101
+
102
+ - **One number first.** The 0–100 score tells you whether the model
103
+ deserves attention before you read a single measure. Score 38 usually
104
+ means "regenerate formats and delete the dead duplicates"; score 92
105
+ means "quick answer, move on".
106
+ - **Names and formats are the fix.** Around 90% of findings in real
107
+ models are `missing_format` and duplicates after a bulk edit; both
108
+ are auto-fixable by `aibi fix` with `--dry-run` for confirmation.
109
+ - **Exit codes mean CI.** `aibi audit model.json` returns 1 with any
110
+ finding and 0 clean, so the release pipeline it belongs in fails where
111
+ the merge should wait for you.
112
+ - **The report is the artifact.** `aibi report` gives a reviewer the
113
+ score and a short list of examples, which is usually enough for the
114
+ release meeting.
115
+
116
+ ## What it is not
117
+
118
+ - **Not an aibi-dax substitute.** It lints DAX for narrowly-scoped
119
+ patterns (raw `/`, no-arg `ALLSELECTED()`, `CALCULATE([])`, `IFERROR`
120
+ hiding). For deep complexity scoring and anti-pattern detection,
121
+ that is what [aibi-dax](https://github.com/SourinRakshit-ai/aibi-dax)
122
+ is for.
123
+ - **Not a full TMDL/PBIP authoring tool.** It reads shared-schema
124
+ model dumps; it does not write them back to disk yet
125
+ (tracked in [#6](https://github.com/SourinRakshit-ai/aibi-toolkit/issues/6)).
126
+ - **Not a bug finder for DAX logic.** It checks static patterns; it
127
+ cannot tell you your total is wrong. That still needs `EVALUATE`
128
+ checks and your eyes.
129
+ - **Not a performance tool.** It has no cost model for queries; it
130
+ flags patterns, not benchmarks.
131
+
132
+ ## Commands
133
+
134
+ | Command | Purpose |
135
+ | ------- | ------- |
136
+ | `aibi summary model.json` | object counts |
137
+ | `aibi tables model.json` | list tables |
138
+ | `aibi audit model.json` | hygiene findings + 0-100 score |
139
+ | `aibi lint model.json` | DAX rule findings |
140
+ | `aibi fix --dry-run model.json` | preview naming/format fixes (omit `--dry-run` to apply) |
141
+ | `aibi profile model.json` | expression complexity: count, avg, max, heavy |
142
+ | `aibi diagram model.json` | mermaid ER diagram |
143
+ | `aibi export model.json out.csv` | measures to CSV |
144
+ | `aibi report model.json out.md` | markdown audit report |
145
+ | `aibi synth model.json` | generate a sample model |
146
+
147
+ ## Docs and support
148
+
149
+ - **Docs site:** [sourinrakshit-ai.github.io/aibi-toolkit](https://sourinrakshit-ai.github.io/aibi-toolkit/) (`mkdocs gh-deploy`)
150
+ - **Issues:** [https://github.com/SourinRakshit-ai/aibi-toolkit/issues](https://github.com/SourinRakshit-ai/aibi-toolkit/issues)
151
+ - **Status:** `v1.2.0` on main. Not yet published to PyPI; trusted publishing
152
+ for the repo is tracked in [#5](https://github.com/SourinRakshit-ai/aibi-toolkit/issues/5),
153
+ with the pattern now proven by [aibi-dax](https://github.com/SourinRakshit-ai/aibi-dax).
154
+ - **Releases:** tagged `v*` triggers the `publish.yml` workflow once
155
+ trusted publishing is configured.
156
+
157
+ ## Development
158
+
159
+ ```bash
160
+ make install # pip install -e ".[dev]"
161
+ make test # pytest -q
162
+ make typecheck # mypy --strict src/aibi_toolkit/
163
+ make lint # ruff check src/ tests/
164
+ make serve-docs # mkdocs serve
165
+ ```
166
+
167
+ MIT licensed. Roadmap lives in the issue tracker.
@@ -0,0 +1,44 @@
1
+ [project]
2
+ name = "aibi-toolkit"
3
+ version = "1.2.0"
4
+ description = "Clean up Power BI / Tableau semantic-model metadata: naming, format strings, DAX snippets, hygiene auditing, linting, diagrams and reports"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = { file = "LICENSE" }
8
+ authors = [{ name = "Sourin Rakshit" }]
9
+ keywords = ["powerbi", "tableau", "dax", "tmdl", "semantic-model", "lint"]
10
+ classifiers = [
11
+ "Development Status :: 5 - Production/Stable",
12
+ "Environment :: Console",
13
+ "Operating System :: OS Independent",
14
+ "Programming Language :: Python :: 3.10",
15
+ "Programming Language :: Python :: 3.11",
16
+ "Programming Language :: Python :: 3.12",
17
+ "Programming Language :: Python :: 3.13",
18
+ "Topic :: Software Development :: Quality Assurance",
19
+ "Topic :: Software Development :: Libraries :: Python Modules",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/SourinRakshit-ai/aibi-toolkit"
24
+ Changelog = "https://github.com/SourinRakshit-ai/aibi-toolkit/blob/main/CHANGELOG.md"
25
+ Issues = "https://github.com/SourinRakshit-ai/aibi-toolkit/issues"
26
+
27
+ [project.scripts]
28
+ aibi = "aibi_toolkit.cli:main"
29
+
30
+ [project.optional-dependencies]
31
+ dev = ["pytest", "mypy", "ruff"]
32
+ docs = ["mkdocs-material"]
33
+
34
+ [build-system]
35
+ requires = ["setuptools>=68"]
36
+ build-backend = "setuptools.build_meta"
37
+
38
+ [tool.setuptools.packages.find]
39
+ where = ["src"]
40
+
41
+ [tool.mypy]
42
+ disallow_untyped_defs = true
43
+ disallow_any_generics = true
44
+ warn_return_any = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,44 @@
1
+ """aibi-toolkit: helpers for BI semantic-model metadata cleanup.
2
+
3
+ API is stable as of 1.0 — new functionality lands after this point will
4
+ be additive.
5
+ """
6
+
7
+ from . import (
8
+ audit,
9
+ autofix,
10
+ config,
11
+ csvio,
12
+ dax,
13
+ diagram,
14
+ filters,
15
+ integrity,
16
+ lint,
17
+ measure,
18
+ metadata,
19
+ naming,
20
+ profile,
21
+ report,
22
+ sample,
23
+ tables,
24
+ )
25
+
26
+ __version__ = "1.2.0"
27
+ __all__ = [
28
+ "audit",
29
+ "autofix",
30
+ "config",
31
+ "csvio",
32
+ "dax",
33
+ "diagram",
34
+ "filters",
35
+ "integrity",
36
+ "lint",
37
+ "measure",
38
+ "metadata",
39
+ "naming",
40
+ "profile",
41
+ "report",
42
+ "sample",
43
+ "tables",
44
+ ]
@@ -0,0 +1,12 @@
1
+ """Allow `python -m aibi_toolkit` to behave like the `aibi` console script.
2
+
3
+ The console script is the documented entry point (`aibi ...`); this module
4
+ exists so that people who reach for `python -m` get the same CLI.
5
+ """
6
+
7
+ import sys
8
+
9
+ from aibi_toolkit.cli import main
10
+
11
+ if __name__ == "__main__":
12
+ sys.exit(main())
@@ -0,0 +1,46 @@
1
+ from __future__ import annotations
2
+
3
+ from .metadata import Model
4
+
5
+ """Model hygiene audits for semantic models."""
6
+
7
+ from .metadata import list_measures
8
+
9
+
10
+ def audit_measures(model: Model) -> dict[str, list[str]]:
11
+ """Run a measure hygiene audit and return findings by category."""
12
+ measures = list_measures(model)
13
+ findings: dict[str, list[str]] = {
14
+ "missing_format": [],
15
+ "duplicate_names": [],
16
+ "long_names": [],
17
+ }
18
+ seen: set[str] = set()
19
+ for m in measures:
20
+ if not m.get("formatString"):
21
+ findings["missing_format"].append(m["name"])
22
+ if m["name"].lower() in seen:
23
+ findings["duplicate_names"].append(m["name"])
24
+ seen.add(m["name"].lower())
25
+ if len(m["name"]) > 64:
26
+ findings["long_names"].append(m["name"])
27
+ return findings
28
+
29
+ def audit_score(model: Model) -> int:
30
+ """Score 0-100 based on measure hygiene findings."""
31
+ measures = list_measures(model)
32
+ if not measures:
33
+ return 100
34
+ findings = audit_measures(model)
35
+ problems = sum(len(v) for v in findings.values())
36
+ return max(0, 100 - round(100 * problems / (2 * len(measures))))
37
+
38
+ def audit_tables(model: Model) -> dict[str, list[str]]:
39
+ """Table-level findings: name issues and empty tables."""
40
+ out: dict[str, list[str]] = {"empty": [], "bad_names": []}
41
+ for t in model.get("tables", []):
42
+ if not t.get("columns") and not t.get("measures"):
43
+ out["empty"].append(t["name"])
44
+ if t["name"] != t["name"].strip() or " " in t["name"]:
45
+ out["bad_names"].append(t["name"])
46
+ return out
@@ -0,0 +1,47 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ from .metadata import Model
6
+
7
+ """Automatic naming fixes for semantic-model dumps."""
8
+
9
+
10
+ def fix_measure_name(name: str) -> str:
11
+ """Turn a raw measure name into a display-safe one."""
12
+ from .naming import strip_numbers, to_display_name
13
+ return truncate(to_display_name(strip_numbers(name)), 64)
14
+
15
+
16
+ def truncate(name: str, limit: int = 64) -> str:
17
+ """Truncate without trailing separators."""
18
+ out = name[:limit].rstrip()
19
+ while out and out[-1] in "-_ ":
20
+ out = out[:-1].rstrip()
21
+ return out
22
+
23
+
24
+ def suggest_format(expression: str) -> str:
25
+ """Suggest a format string from a measure expression."""
26
+ from .naming import expand_abbreviations
27
+ lowered = expression.lower()
28
+ if any(k in lowered for k in ("divide", "distinctcount", "count(")):
29
+ return "#,0"
30
+ if "%" in expand_abbreviations(lowered)[:40]:
31
+ return "0.0%"
32
+ return "$#,0.00"
33
+
34
+
35
+ def autofix_model(model: Model) -> dict[str, Any]:
36
+ """Apply non-destructive fixes; returns a change log."""
37
+ changes: list[str] = []
38
+ for t in model.get("tables", []):
39
+ for m in t.get("measures", []):
40
+ fixed = fix_measure_name(m["name"])
41
+ if fixed != m["name"]:
42
+ changes.append(f"measure '{m['name']}' -> '{fixed}'")
43
+ m["name"] = fixed
44
+ if not m.get("formatString"):
45
+ m["formatString"] = suggest_format(m.get("expression", ""))
46
+ changes.append(f"format for '{m['name']}' -> {m['formatString']}")
47
+ return {"changes": changes, "count": len(changes)}