model2data 1.19.0__tar.gz → 1.21.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 (215) hide show
  1. {model2data-1.19.0/model2data.egg-info → model2data-1.21.0}/PKG-INFO +7 -1
  2. {model2data-1.19.0 → model2data-1.21.0}/README.md +11 -0
  3. {model2data-1.19.0 → model2data-1.21.0}/README_PYPI.md +6 -0
  4. {model2data-1.19.0 → model2data-1.21.0}/model2data/cli.py +219 -9
  5. model2data-1.21.0/model2data/dashboards/__init__.py +94 -0
  6. model2data-1.21.0/model2data/dashboards/check.py +682 -0
  7. model2data-1.21.0/model2data/dashboards/reader.py +121 -0
  8. model2data-1.21.0/model2data/dashboards/types.py +228 -0
  9. model2data-1.21.0/model2data/dashboards/writer.py +107 -0
  10. {model2data-1.19.0 → model2data-1.21.0}/model2data/dbt/naming.py +19 -2
  11. model2data-1.21.0/model2data/dbt/templates/rollup_macros/model2data_rollup_tests.sql +58 -0
  12. {model2data-1.19.0 → model2data-1.21.0}/model2data/dbt/tests.py +59 -4
  13. {model2data-1.19.0 → model2data-1.21.0}/model2data/defects/checks.py +61 -0
  14. {model2data-1.19.0 → model2data-1.21.0}/model2data/generate/core.py +114 -10
  15. {model2data-1.19.0 → model2data-1.21.0}/model2data/generate/days.py +23 -0
  16. {model2data-1.19.0 → model2data-1.21.0}/model2data/generate/hints.py +7 -1
  17. {model2data-1.19.0 → model2data-1.21.0}/model2data/generate/parents.py +8 -1
  18. model2data-1.21.0/model2data/generate/rollups.py +698 -0
  19. {model2data-1.19.0 → model2data-1.21.0}/model2data/generate/timeline.py +5 -1
  20. model2data-1.21.0/model2data/guide/dashboards.md +96 -0
  21. {model2data-1.19.0 → model2data-1.21.0}/model2data/guide/setup.md +2 -2
  22. {model2data-1.19.0 → model2data-1.21.0}/model2data/guide/triage.md +17 -5
  23. {model2data-1.19.0 → model2data-1.21.0}/model2data/guide/tune.md +38 -6
  24. {model2data-1.19.0 → model2data-1.21.0}/model2data/model/__init__.py +1 -1
  25. {model2data-1.19.0 → model2data-1.21.0}/model2data/model/dbml.py +6 -3
  26. {model2data-1.19.0 → model2data-1.21.0}/model2data/model/document.py +54 -2
  27. {model2data-1.19.0 → model2data-1.21.0}/model2data/model/types.py +1 -1
  28. {model2data-1.19.0 → model2data-1.21.0}/model2data/model/validate.py +63 -14
  29. {model2data-1.19.0 → model2data-1.21.0}/model2data/spec/PUBLISHING.md +34 -12
  30. {model2data-1.19.0 → model2data-1.21.0}/model2data/spec/README.md +82 -5
  31. model2data-1.21.0/model2data/spec/dashboards/README.md +232 -0
  32. model2data-1.21.0/model2data/spec/dashboards/dashboard.schema.json +152 -0
  33. model2data-1.21.0/model2data/spec/examples/coffee_webshop_sales.dashboard.yml +91 -0
  34. {model2data-1.19.0 → model2data-1.21.0}/model2data/spec/model.schema.json +51 -5
  35. {model2data-1.19.0 → model2data-1.21.0/model2data.egg-info}/PKG-INFO +7 -1
  36. {model2data-1.19.0 → model2data-1.21.0}/model2data.egg-info/SOURCES.txt +14 -0
  37. {model2data-1.19.0 → model2data-1.21.0}/pyproject.toml +1 -1
  38. model2data-1.21.0/tests/test_dashboards.py +824 -0
  39. model2data-1.21.0/tests/test_dashboards_cli.py +224 -0
  40. {model2data-1.19.0 → model2data-1.21.0}/tests/test_dbt_integration.py +47 -0
  41. {model2data-1.19.0 → model2data-1.21.0}/tests/test_defects.py +2 -1
  42. {model2data-1.19.0 → model2data-1.21.0}/tests/test_model_messages.py +4 -4
  43. model2data-1.21.0/tests/test_rollups.py +1023 -0
  44. {model2data-1.19.0 → model2data-1.21.0}/LICENSE +0 -0
  45. {model2data-1.19.0 → model2data-1.21.0}/model2data/__init__.py +0 -0
  46. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/__init__.py +0 -0
  47. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/LICENSE +0 -0
  48. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/VENDORED.md +0 -0
  49. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/__init__.py +0 -0
  50. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/_classes/__init__.py +0 -0
  51. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/_classes/base.py +0 -0
  52. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/_classes/column.py +0 -0
  53. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/_classes/enum.py +0 -0
  54. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/_classes/expression.py +0 -0
  55. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/_classes/index.py +0 -0
  56. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/_classes/note.py +0 -0
  57. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/_classes/project.py +0 -0
  58. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/_classes/reference.py +0 -0
  59. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/_classes/sticky_note.py +0 -0
  60. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/_classes/table.py +0 -0
  61. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/_classes/table_group.py +0 -0
  62. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/classes/__init__.py +0 -0
  63. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/constants.py +0 -0
  64. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/database.py +0 -0
  65. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/__init__.py +0 -0
  66. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/column.py +0 -0
  67. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/common.py +0 -0
  68. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/enum.py +0 -0
  69. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/generic.py +0 -0
  70. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/index.py +0 -0
  71. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/project.py +0 -0
  72. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/records.py +0 -0
  73. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/reference.py +0 -0
  74. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/sticky_note.py +0 -0
  75. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/table.py +0 -0
  76. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/table_group.py +0 -0
  77. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/definitions/table_partial.py +0 -0
  78. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/exceptions.py +0 -0
  79. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/parser/__init__.py +0 -0
  80. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/parser/blueprints.py +0 -0
  81. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/parser/parser.py +0 -0
  82. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/__init__.py +0 -0
  83. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/base.py +0 -0
  84. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/__init__.py +0 -0
  85. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/__init__.py +0 -0
  86. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/column.py +0 -0
  87. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/enum.py +0 -0
  88. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/expression.py +0 -0
  89. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/index.py +0 -0
  90. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/note.py +0 -0
  91. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/project.py +0 -0
  92. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/reference.py +0 -0
  93. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/renderer.py +0 -0
  94. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/sticky_note.py +0 -0
  95. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/table.py +0 -0
  96. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/table_group.py +0 -0
  97. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/dbml/default/utils.py +0 -0
  98. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/sql/__init__.py +0 -0
  99. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/sql/default/__init__.py +0 -0
  100. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/sql/default/column.py +0 -0
  101. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/sql/default/enum.py +0 -0
  102. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/sql/default/expression.py +0 -0
  103. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/sql/default/index.py +0 -0
  104. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/sql/default/note.py +0 -0
  105. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/sql/default/reference.py +0 -0
  106. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/sql/default/renderer.py +0 -0
  107. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/sql/default/table.py +0 -0
  108. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/renderer/sql/default/utils.py +0 -0
  109. {model2data-1.19.0 → model2data-1.21.0}/model2data/_vendor/pydbml/tools.py +0 -0
  110. {model2data-1.19.0 → model2data-1.21.0}/model2data/dbt/__init__.py +0 -0
  111. {model2data-1.19.0 → model2data-1.21.0}/model2data/dbt/hint_tests.py +0 -0
  112. {model2data-1.19.0 → model2data-1.21.0}/model2data/dbt/project.py +0 -0
  113. {model2data-1.19.0 → model2data-1.21.0}/model2data/dbt/templates/dbt_project.yml.jinja +0 -0
  114. {model2data-1.19.0 → model2data-1.21.0}/model2data/dbt/templates/hint_macros/model2data_hint_tests.sql +0 -0
  115. {model2data-1.19.0 → model2data-1.21.0}/model2data/dbt/templates/hint_macros/model2data_parent_tests.sql +0 -0
  116. {model2data-1.19.0 → model2data-1.21.0}/model2data/dbt/templates/hint_macros/model2data_when_tests.sql +0 -0
  117. {model2data-1.19.0 → model2data-1.21.0}/model2data/dbt/templates/history_macros/model2data_history_tests.sql +0 -0
  118. {model2data-1.19.0 → model2data-1.21.0}/model2data/dbt/templates/macros/generate_schema_name.sql +0 -0
  119. {model2data-1.19.0 → model2data-1.21.0}/model2data/dbt/templates/profiles.yml.jinja +0 -0
  120. {model2data-1.19.0 → model2data-1.21.0}/model2data/defects/__init__.py +0 -0
  121. {model2data-1.19.0 → model2data-1.21.0}/model2data/defects/apply.py +0 -0
  122. {model2data-1.19.0 → model2data-1.21.0}/model2data/defects/presets.py +0 -0
  123. {model2data-1.19.0 → model2data-1.21.0}/model2data/defects/report.py +0 -0
  124. {model2data-1.19.0 → model2data-1.21.0}/model2data/generate/__init__.py +0 -0
  125. {model2data-1.19.0 → model2data-1.21.0}/model2data/generate/faker.py +0 -0
  126. {model2data-1.19.0 → model2data-1.21.0}/model2data/generate/history.py +0 -0
  127. {model2data-1.19.0 → model2data-1.21.0}/model2data/generate/kinds.py +0 -0
  128. {model2data-1.19.0 → model2data-1.21.0}/model2data/generate/options.py +0 -0
  129. {model2data-1.19.0 → model2data-1.21.0}/model2data/generate/relationships.py +0 -0
  130. {model2data-1.19.0 → model2data-1.21.0}/model2data/generate/when.py +0 -0
  131. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/__init__.py +0 -0
  132. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/check.py +0 -0
  133. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/columns.py +0 -0
  134. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/dbt.py +0 -0
  135. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/expression.py +0 -0
  136. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/graph.py +0 -0
  137. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/infer.py +0 -0
  138. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/lightdash.py +0 -0
  139. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/ossie.py +0 -0
  140. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/reader.py +0 -0
  141. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/semantic.py +0 -0
  142. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/slices.py +0 -0
  143. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/sql.py +0 -0
  144. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/types.py +0 -0
  145. {model2data-1.19.0 → model2data-1.21.0}/model2data/metrics/values.py +0 -0
  146. {model2data-1.19.0 → model2data-1.21.0}/model2data/model/_yaml.py +0 -0
  147. {model2data-1.19.0 → model2data-1.21.0}/model2data/model/dump.py +0 -0
  148. {model2data-1.19.0 → model2data-1.21.0}/model2data/model/engine.py +0 -0
  149. {model2data-1.19.0 → model2data-1.21.0}/model2data/model/errors.py +0 -0
  150. {model2data-1.19.0 → model2data-1.21.0}/model2data/model/reader.py +0 -0
  151. {model2data-1.19.0 → model2data-1.21.0}/model2data/output.py +0 -0
  152. {model2data-1.19.0 → model2data-1.21.0}/model2data/parse/__init__.py +0 -0
  153. {model2data-1.19.0 → model2data-1.21.0}/model2data/parse/dbml.py +0 -0
  154. {model2data-1.19.0 → model2data-1.21.0}/model2data/spec/examples/coffee_webshop.metrics.yml +0 -0
  155. {model2data-1.19.0 → model2data-1.21.0}/model2data/spec/examples/coffee_webshop.model2data.yml +0 -0
  156. {model2data-1.19.0 → model2data-1.21.0}/model2data/spec/metrics/README.md +0 -0
  157. {model2data-1.19.0 → model2data-1.21.0}/model2data/spec/metrics/metrics.schema.json +0 -0
  158. {model2data-1.19.0 → model2data-1.21.0}/model2data/utils.py +0 -0
  159. {model2data-1.19.0 → model2data-1.21.0}/model2data.egg-info/dependency_links.txt +0 -0
  160. {model2data-1.19.0 → model2data-1.21.0}/model2data.egg-info/entry_points.txt +0 -0
  161. {model2data-1.19.0 → model2data-1.21.0}/model2data.egg-info/requires.txt +0 -0
  162. {model2data-1.19.0 → model2data-1.21.0}/model2data.egg-info/top_level.txt +0 -0
  163. {model2data-1.19.0 → model2data-1.21.0}/setup.cfg +0 -0
  164. {model2data-1.19.0 → model2data-1.21.0}/tests/test_as_of_anchor.py +0 -0
  165. {model2data-1.19.0 → model2data-1.21.0}/tests/test_cli.py +0 -0
  166. {model2data-1.19.0 → model2data-1.21.0}/tests/test_cli_model.py +0 -0
  167. {model2data-1.19.0 → model2data-1.21.0}/tests/test_column_time_hints.py +0 -0
  168. {model2data-1.19.0 → model2data-1.21.0}/tests/test_coverage_gaps.py +0 -0
  169. {model2data-1.19.0 → model2data-1.21.0}/tests/test_days.py +0 -0
  170. {model2data-1.19.0 → model2data-1.21.0}/tests/test_dbml_parser.py +0 -0
  171. {model2data-1.19.0 → model2data-1.21.0}/tests/test_dbml_parser_fuzz.py +0 -0
  172. {model2data-1.19.0 → model2data-1.21.0}/tests/test_dbt_naming.py +0 -0
  173. {model2data-1.19.0 → model2data-1.21.0}/tests/test_dbt_project.py +0 -0
  174. {model2data-1.19.0 → model2data-1.21.0}/tests/test_dbt_tests.py +0 -0
  175. {model2data-1.19.0 → model2data-1.21.0}/tests/test_defects_dbt.py +0 -0
  176. {model2data-1.19.0 → model2data-1.21.0}/tests/test_defects_replay.py +0 -0
  177. {model2data-1.19.0 → model2data-1.21.0}/tests/test_defects_report.py +0 -0
  178. {model2data-1.19.0 → model2data-1.21.0}/tests/test_defects_review.py +0 -0
  179. {model2data-1.19.0 → model2data-1.21.0}/tests/test_determinism.py +0 -0
  180. {model2data-1.19.0 → model2data-1.21.0}/tests/test_distributions.py +0 -0
  181. {model2data-1.19.0 → model2data-1.21.0}/tests/test_examples_model.py +0 -0
  182. {model2data-1.19.0 → model2data-1.21.0}/tests/test_faker_name_inference.py +0 -0
  183. {model2data-1.19.0 → model2data-1.21.0}/tests/test_fast_paths.py +0 -0
  184. {model2data-1.19.0 → model2data-1.21.0}/tests/test_generation.py +0 -0
  185. {model2data-1.19.0 → model2data-1.21.0}/tests/test_guide.py +0 -0
  186. {model2data-1.19.0 → model2data-1.21.0}/tests/test_hint_tests.py +0 -0
  187. {model2data-1.19.0 → model2data-1.21.0}/tests/test_history.py +0 -0
  188. {model2data-1.19.0 → model2data-1.21.0}/tests/test_issue_lines.py +0 -0
  189. {model2data-1.19.0 → model2data-1.21.0}/tests/test_lone_country.py +0 -0
  190. {model2data-1.19.0 → model2data-1.21.0}/tests/test_metrics_cli.py +0 -0
  191. {model2data-1.19.0 → model2data-1.21.0}/tests/test_metrics_dbt.py +0 -0
  192. {model2data-1.19.0 → model2data-1.21.0}/tests/test_metrics_expression.py +0 -0
  193. {model2data-1.19.0 → model2data-1.21.0}/tests/test_metrics_lightdash.py +0 -0
  194. {model2data-1.19.0 → model2data-1.21.0}/tests/test_metrics_ossie.py +0 -0
  195. {model2data-1.19.0 → model2data-1.21.0}/tests/test_metrics_prepared.py +0 -0
  196. {model2data-1.19.0 → model2data-1.21.0}/tests/test_metrics_reader.py +0 -0
  197. {model2data-1.19.0 → model2data-1.21.0}/tests/test_metrics_semantic.py +0 -0
  198. {model2data-1.19.0 → model2data-1.21.0}/tests/test_metrics_slices.py +0 -0
  199. {model2data-1.19.0 → model2data-1.21.0}/tests/test_metrics_spec.py +0 -0
  200. {model2data-1.19.0 → model2data-1.21.0}/tests/test_metrics_values.py +0 -0
  201. {model2data-1.19.0 → model2data-1.21.0}/tests/test_model.py +0 -0
  202. {model2data-1.19.0 → model2data-1.21.0}/tests/test_model_dbml.py +0 -0
  203. {model2data-1.19.0 → model2data-1.21.0}/tests/test_model_edges.py +0 -0
  204. {model2data-1.19.0 → model2data-1.21.0}/tests/test_model_vocabulary.py +0 -0
  205. {model2data-1.19.0 → model2data-1.21.0}/tests/test_options.py +0 -0
  206. {model2data-1.19.0 → model2data-1.21.0}/tests/test_parent_dates.py +0 -0
  207. {model2data-1.19.0 → model2data-1.21.0}/tests/test_release_stress.py +0 -0
  208. {model2data-1.19.0 → model2data-1.21.0}/tests/test_reproducibility.py +0 -0
  209. {model2data-1.19.0 → model2data-1.21.0}/tests/test_row_identity.py +0 -0
  210. {model2data-1.19.0 → model2data-1.21.0}/tests/test_shaping.py +0 -0
  211. {model2data-1.19.0 → model2data-1.21.0}/tests/test_spec_alignment.py +0 -0
  212. {model2data-1.19.0 → model2data-1.21.0}/tests/test_spec_schema.py +0 -0
  213. {model2data-1.19.0 → model2data-1.21.0}/tests/test_table_seeds.py +0 -0
  214. {model2data-1.19.0 → model2data-1.21.0}/tests/test_timeline.py +0 -0
  215. {model2data-1.19.0 → model2data-1.21.0}/tests/test_when.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: model2data
