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: v0.1.3
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
Loading
Showing with 35,156 additions and 586 deletions.
  1. +15 −0 .github/FUNDING.yml
  2. +84 −0 .github/workflows/codeql-analysis.yml
  3. +36 −0 .github/workflows/master.yml
  4. +39 −0 .github/workflows/pull_request.yml
  5. +6 −5 .gitignore
  6. +81 −0 CONTRIBUTING.md
  7. +0 −4 MANIFEST.in
  8. +95 −11 Makefile
  9. +310 −0 README.md
  10. +0 −7 README.rst
  11. +0 −9 dbt_project.yml
  12. +12 −61 dbtmetabase/__init__.py
  13. +413 −0 dbtmetabase/__main__.py
  14. +473 −0 dbtmetabase/_exposures.py
  15. +506 −0 dbtmetabase/_models.py
  16. +0 −6 dbtmetabase/bin/dbt-metabase
  17. +74 −0 dbtmetabase/core.py
  18. +0 −99 dbtmetabase/dbt.py
  19. +6 −0 dbtmetabase/errors.py
  20. +155 −0 dbtmetabase/format.py
  21. +471 −0 dbtmetabase/manifest.py
  22. +211 −283 dbtmetabase/metabase.py
  23. +0 −49 macros/tests.sql
  24. +79 −0 pyproject.toml
  25. +0 −2 requirements.txt
  26. +9 −0 sandbox/.env
  27. +1 −0 sandbox/.gitignore
  28. +17 −0 sandbox/Dockerfile
  29. +7 −0 sandbox/README.md
  30. +19 −0 sandbox/dbt_project.yml
  31. +75 −0 sandbox/docker-compose.yml
  32. +157 −0 sandbox/entrypoint.py
  33. BIN sandbox/metabase.db/metabase.db.mv.db
  34. +1 −0 sandbox/models/.gitignore
  35. +66 −0 sandbox/models/customers.sql
  36. +54 −0 sandbox/models/orders.sql
  37. +3 −0 sandbox/models/payments.sql
  38. +118 −0 sandbox/models/schema.yml
  39. +50 −0 sandbox/models/staging/schema.yml
  40. +22 −0 sandbox/models/staging/stg_customers.sql
  41. +24 −0 sandbox/models/staging/stg_orders.sql
  42. +25 −0 sandbox/models/staging/stg_payments.sql
  43. +4 −0 sandbox/postgres-initdb/init.sql
  44. +11 −0 sandbox/profiles.yml
  45. +101 −0 sandbox/seeds/raw_customers.csv
  46. +100 −0 sandbox/seeds/raw_orders.csv
  47. +114 −0 sandbox/seeds/raw_payments.csv
  48. +0 −50 setup.py
  49. 0 test-requirements.txt
  50. +10 −0 tests/__init__.py
  51. +113 −0 tests/_mocks.py
  52. +20 −0 tests/conftest.py
  53. +651 −0 tests/fixtures/api/card/27.json
  54. +625 −0 tests/fixtures/api/card/28.json
  55. +104 −0 tests/fixtures/api/card/29.json
  56. +106 −0 tests/fixtures/api/card/30.json
  57. +106 −0 tests/fixtures/api/card/31.json
  58. +342 −0 tests/fixtures/api/card/32.json
  59. +218 −0 tests/fixtures/api/card/33.json
  60. +46 −0 tests/fixtures/api/collection.json
  61. +25 −0 tests/fixtures/api/collection/3/items.json
  62. +159 −0 tests/fixtures/api/collection/root/items.json
  63. +1,393 −0 tests/fixtures/api/dashboard/2.json
  64. +92 −0 tests/fixtures/api/database.json
  65. +2,684 −0 tests/fixtures/api/database/2/metadata.json
  66. +1,102 −0 tests/fixtures/api/table.json
  67. +24 −0 tests/fixtures/api/user/1.json
  68. +186 −0 tests/fixtures/exposure/collection/our_analytics.yml
  69. +28 −0 tests/fixtures/exposure/collection/коллекция.yml
  70. +228 −0 tests/fixtures/exposure/default/exposures.yml
  71. +29 −0 tests/fixtures/exposure/type/card/27.yml
  72. +29 −0 tests/fixtures/exposure/type/card/28.yml
  73. +20 −0 tests/fixtures/exposure/type/card/29.yml
  74. +37 −0 tests/fixtures/exposure/type/card/30.yml
  75. +37 −0 tests/fixtures/exposure/type/card/31.yml
  76. +18 −0 tests/fixtures/exposure/type/card/32.yml
  77. +28 −0 tests/fixtures/exposure/type/card/33.yml
  78. +28 −0 tests/fixtures/exposure/type/dashboard/2.yml
  79. +1 −0 tests/fixtures/manifest-v11-disabled.json
  80. +14,064 −0 tests/fixtures/manifest-v12.json
  81. +6,085 −0 tests/fixtures/manifest-v2.json
  82. +7 −0 tests/fixtures/test_dump_yaml.yml
  83. +125 −0 tests/test_exposures.py
  84. +73 −0 tests/test_format.py
  85. +428 −0 tests/test_manifest.py
  86. +36 −0 tests/test_metabase.py
  87. +88 −0 tests/test_models.py
  88. +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']
84 changes: 84 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "master" ]
# pull_request:
# # The branches below must be a subset of the branches above
# branches: [ "master" ]
schedule:
- cron: '38 20 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
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.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# 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@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

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

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

- 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@v3
36 changes: 36 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: master

on:
push:
branches:
- master
release:
types:
- released

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

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

- 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
39 changes: 39 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: pull_request

on:
pull_request:
branches:
- master

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

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

- name: Install uv
run: pipx install uv

- uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}

- name: Dependencies
run: make dependencies

- name: Build
run: make build

- name: Lint check (ruff)
run: make check-lint

- name: Type check (mypy)
run: make check-type

- name: Test
run: make test
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -26,6 +26,8 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
*/_version.py
tmp/

# PyInstaller
# Usually these files are written by a python script from a template
@@ -71,9 +73,6 @@ instance/
# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

@@ -102,7 +101,7 @@ celerybeat.pid
*.sage.py

# Environments
.env
/.env
.venv
env/
venv/
@@ -130,8 +129,10 @@ dmypy.json

# IDE
.vscode/
.idea/

# dbt
target/
dbt_modules/
logs/
target/
.user.yml
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.

Loading