Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gouline/dbt-metabase
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.1
Choose a base ref
...
head repository: gouline/dbt-metabase
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jan 27, 2024

  1. Copy the full SHA
    eab95fd View commit details

Commits on Feb 14, 2024

  1. Copy the full SHA
    df6e280 View commit details

Commits on Feb 16, 2024

  1. Copy the full SHA
    09675ec View commit details

Commits on Feb 19, 2024

  1. Fix exposures depends_on refs with aliased models (#228)

    * Separate model alias from name
    
    * Clean up pylint ignores
    gouline authored Feb 19, 2024
    Copy the full SHA
    5990ef6 View commit details
  2. Column ordering sync (#229)

    * Sync table field order
    
    * Fix test mismatch between dbt and Metabase
    gouline authored Feb 19, 2024
    Copy the full SHA
    d9f50dc View commit details

Commits on Feb 20, 2024

  1. Copy the full SHA
    d8788cc View commit details
  2. Copy the full SHA
    f059bf4 View commit details

Commits on Feb 23, 2024

  1. Copy the full SHA
    d7fa4fc View commit details

Commits on Feb 25, 2024

  1. Copy the full SHA
    9fc8bcd View commit details

Commits on Mar 4, 2024

  1. Fix PR 238 and add tests (#239)

    * Skip missing cards/dashboards in exposures (#238)
    
    * In case of missing resource {dashboard, card, user}, dbt-metabase skips it instead of raising an error.
    
    * Rename get_[card, dashboard] to find_[card, dashboard], and remove duplicate return.
    
    * Fix unit test, change all occurences for get_dashboard
    
    ---------
    
    Co-authored-by: pierre dosne <pierre.dosne@fintecture.com>
    
    * Fix type and format issues
    
    * Add missing card to test
    
    * Formatting and imports
    
    ---------
    
    Co-authored-by: dosnep <dosnep@hotmail.fr>
    Co-authored-by: pierre dosne <pierre.dosne@fintecture.com>
    3 people authored Mar 4, 2024
    Copy the full SHA
    4d40277 View commit details

Commits on Mar 14, 2024

  1. Handle uppercase references from Metabase GUI derived queries (#242)

    * lowercase normal question exposures in from and join
    
    * handle edge case where source_table is None
    
    * change table name to uppercase in fixtures to verify changes
    
    * fix indentation
    alex-float-on authored Mar 14, 2024
    Copy the full SHA
    27821ef View commit details
  2. Copy the full SHA
    f8e803a View commit details

Commits on Mar 15, 2024

  1. Add flag to exposures for excluding all unverified collection items (#…

    …243)
    
    * add flag to exclude unverified collection items
    
    * simplify check for moderation status
    
    * leave dashboards alone
    
    * Add
    
    Co-authored-by: Mike Gouline <1960272+gouline@users.noreply.github.com>
    
    * Revise ordering of exclusion logic
    
    Co-authored-by: Mike Gouline <1960272+gouline@users.noreply.github.com>
    
    * revert flag name now that we have alignment
    
    ---------
    
    Co-authored-by: Mike Gouline <1960272+gouline@users.noreply.github.com>
    alex-float-on and gouline authored Mar 15, 2024
    Copy the full SHA
    7803ae2 View commit details

Commits on Mar 28, 2024

  1. Copy the full SHA
    7a98a24 View commit details

Commits on Apr 2, 2024

  1. Copy the full SHA
    9dad3b9 View commit details

Commits on Apr 18, 2024

  1. Copy the full SHA
    6dd105e View commit details

Commits on Jun 12, 2024

  1. Metabase 50 support (#257)

    * Linux environment fixes
    
    * Pin dependencies for reproducibility
    
    * Metabase 50 compatibility fixes
    
    * Fmt
    gouline authored Jun 12, 2024
    Copy the full SHA
    ac35f7b View commit details

Commits on Jun 13, 2024

  1. Copy the full SHA
    258e7f9 View commit details

Commits on Jun 14, 2024

  1. Copy the full SHA
    a5cea8a View commit details

Commits on Jun 20, 2024

  1. Fix exposure dependencies (#262)

    * Defensive sanitization of exposure models
    
    * Standardize exposure depends to lower case
    gouline authored Jun 20, 2024
    Copy the full SHA
    adf4dca View commit details
  2. API response recorder for test fixtures (#261)

    * API response recorder for test fixtures
    
    * Tracked H2 app database with idempotent setup
    
    * New reference exposures and resulting fixtures and test fixes
    
    * Clean up tests and remove stale fixtures
    gouline authored Jun 20, 2024
    Copy the full SHA
    1e6d0f9 View commit details
  3. Copy the full SHA
    3d18ffa View commit details

Commits on Jul 4, 2024

  1. Copy the full SHA
    0d36ef2 View commit details
  2. Copy the full SHA
    9edebe0 View commit details

Commits on Jul 19, 2024

  1. Skip invisible tables (#268)

    * Skip tables that are technical not just hidden (#267)
    
    Tables are hidden with any non-nil value - we hide our tables with  `technical` so would be useful to update this.
    
    * Allow other table hidden values
    
    ---------
    
    Co-authored-by: Chris Parsons <cp@lollipopai.com>
    gouline and chrismdp authored Jul 19, 2024
    Copy the full SHA
    2fd386a View commit details

Commits on Jul 22, 2024

  1. Testability in IDE and pytest (#269)

    * Fix tests for IDE config
    
    * Migrate to pytest
    gouline authored Jul 22, 2024
    Copy the full SHA
    8647627 View commit details

Commits on Jul 25, 2024

  1. Allow tags on exposures (#271)

    * Allow tags on exposures
    
    * Fix help and tests
    
    * Naming and docs cleanup
    gouline authored Jul 25, 2024
    Copy the full SHA
    cc6e8b1 View commit details

Commits on Aug 13, 2024

  1. Migrate to Ruff (#272)

    gouline authored Aug 13, 2024
    Copy the full SHA
    134ab8c View commit details

Commits on Aug 14, 2024

  1. Copy the full SHA
    cb72905 View commit details

Commits on Aug 31, 2024

  1. Copy the full SHA
    2fa3e11 View commit details
  2. Makefile upgrade

    gouline committed Aug 31, 2024
    Copy the full SHA
    fcb9691 View commit details

Commits on Sep 1, 2024

  1. Copy the full SHA
    38ddc47 View commit details
  2. Copy the full SHA
    227511d View commit details

Commits on Oct 8, 2024

  1. Copy the full SHA
    e9aa680 View commit details

Commits on Oct 12, 2024

  1. Copy the full SHA
    78e8133 View commit details
  2. feat: query average time and last usage metadata (#284)

    * Feat: avg query time + last used at timestamp (#281)
    
    * Query average time and last usage metadata
    
    ---------
    
    Co-authored-by: Simon Rosenberger (Bumm) <41942954+codingcyclist@users.noreply.github.com>
    gouline and codingcyclist authored Oct 12, 2024
    Copy the full SHA
    602192e View commit details
  3. chore: update sandbox images and re-record fixtures (#285)

    * chore: update sandbox images and re-record fixtures
    
    * chore: check for FIXME
    
    * docs: how to record test fixtures
    gouline authored Oct 12, 2024
    Copy the full SHA
    160e2fb View commit details

Commits on Nov 1, 2024

  1. Copy the full SHA
    e900f51 View commit details

Commits on Nov 2, 2024

  1. Demote field ordering failures to warning (#290)

    * demote field ordering failures to warning
    
    * tests for source relationships
    gouline authored Nov 2, 2024
    Copy the full SHA
    3b8804d View commit details

Commits on Nov 27, 2024

  1. Meta description (#292)

    * feat: allow column description to be overwritten (#291)
    
    * feat: allow column description to be overwritten
    
    * feat: Consider Model description as well
    
    * chore: Update tests
    
    * chore: Column test
    
    * fix: fmt
    
    * fix: test v2 manifest instead of v12
    
    * Apply suggestions from code review
    
    ---------
    
    Co-authored-by: Mike Gouline <1960272+gouline@users.noreply.github.com>
    
    * fix type issue
    
    ---------
    
    Co-authored-by: Felipe Guilherme Sabino <982190+sabino@users.noreply.github.com>
    gouline and sabino authored Nov 27, 2024
    Copy the full SHA
    59cb87d View commit details

Commits on Dec 1, 2024

  1. Copy the full SHA
    8bf4215 View commit details
  2. Copy the full SHA
    c2ba2fb View commit details

Commits on Dec 16, 2024

  1. Exposure dependency resolution by fully-qualified names (#287)

    * Exposure dependency resolution by fully-qualified names
    
    * Reference databases by dbname
    
    * remove redundant calls to extract_card_exposures with empty cards
    
    * extract dbname from details
    
    * update dependencies
    
    * support project-id as exposure database
    gouline authored Dec 16, 2024
    Copy the full SHA
    781af8c View commit details

Commits on Dec 17, 2024

  1. Copy the full SHA
    d6a4247 View commit details

Commits on Dec 20, 2024

  1. Copy the full SHA
    88452f1 View commit details
  2. Copy the full SHA
    c490dcd View commit details
  3. Copy the full SHA
    a9eec40 View commit details
  4. Copy the full SHA
    c579c0c View commit details

Commits on Dec 21, 2024

  1. Create FUNDING.yml

    gouline authored Dec 21, 2024
    Copy the full SHA
    ea0693d View commit details

Commits on Dec 22, 2024

  1. Copy the full SHA
    c37cf49 View commit details
Showing with 15,571 additions and 19,909 deletions.
  1. +15 −0 .github/FUNDING.yml
  2. +10 −7 .github/workflows/codeql-analysis.yml
  3. +14 −10 .github/workflows/master.yml
  4. +14 −19 .github/workflows/pull_request.yml
  5. +81 −0 CONTRIBUTING.md
  6. +0 −4 MANIFEST.in
  7. +48 −54 Makefile
  8. +28 −24 README.md
  9. +1 −1 dbtmetabase/__init__.py
  10. +45 −6 dbtmetabase/__main__.py
  11. +246 −131 dbtmetabase/_exposures.py
  12. +147 −37 dbtmetabase/_models.py
  13. +6 −3 dbtmetabase/core.py
  14. +16 −6 dbtmetabase/format.py
  15. +126 −49 dbtmetabase/manifest.py
  16. +57 −19 dbtmetabase/metabase.py
  17. +67 −11 pyproject.toml
  18. +0 −11 requirements-test.txt
  19. +0 −4 requirements.txt
  20. +1 −0 sandbox/.gitignore
  21. +9 −4 sandbox/Dockerfile
  22. +7 −4 sandbox/docker-compose.yml
  23. +83 −137 sandbox/entrypoint.py
  24. BIN sandbox/metabase.db/metabase.db.mv.db
  25. +3 −0 sandbox/models/payments.sql
  26. +41 −12 sandbox/models/schema.yml
  27. +26 −7 sandbox/models/staging/schema.yml
  28. +2 −1 sandbox/models/staging/stg_orders.sql
  29. +4 −0 sandbox/postgres-initdb/init.sql
  30. +0 −47 setup.py
  31. +5 −6 tests/__init__.py
  32. +81 −18 tests/_mocks.py
  33. +20 −0 tests/conftest.py
  34. +0 −2,497 tests/fixtures/api/card.json
  35. +0 −175 tests/fixtures/api/card/1.json
  36. +0 −186 tests/fixtures/api/card/10.json
  37. +0 −186 tests/fixtures/api/card/11.json
  38. +0 −145 tests/fixtures/api/card/12.json
  39. +0 −145 tests/fixtures/api/card/13.json
  40. +0 −145 tests/fixtures/api/card/14.json
  41. +0 −145 tests/fixtures/api/card/15.json
  42. +0 −145 tests/fixtures/api/card/16.json
  43. +0 −145 tests/fixtures/api/card/17.json
  44. +0 −90 tests/fixtures/api/card/2.json
  45. +651 −0 tests/fixtures/api/card/27.json
  46. +625 −0 tests/fixtures/api/card/28.json
  47. +104 −0 tests/fixtures/api/card/29.json
  48. +0 −90 tests/fixtures/api/card/3.json
  49. +106 −0 tests/fixtures/api/card/30.json
  50. +106 −0 tests/fixtures/api/card/31.json
  51. +342 −0 tests/fixtures/api/card/32.json
  52. +218 −0 tests/fixtures/api/card/33.json
  53. +0 −111 tests/fixtures/api/card/4.json
  54. +0 −111 tests/fixtures/api/card/5.json
  55. +0 −155 tests/fixtures/api/card/6.json
  56. +0 −155 tests/fixtures/api/card/7.json
  57. +0 −186 tests/fixtures/api/card/8.json
  58. +0 −186 tests/fixtures/api/card/9.json
  59. +22 −25 tests/fixtures/api/collection.json
  60. +0 −23 tests/fixtures/api/collection/1.json
  61. +0 −23 tests/fixtures/api/collection/2.json
  62. +0 −9 tests/fixtures/api/collection/2/items.json
  63. +0 −28 tests/fixtures/api/collection/3.json
  64. +14 −246 tests/fixtures/api/collection/3/items.json
  65. +133 −22 tests/fixtures/api/collection/root/items.json
  66. +0 −54 tests/fixtures/api/dashboard.json
  67. +0 −2,533 tests/fixtures/api/dashboard/1.json
  68. +1,393 −0 tests/fixtures/api/dashboard/2.json
  69. +58 −17 tests/fixtures/api/database.json
  70. +0 −64 tests/fixtures/api/database/2.json
  71. +1,224 −400 tests/fixtures/api/database/2/metadata.json
  72. +0 −111 tests/fixtures/api/field/37.json
  73. +0 −112 tests/fixtures/api/field/38.json
  74. +0 −108 tests/fixtures/api/field/39.json
  75. +0 −112 tests/fixtures/api/field/40.json
  76. +0 −112 tests/fixtures/api/field/41.json
  77. +0 −108 tests/fixtures/api/field/42.json
  78. +0 −111 tests/fixtures/api/field/43.json
  79. +0 −112 tests/fixtures/api/field/44.json
  80. +0 −112 tests/fixtures/api/field/45.json
  81. +0 −108 tests/fixtures/api/field/46.json
  82. +0 −112 tests/fixtures/api/field/47.json
  83. +0 −112 tests/fixtures/api/field/48.json
  84. +0 −112 tests/fixtures/api/field/49.json
  85. +0 −111 tests/fixtures/api/field/50.json
  86. +0 −112 tests/fixtures/api/field/51.json
  87. +0 −112 tests/fixtures/api/field/52.json
  88. +0 −111 tests/fixtures/api/field/53.json
  89. +0 −111 tests/fixtures/api/field/54.json
  90. +0 −104 tests/fixtures/api/field/55.json
  91. +0 −108 tests/fixtures/api/field/56.json
  92. +0 −97 tests/fixtures/api/field/57.json
  93. +0 −111 tests/fixtures/api/field/58.json
  94. +0 −112 tests/fixtures/api/field/59.json
  95. +0 −112 tests/fixtures/api/field/60.json
  96. +0 −111 tests/fixtures/api/field/61.json
  97. +0 −97 tests/fixtures/api/field/62.json
  98. +0 −112 tests/fixtures/api/field/63.json
  99. +0 −111 tests/fixtures/api/field/64.json
  100. +0 −112 tests/fixtures/api/field/65.json
  101. +0 −111 tests/fixtures/api/field/66.json
  102. +0 −108 tests/fixtures/api/field/67.json
  103. +0 −112 tests/fixtures/api/field/68.json
  104. +0 −111 tests/fixtures/api/field/69.json
  105. +0 −112 tests/fixtures/api/field/70.json
  106. +0 −112 tests/fixtures/api/field/71.json
  107. +0 −111 tests/fixtures/api/field/72.json
  108. +0 −112 tests/fixtures/api/field/73.json
  109. +0 −112 tests/fixtures/api/field/74.json
  110. +0 −1 tests/fixtures/api/metric.json
  111. +749 −177 tests/fixtures/api/table.json
  112. +0 −67 tests/fixtures/api/table/10.json
  113. +0 −67 tests/fixtures/api/table/11.json
  114. +0 −67 tests/fixtures/api/table/12.json
  115. +0 −67 tests/fixtures/api/table/5.json
  116. +0 −67 tests/fixtures/api/table/6.json
  117. +0 −67 tests/fixtures/api/table/7.json
  118. +0 −67 tests/fixtures/api/table/8.json
  119. +0 −67 tests/fixtures/api/table/9.json
  120. +0 −24 tests/fixtures/api/user.json
  121. +15 −12 tests/fixtures/api/user/1.json
  122. +0 −370 tests/fixtures/exposure/collection/a_look_at_your_customers_table.yml
  123. +153 −16 tests/fixtures/exposure/collection/our_analytics.yml
  124. +28 −0 tests/fixtures/exposure/collection/коллекция.yml
  125. +182 −371 tests/fixtures/exposure/default/exposures.yml
  126. +0 −26 tests/fixtures/exposure/type/card/1.yml
  127. +0 −25 tests/fixtures/exposure/type/card/10.yml
  128. +0 −25 tests/fixtures/exposure/type/card/11.yml
  129. +0 −25 tests/fixtures/exposure/type/card/12.yml
  130. +0 −25 tests/fixtures/exposure/type/card/13.yml
  131. +0 −25 tests/fixtures/exposure/type/card/14.yml
  132. +0 −25 tests/fixtures/exposure/type/card/15.yml
  133. +0 −25 tests/fixtures/exposure/type/card/16.yml
  134. +0 −25 tests/fixtures/exposure/type/card/17.yml
  135. +0 −25 tests/fixtures/exposure/type/card/2.yml
  136. +29 −0 tests/fixtures/exposure/type/card/27.yml
  137. +29 −0 tests/fixtures/exposure/type/card/28.yml
  138. +20 −0 tests/fixtures/exposure/type/card/29.yml
  139. +0 −25 tests/fixtures/exposure/type/card/3.yml
  140. +37 −0 tests/fixtures/exposure/type/card/30.yml
  141. +37 −0 tests/fixtures/exposure/type/card/31.yml
  142. +18 −0 tests/fixtures/exposure/type/card/32.yml
  143. +28 −0 tests/fixtures/exposure/type/card/33.yml
  144. +0 −25 tests/fixtures/exposure/type/card/4.yml
  145. +0 −25 tests/fixtures/exposure/type/card/5.yml
  146. +0 −25 tests/fixtures/exposure/type/card/6.yml
  147. +0 −25 tests/fixtures/exposure/type/card/7.yml
  148. +0 −25 tests/fixtures/exposure/type/card/8.yml
  149. +0 −25 tests/fixtures/exposure/type/card/9.yml
  150. +0 −25 tests/fixtures/exposure/type/dashboard/1.yml
  151. +28 −0 tests/fixtures/exposure/type/dashboard/2.yml
  152. +5,572 −4,124 tests/fixtures/{manifest-v11.json → manifest-v12.json}
  153. +6 −2 tests/fixtures/manifest-v2.json
  154. +7 −0 tests/fixtures/test_dump_yaml.yml
  155. +120 −69 tests/test_exposures.py
  156. +65 −75 tests/test_format.py
  157. +417 −324 tests/test_manifest.py
  158. +27 −33 tests/test_metabase.py
  159. +88 −63 tests/test_models.py
  160. +1,717 −0 uv.lock
15 changes: 15 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# These are supported funding model platforms

github: gouline # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
thanks_dev: # Replace with a single thanks.dev username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
17 changes: 10 additions & 7 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -38,11 +38,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -55,7 +55,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
# - name: Autobuild
# uses: github/codeql-action/autobuild@v2
# uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -69,13 +69,16 @@ jobs:

- uses: actions/setup-python@v2
with:
python-version: "3.8.x"
python-version: "3.9.x"

- name: Requirements
run: make requirements
- name: Install uv
run: pipx install uv

- name: Dependencies
run: make dependencies

- name: Build
run: make build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
24 changes: 14 additions & 10 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -6,27 +6,31 @@ on:
- master
release:
types:
- created
- released

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8.18"
python-version: "3.9"

- name: Requirements
run: make requirements
- name: Install uv
run: pipx install uv

- name: Dependencies
run: make dependencies

- name: Build
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.release.tag_name }}
run: make build

- name: Publish a Python distribution to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
33 changes: 14 additions & 19 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -7,35 +7,30 @@ on:

jobs:
validate:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8.18"
python-version: "3.9"

- uses: actions/cache@v2
- name: Install uv
run: pipx install uv

- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}

- name: Requirements
run: make requirements
- name: Dependencies
run: make dependencies

- name: Build
run: make build

- name: Formatting check (black)
run: make check-fmt

- name: Imports ordering check (isort)
run: make check-imports

- name: Lint Python check (pylint)
run: make check-lint-python
- name: Lint check (ruff)
run: make check-lint

- name: Type check (mypy)
run: make check-type
81 changes: 81 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Contributing Guidelines

This project would not be here without its community, so contributions have and will always be welcome!

## Issues

When reporting a bug, please create an [issue](https://github.com/gouline/issues) and provide as much content as humanly possible:

* Package version (`dbt-metabase --version` or `pip show dbt-metabase`)
* Environment details, e.g. operating system, cloud provider, database
* Steps to reproduce
* Expected vs actual results
* Sample code, logs, screenshots

## Pull Requests

Code contributions must be reviewed by the maintainer in a [pull request](https://github.com/gouline/pulls). This project only has one maintainer, so please be patient if the review process takes days or weeks.

Unless your change is a bug fix or an incremental addition, consider proposing your approach in an issue first. While your contributions are appreciated, not everything is suitable for this project, and seeking feedback in advance avoids wasting your time implementing something that gets rejected.

### Validation

While checks and tests are run automatically on pull requests, GitHub Actions requires maintainers to manually approve new contributors for security reasons. This means you could spend days waiting for a code review only to be immediately rejected because validation failed. To avoid this, please **run checks locally before you commit**!

To execute only checks (you can also run each check separately, e.g. `check-fmt`):

```
make check
```

To execute only tests:

```
make test
```

The most convenient way to fix formatting and imports, and run checks and tests, with one command:

```
make pre
```

### Tests

Any code you contribute **must have unit tests**. Bug fixes in particular require at least one test case that fails before your fix and succeeds afterwards. This helps communicate how your contribution works and ensures no future changes inadvertently break it.

### Sandbox

While developing, it can be useful to have a sandbox with Metabase, dbt and PostgreSQL running locally to test your changes. To start it in [Docker Compose](https://docs.docker.com/compose/), execute the following (see [.env](./sandbox/.env) for ports and credentials):

```
make sandbox-up
```

To execute dbt-metabase commands against it:

```
make sandbox-models
make sandbox-exposures
```

Once you are finished, stop the sandbox:

```
make sandbox-down
```

#### Recording

Whenever tests require updating Metabase API fixtures, you need to "record" them from the running sandbox instance by executing:

```
RECORD=true make test
```

This will run tests against the actual Metabase instance, instead of fixtures, and write those responses to new fixtures. **Many tests will likely fail**, because of timestamps and other transient data, so you need to manually fix those assertions.

## Code of Conduct

All contributors are expected to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).

4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

102 changes: 48 additions & 54 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,108 +1,102 @@
build: clean
python3 -m build
.PHONY: build
export SETUPTOOLS_SCM_PRETEND_VERSION ?= 0.0.0

clean:
rm -rf build dist
.PHONY: clean
.PHONY: dependencies
dependencies:
uv sync --no-install-project --all-extras --frozen

requirements:
python3 -m pip install \
-r requirements.txt \
-r requirements-test.txt
.PHONY: requirements
.PHONY: upgrade
upgrade:
uv sync --no-install-project --all-extras --upgrade

fix-fmt:
black .
.PHONY: fix-fmt
.PHONY: build
build: clean
uv run python3 -m build

fix-imports:
isort .
.PHONY: fix-imports
.PHONY: clean
clean:
rm -rf build dist

fix: fix-fmt fix-imports
.PHONY: fix
fix:
uv run ruff format .
uv run ruff check --fix .

check-fmt:
black --check .
.PHONY: check-fmt

check-imports:
isort --check .
.PHONY: check-imports
.PHONY: check-lint
check-lint:
uv run ruff format --check .
uv run ruff check .

check-lint-python:
pylint dbtmetabase
.PHONY: check-lint-python

check-type:
mypy dbtmetabase
.PHONY: check-type
check-type:
uv run mypy dbtmetabase

check: check-fmt check-imports check-lint-python check-type
.PHONY: check
check: check-lint check-type

test:
python3 -m unittest tests
.PHONY: test
test:
rm -rf tests/tmp
uv run pytest tests

pre: fix check test
.PHONY: pre
pre: fix check test

dist-check: build
twine check dist/*
.PHONY: dist-check
dist-check: build
uv run twine check dist/*

dist-upload: check
twine upload dist/*
.PHONY: dist-upload
dist-upload: check
uv run twine upload dist/*

install: build
python3 -m pip uninstall -y dbt-metabase \
&& python3 -m pip install dist/dbt_metabase-*-py3-none-any.whl
.PHONY: install
install: build
uv pip uninstall dbt-metabase \
&& uv pip install dist/dbt_metabase-*-py3-none-any.whl

sandbox-up:
( cd sandbox && docker-compose up --build --attach app )
.PHONY: sandbox-up
sandbox-up:
( cd sandbox && docker compose up --build --attach app )

sandbox-down:
( cd sandbox && docker-compose down )
.PHONY: sandbox-up
sandbox-down:
( cd sandbox && docker compose down )

.PHONY: sandbox-models
sandbox-models:
( source sandbox/.env && python3 -m dbtmetabase models \
( . sandbox/.env && uv run python3 -m dbtmetabase models \
--manifest-path sandbox/target/manifest.json \
--metabase-url http://localhost:$$MB_PORT \
--metabase-username $$MB_USER \
--metabase-password $$MB_PASSWORD \
--metabase-database $$POSTGRES_DB \
--include-schemas "public",other \
--include-schemas "pub*",inventory \
--http-header x-dummy-key dummy-value \
--order-fields \
--verbose )
.PHONY: sandbox-models

.PHONY: sandbox-exposures
sandbox-exposures:
rm -rf sandbox/models/exposures
mkdir -p sandbox/models/exposures
( source sandbox/.env && python3 -m dbtmetabase exposures \
( . sandbox/.env && uv run python3 -m dbtmetabase exposures \
--manifest-path sandbox/target/manifest.json \
--metabase-url http://localhost:$$MB_PORT \
--metabase-username $$MB_USER \
--metabase-password $$MB_PASSWORD \
--output-path sandbox/models/exposures \
--output-grouping collection \
--tag metabase \
--verbose )

( source sandbox/.env && cd sandbox && \
( . sandbox/.env && cd sandbox && \
POSTGRES_HOST=localhost \
POSTGRES_PORT=$$POSTGRES_PORT \
POSTGRES_USER=$$POSTGRES_USER \
POSTGRES_PASSWORD=$$POSTGRES_PASSWORD \
POSTGRES_DB=$$POSTGRES_DB \
POSTGRES_SCHEMA=$$POSTGRES_SCHEMA \
dbt docs generate )
.PHONY: sandbox-exposures
uv run dbt docs generate )

sandbox-e2e: sandbox-up sandbox-models sandbox-exposures sandbox-down
.PHONY: sandbox-e2e
sandbox-e2e: sandbox-up sandbox-models sandbox-exposures sandbox-down
Loading