3
- Version: 1.19.0
3
+ Version: 1.21.0
4
4
  Summary: Turn a data model into realistic synthetic data, a runnable dbt project and metrics with known values
5
5
  Author: JB Analytica
6
6
  License-Expression: MIT
@@ -280,6 +280,12 @@ should fail. → [Defects on purpose](https://github.com/JB-Analytica/model2data
280
280
  an Apache Ossie semantic model, and with `--lightdash` the same metrics as Lightdash reads them.
281
281
  → [Metrics with known values](https://github.com/JB-Analytica/model2data/blob/main/docs/metrics.md)
282
282
 
283
+ **Dashboards as files.** A `<name>.dashboard.yml` lays out KPI, chart, filter and table tiles
284
+ over the model's metrics and columns, and holds no values. `model2data dashboard check` checks it
285
+ offline, with the line and column of every issue and a suggestion for every unknown name;
286
+ [model2data studio](https://studio.jbanalytica.com) draws it with the numbers.
287
+ → [The dashboard spec](https://github.com/JB-Analytica/model2data/blob/main/model2data/spec/dashboards/README.md)
288
+
283
289
  **Validate in CI.** `model2data validate` prints GitHub annotations; `uses: JB-Analytica/model2data@v1`
284
290
  fails a pull request that breaks a model. Pre-commit and GitLab CI too. → [Validate models in CI](https://github.com/JB-Analytica/model2data/blob/main/docs/ci.md)
285
291
 
@@ -26,6 +26,11 @@ cd dbt_ecommerce && dbt build # PA
26
26
  > is this engine in the browser: draw the schema, see every column's values before you generate,
27
27
  > shape the data on a sample of your own, and export a dbt project with a star schema or Data
28
28
  > Vault on top. [Start free, no install →](https://studio.jbanalytica.com)
29
+ >
30
+ > **Or ask Claude.** Add `https://studio.jbanalytica.com/mcp` as a connector in Claude Code,
31
+ > Claude Desktop or claude.ai, sign in, and Claude builds the model, the data, metrics with known
32
+ > answers and a dashboard from one sentence. Works on the free plan.
33
+ > [![model2data studio MCP connector – tool definition quality and endpoint health on Glama](https://glama.ai/mcp/connectors/io.github.JB-Analytica/model2data-studio/badges/score.svg)](https://glama.ai/mcp/connectors/io.github.JB-Analytica/model2data-studio)
29
34
 
30
35
  ---
31
36
 
@@ -233,6 +238,12 @@ should fail. → [Defects on purpose](docs/defects.md)
233
238
  an Apache Ossie semantic model, and with `--lightdash` the same metrics as Lightdash reads them.
234
239
  → [Metrics with known values](docs/metrics.md)
235
240
 
241
+ **Dashboards as files.** A `<name>.dashboard.yml` lays out KPI, chart, filter and table tiles
242
+ over the model's metrics and columns, and holds no values. `model2data dashboard check` checks it
243
+ offline, with the line and column of every issue and a suggestion for every unknown name;
244
+ [model2data studio](https://studio.jbanalytica.com) draws it with the numbers.
245
+ → [The dashboard spec](model2data/spec/dashboards/README.md)
246
+
236
247
  **Validate in CI.** `model2data validate` prints GitHub annotations; `uses: JB-Analytica/model2data@v1`
237
248
  fails a pull request that breaks a model. Pre-commit and GitLab CI too. → [Validate models in CI](docs/ci.md)
238
249
 
@@ -233,6 +233,12 @@ should fail. → [Defects on purpose](https://github.com/JB-Analytica/model2data
233
233
  an Apache Ossie semantic model, and with `--lightdash` the same metrics as Lightdash reads them.
234
234
  → [Metrics with known values](https://github.com/JB-Analytica/model2data/blob/main/docs/metrics.md)
235
235
 
236
+ **Dashboards as files.** A `<name>.dashboard.yml` lays out KPI, chart, filter and table tiles
237
+ over the model's metrics and columns, and holds no values. `model2data dashboard check` checks it
238
+ offline, with the line and column of every issue and a suggestion for every unknown name;
239
+ [model2data studio](https://studio.jbanalytica.com) draws it with the numbers.
240
+ → [The dashboard spec](https://github.com/JB-Analytica/model2data/blob/main/model2data/spec/dashboards/README.md)
241
+
236
242
  **Validate in CI.** `model2data validate` prints GitHub annotations; `uses: JB-Analytica/model2data@v1`
237
243
  fails a pull request that breaks a model. Pre-commit and GitLab CI too. → [Validate models in CI](https://github.com/JB-Analytica/model2data/blob/main/docs/ci.md)
238
244
 
@@ -13,6 +13,8 @@ from faker import Faker
13
13
  from typer.core import TyperGroup
14
14
  from typer.models import ParameterInfo
15
15
 
16
+ from model2data import dashboards
17
+ from model2data.dashboards.check import declared_model
16
18
  from model2data.dbt.hint_tests import DEFAULT_TOLERANCE, SEVERITIES
17
19
  from model2data.dbt.naming import dbt_names, for_dbt
18
20
  from model2data.dbt.project import (
@@ -31,6 +33,7 @@ from model2data.generate.core import (
31
33
  generate_data_from_dbml,
32
34
  get_capped_tables,
33
35
  get_cyclic_tables,
36
+ get_uncovered_parents,
34
37
  get_unresolved_composite_keys,
35
38
  )
36
39
  from model2data.generate.days import (
@@ -185,7 +188,7 @@ app = typer.Typer(
185
188
  cls=_GenerateByDefault,
186
189
  help=(
187
190
  "model2data: Generate analytics-ready datasets from a data model.\n\n"
188
- "Given a model -- a .model2data.yml document (spec 0.5.0), the same as JSON,\n"
191
+ "Given a model -- a .model2data.yml document (spec 0.6.0), the same as JSON,\n"
189
192
  "or a DBML file -- this tool produces:\n"
190
193
  "• Synthetic but realistic data\n"
191
194
  "• A runnable dbt project scaffold\n"
@@ -775,6 +778,7 @@ def main(
775
778
  unresolved_keys = get_unresolved_composite_keys()
776
779
  duplicate_unique = get_duplicate_unique_columns()
777
780
  capped_tables = get_capped_tables()
781
+ uncovered = get_uncovered_parents()
778
782
 
779
783
  typer.echo("\n📊 Summary")
780
784
  typer.echo(f" Tables generated: {len(generated_tables)}")
@@ -820,6 +824,13 @@ def main(
820
824
  )
821
825
  for label in capped_tables:
822
826
  typer.echo(f" - {label}")
827
+ if uncovered:
828
+ typer.echo(
829
+ " ⚠️ Foreign keys with too few rows for their at_least (raise the table's rows "
830
+ "to cover every parent):"
831
+ )
832
+ for label in uncovered:
833
+ typer.echo(f" - {label}")
823
834
 
824
835
  if metrics_count is not None:
825
836
  typer.echo(
@@ -847,10 +858,10 @@ def main(
847
858
 
848
859
 
849
860
  def _spec_of(file: Path) -> str:
850
- """The spec a conforming model is written against: 0.5.0, 0.4.0, 0.3.0, or 0.2.0 (DBML
851
- without `when` or a 0.5.0 `after` included)."""
861
+ """The spec a conforming model is written against: 0.6.0, 0.5.0, 0.4.0, 0.3.0, or 0.2.0
862
+ (DBML without `when`, a 0.5.0 `after`, `rollup` or `at_least` included)."""
852
863
  version = str(load(file).version)
853
- for minor in ("0.5", "0.4", "0.3"):
864
+ for minor in ("0.6", "0.5", "0.4", "0.3"):
854
865
  if version.startswith(minor):
855
866
  return f"{minor}.0"
856
867
  return "0.2.0"
@@ -940,15 +951,18 @@ def validate_command(
940
951
  dir_okay=False,
941
952
  readable=True,
942
953
  help=(
943
- "The model a metrics file (*.metrics.yml) is checked against. Default: the model "
944
- "beside it with the same stem (coffee.model2data.yml for coffee.metrics.yml)."
954
+ "The model a metrics file (*.metrics.yml) or a dashboard (*.dashboard.yml) is "
955
+ "checked against. Default: the model beside it with the same stem "
956
+ "(coffee.model2data.yml for coffee.metrics.yml)."
945
957
  ),
946
958
  ),
947
959
  ):
948
- """Check that models conform to spec 0.5.0 (or 0.2.x-0.4.x), printing every issue with its path.
960
+ """Check that models conform to spec 0.6.0 (or 0.2.x-0.5.x), printing every issue with its path.
949
961
 
950
962
  Takes one or more files and/or --glob patterns. A metrics file (*.metrics.yml) is checked
951
- against metrics spec 0.1.0 and against its model. Exits 1 when any file has an error;
963
+ against metrics spec 0.1.0 and against its model; a dashboard (*.dashboard.yml) against
964
+ dashboard spec 0.1.0 and the names of the model and metrics beside it, as `dashboard check`
965
+ does. Exits 1 when any file has an error;
952
966
  warnings are printed, and the file conforms. A warning that a child's date `can fall
953
967
  before` its parent's names the `after: <table>.<column>` to add.
954
968
  """
@@ -966,6 +980,11 @@ def validate_command(
966
980
  against: Optional[Path] = None
967
981
  if is_metrics_file(file):
968
982
  issues, against = _metrics_issues(file, _given(model_option))
983
+ elif dashboards.is_dashboard_file(file):
984
+ found, against, _ = _dashboard_issues(file, _given(model_option), None)
985
+ issues = [
986
+ Issue(issue.path, issue.message, issue.line, issue.severity) for issue in found
987
+ ]
969
988
  else:
970
989
  issues = validate(file)
971
990
  if output_format == "github":
@@ -981,6 +1000,11 @@ def validate_command(
981
1000
  typer.echo(
982
1001
  f"✅ {shown} conforms to metrics spec {METRICS_SPEC_VERSION}{model_note}."
983
1002
  )
1003
+ elif dashboards.is_dashboard_file(file):
1004
+ model_note = f", checked against {against.name}" if against is not None else ""
1005
+ typer.echo(
1006
+ f"✅ {shown} conforms to dashboard spec {dashboards.SPEC_VERSION}{model_note}."
1007
+ )
984
1008
  else:
985
1009
  typer.echo(f"✅ {shown} conforms to spec {_spec_of(file)}.")
986
1010
  if len(targets) > 1 or output_format == "github":
@@ -1042,7 +1066,7 @@ def convert_command(
1042
1066
  ):
1043
1067
  """Convert a model -- DBML, typically -- to a .model2data.yml document (spec 0.2.0, or
1044
1068
  0.3.0 when it has defects, 0.4.0 when it has `when`, 0.5.0 when an `after` is a list or
1045
- names a parent's column)."""
1069
+ names a parent's column, 0.6.0 when it has `rollup` or `at_least`)."""
1046
1070
  try:
1047
1071
  model = load(file)
1048
1072
  except ModelError as error:
@@ -1065,6 +1089,7 @@ class GuideTopic(str, Enum):
1065
1089
  setup = "setup"
1066
1090
  triage = "triage"
1067
1091
  tune = "tune"
1092
+ dashboards = "dashboards"
1068
1093
 
1069
1094
 
1070
1095
  _MODEL_PATTERNS = ("*.model2data.yml", "*.model2data.yaml", "*.model2data.json", "*.dbml")
@@ -1089,6 +1114,7 @@ def guide_command(
1089
1114
  "setup: no model here yet -- install, write one, first run. "
1090
1115
  "triage: what validate, generate and dbt build printed, and what to do. "
1091
1116
  "tune: every option, model key and exit code. "
1117
+ "dashboards: write a *.dashboard.yml over the model's metrics and check it. "
1092
1118
  "Default: picked from the current directory (a *.model2data.yml or *.dbml "
1093
1119
  "file in it means triage)."
1094
1120
  ),
@@ -1237,3 +1263,187 @@ def metrics_export_command(
1237
1263
  _print_losses(
1238
1264
  "Not expressible in Ossie 0.1.1 itself, carried in custom_extensions", export.lossiness
1239
1265
  )
1266
+
1267
+
1268
+ dashboard_app = typer.Typer(
1269
+ help=(
1270
+ "Dashboards as files (dashboard spec 0.1.0): check a *.dashboard.yml against the "
1271
+ "spec and against the names of its model and metrics. `model2data guide dashboards` "
1272
+ "says how to write one."
1273
+ ),
1274
+ no_args_is_help=True,
1275
+ )
1276
+ app.add_typer(dashboard_app, name="dashboard")
1277
+
1278
+ _MODEL_SUFFIXES = (".model2data.yml", ".model2data.yaml", ".model2data.json", ".dbml")
1279
+ _METRICS_SUFFIXES = (".metrics.yml", ".metrics.yaml", ".metrics.json")
1280
+
1281
+
1282
+ def _beside(folder: Path, suffixes: tuple[str, ...]) -> list[Path]:
1283
+ """The files directly in `folder` whose names end in one of `suffixes`, by name."""
1284
+ return sorted(
1285
+ path for path in folder.iterdir() if path.is_file() and path.name.lower().endswith(suffixes)
1286
+ )
1287
+
1288
+
1289
+ def _dashboard_model(file: Path, text: str) -> tuple[Optional[Path], Optional[str]]:
1290
+ """The model a dashboard is checked against when none is given, or why there is none.
1291
+
1292
+ In order: the model the file's `model` names, `<model>.model2data.yml` (or `.yaml`,
1293
+ `.json`, `.dbml`) beside the file; the only model in the dashboard's folder.
1294
+ """
1295
+ folder = file.parent
1296
+ declared = declared_model(text)
1297
+ if declared:
1298
+ for suffix in _MODEL_SUFFIXES:
1299
+ candidate = folder / f"{declared}{suffix}"
1300
+ if candidate.is_file():
1301
+ return candidate, None
1302
+ models = _beside(folder, _MODEL_SUFFIXES)
1303
+ if len(models) == 1:
1304
+ return models[0], None
1305
+ if models:
1306
+ names = ", ".join(path.name for path in models)
1307
+ return None, (
1308
+ f"several models beside it ({names}), and none named by the file: its metric, "
1309
+ "table and column names are not checked; pass --model to check them"
1310
+ )
1311
+ return None, (
1312
+ "no model beside it: its metric, table and column names are not checked; "
1313
+ "pass --model to check them"
1314
+ )
1315
+
1316
+
1317
+ def _dashboard_metrics(model_file: Path) -> Optional[Path]:
1318
+ """The metrics file beside the model with its stem: coffee.metrics.yml for coffee.dbml."""
1319
+ stem = _model_stem(model_file)
1320
+ for suffix in _METRICS_SUFFIXES:
1321
+ candidate = model_file.with_name(stem + suffix)
1322
+ if candidate.is_file():
1323
+ return candidate
1324
+ return None
1325
+
1326
+
1327
+ def _dashboard_issues(
1328
+ file: Path, model_option: Optional[Path], metrics_option: Optional[Path]
1329
+ ) -> tuple[list[dashboards.Issue], Optional[Path], Optional[Path]]:
1330
+ """A dashboard's issues, checked against its model and metrics, and the model and
1331
+ metrics files it was checked against (None where there was none)."""
1332
+ try:
1333
+ text = file.read_bytes().decode("utf-8-sig")
1334
+ except UnicodeDecodeError as error:
1335
+ message = f"{file.name} is not UTF-8 (byte {error.start} cannot be decoded)."
1336
+ return [dashboards.Issue(None, None, message)], None, None
1337
+ notes: list[dashboards.Issue] = []
1338
+ model_file = model_option
1339
+ if model_file is None:
1340
+ model_file, why = _dashboard_model(file, text)
1341
+ if why is not None:
1342
+ notes.append(dashboards.Issue(None, None, why, "warning"))
1343
+ name = dashboards.dashboard_name(file)
1344
+ if dashboards.check_name(name) is not None:
1345
+ notes.append(
1346
+ dashboards.Issue(
1347
+ None,
1348
+ None,
1349
+ f"its file name gives the dashboard the name {name!r}. {dashboards.NAME_RULE}",
1350
+ "warning",
1351
+ )
1352
+ )
1353
+ if model_file is None:
1354
+ return [*notes, *dashboards.check_dashboard(text)], None, None
1355
+
1356
+ try:
1357
+ model = load(model_file)
1358
+ except ModelError:
1359
+ problem = (
1360
+ f"its model, {model_file.name}, does not conform: run `model2data validate "
1361
+ f"{model_file.name}` and fix it first"
1362
+ )
1363
+ return [*notes, dashboards.Issue(None, None, problem)], model_file, None
1364
+ metrics_file = metrics_option or _dashboard_metrics(model_file)
1365
+ found: Optional[Metrics] = None
1366
+ if metrics_file is not None:
1367
+ try:
1368
+ found = load_metrics(metrics_file, model, model_name=_model_stem(model_file))
1369
+ except MetricsError:
1370
+ problem = (
1371
+ f"its metrics file, {metrics_file.name}, does not conform: run `model2data "
1372
+ f"validate {metrics_file.name}` and fix it first"
1373
+ )
1374
+ return [*notes, dashboards.Issue(None, None, problem)], model_file, metrics_file
1375
+ known = dashboards.known_names(model, found, model_name=_model_stem(model_file))
1376
+ return [*notes, *dashboards.check_dashboard(text, known)], model_file, metrics_file
1377
+
1378
+
1379
+ def _issue_line(file: Path, issue: dashboards.Issue) -> str:
1380
+ """`file:line:column: error|warning: message`, without the place when there is none."""
1381
+ where = str(file)
1382
+ if issue.line is not None:
1383
+ where += f":{issue.line}"
1384
+ if issue.column is not None:
1385
+ where += f":{issue.column}"
1386
+ return f"{where}: {issue.severity}: {issue.message}"
1387
+
1388
+
1389
+ @dashboard_app.command("check")
1390
+ def dashboard_check_command(
1391
+ files: list[Path] = typer.Argument( # noqa: B008
1392
+ ...,
1393
+ exists=True,
1394
+ file_okay=True,
1395
+ dir_okay=False,
1396
+ readable=True,
1397
+ help="The dashboards: *.dashboard.yml files.",
1398
+ ),
1399
+ model_option: Optional[Path] = typer.Option( # noqa: B008
1400
+ None,
1401
+ "--model",
1402
+ "-m",
1403
+ exists=True,
1404
+ file_okay=True,
1405
+ dir_okay=False,
1406
+ readable=True,
1407
+ help=(
1408
+ "The model whose tables and columns the dashboards name. Default: "
1409
+ "<model>.model2data.yml (or .dbml) beside the file for the `model` it names, "
1410
+ "else the only model beside the file."
1411
+ ),
1412
+ ),
1413
+ metrics_option: Optional[Path] = typer.Option( # noqa: B008
1414
+ None,
1415
+ "--metrics",
1416
+ exists=True,
1417
+ file_okay=True,
1418
+ dir_okay=False,
1419
+ readable=True,
1420
+ help=(
1421
+ "The model's metrics file. Default: <stem>.metrics.yml beside the model, else "
1422
+ "the metrics the model implies."
1423
+ ),
1424
+ ),
1425
+ ):
1426
+ """Check dashboards against dashboard spec 0.1.0 and the names of their model and metrics.
1427
+
1428
+ Prints `file:line:column: error|warning: message` per issue, then a summary line per
1429
+ file. An error is a way the file does not conform; a metric, `table.column` or table the
1430
+ model does not have is a warning. Exits 1 when any file has an error, 0 otherwise.
1431
+ """
1432
+ failed = False
1433
+ for file in files:
1434
+ issues, model_file, metrics_file = _dashboard_issues(
1435
+ file, _given(model_option), _given(metrics_option)
1436
+ )
1437
+ for issue in issues:
1438
+ typer.echo(_issue_line(file, issue))
1439
+ errors = sum(1 for issue in issues if issue.is_error)
1440
+ warnings = len(issues) - errors
1441
+ failed = failed or errors > 0
1442
+ against = [path.name for path in (model_file, metrics_file) if path is not None]
1443
+ note = f", checked against {' and '.join(against)}" if against else ""
1444
+ typer.echo(
1445
+ f"{file}: {errors} error{'' if errors == 1 else 's'}, "
1446
+ f"{warnings} warning{'' if warnings == 1 else 's'}{note}"
1447
+ )
1448
+ if failed:
1449
+ raise typer.Exit(1)
@@ -0,0 +1,94 @@
1
+ """Dashboards as files: dashboard spec 0.1.0, read, checked and written.
2
+
3
+ A dashboard file is `<name>.dashboard.yml`, as `model2data/spec/dashboards/README.md`
4
+ and `dashboard.schema.json` define it: pages of tiles on a 12-column grid, each
5
+ tile naming a metric, a `table.column` or a table of a model2data model, never a
6
+ data source or a value. The engine does not draw a dashboard or compute its
7
+ numbers; it reads, checks and writes the file. model2data studio draws it with
8
+ the numbers of the model's generated data.
9
+
10
+ >>> from model2data import dashboards, metrics
11
+ >>> from model2data.model import load as load_model
12
+ >>> model = load_model("coffee_webshop.model2data.yml")
13
+ >>> found = metrics.load("coffee_webshop.metrics.yml", model)
14
+ >>> known = dashboards.known_names(model, found) # metrics, tables, columns
15
+ >>> for issue in dashboards.check_dashboard("coffee_webshop_sales.dashboard.yml", known):
16
+ ... print(issue.line, issue.column, issue.severity, issue.message)
17
+ >>> board = dashboards.read_dashboard("coffee_webshop_sales.dashboard.yml", known) # DashboardError on errors
18
+ >>> board.pages[0].tiles[0].metric, board.warnings
19
+ >>> text = dashboards.write_dashboard(board) # the canonical file
20
+
21
+ An error is a way the file does not conform (bad YAML, an unknown key, a
22
+ missing or repeated id, a value out of range). A warning is a name `known`
23
+ does not hold, or a tile running past the grid's right edge: the file still
24
+ conforms. Every issue has a 1-based `line` and `column` when it was read from
25
+ text.
26
+ """
27
+
28
+ from model2data.dashboards.check import schema
29
+ from model2data.dashboards.reader import (
30
+ check_dashboard,
31
+ check_name,
32
+ dashboard_name,
33
+ from_dict,
34
+ is_dashboard_file,
35
+ known_names,
36
+ read_dashboard,
37
+ )
38
+ from model2data.dashboards.types import (
39
+ GRAINS,
40
+ GRID_COLUMNS,
41
+ KINDS,
42
+ MAX_BYTES,
43
+ MAX_COLUMNS,
44
+ MAX_NAME,
45
+ MAX_PAGES,
46
+ MAX_TABLE_ROWS,
47
+ MAX_TEXT,
48
+ MAX_TILES,
49
+ NAME_RULE,
50
+ SCHEMA_URL,
51
+ SPEC_VERSION,
52
+ TILE_FIELDS,
53
+ Dashboard,
54
+ DashboardError,
55
+ Issue,
56
+ Known,
57
+ Page,
58
+ Place,
59
+ Tile,
60
+ )
61
+ from model2data.dashboards.writer import write_dashboard
62
+
63
+ __all__ = [
64
+ "GRAINS",
65
+ "GRID_COLUMNS",
66
+ "KINDS",
67
+ "MAX_BYTES",
68
+ "MAX_COLUMNS",
69
+ "MAX_NAME",
70
+ "MAX_PAGES",
71
+ "MAX_TABLE_ROWS",
72
+ "MAX_TEXT",
73
+ "MAX_TILES",
74
+ "NAME_RULE",
75
+ "SCHEMA_URL",
76
+ "SPEC_VERSION",
77
+ "TILE_FIELDS",
78
+ "Dashboard",
79
+ "DashboardError",
80
+ "Issue",
81
+ "Known",
82
+ "Page",
83
+ "Place",
84
+ "Tile",
85
+ "check_dashboard",
86
+ "check_name",
87
+ "dashboard_name",
88
+ "from_dict",
89
+ "is_dashboard_file",
90
+ "known_names",
91
+ "read_dashboard",
92
+ "schema",
93
+ "write_dashboard",
94
+ ]