No project description provided
Project description
dagster-sqlmesh
WARNING: THIS IS A WORK IN PROGRESS
SQLMesh library for dagster integration.
Current features
- A
@sqlmesh_assetsdecorator akin todagster-dbt's@dbt_assetsdecorator. - A
SQLMeshResourcethat allows you to call sqlmesh from inside an asset (likely one defined by the@sqlmesh_assetsdecorator) - A
SQLMeshDagsterTranslatorthat allows customizing the translation of sqlmesh models into dagster assets.
Basic Usage
This dagster sqlmesh adapter is intended to work in a similar pattern to that of
dagster-dbt in the most basic case by using the @sqlmesh_assets
Assuming that your sqlmesh project is located in a directory /home/foo/sqlmesh_project, this is how you'd setup your dagster assets:
from dagster import (
AssetExecutionContext,
Definitions,
)
from dagster_sqlmesh import sqlmesh_assets, SQLMeshContextConfig, SQLMeshResource
sqlmesh_config = SQLMeshContextConfig(path="/home/foo/sqlmesh_project", gateway="name-of-your-gateway")
@sqlmesh_assets(environment="dev", config=sqlmesh_config)
def sqlmesh_project(context: AssetExecutionContext, sqlmesh: SQLMeshResource):
yield from sqlmesh.run(context)
defs = Definitions(
assets=[sqlmesh_project],
resources={
"sqlmesh": SQLMeshResource(config=sqlmesh_config),
},
)
Contributing
We are very open to contributions!
In order to build the project you'll need the following:
- python 3.11 or 3.12
- node 18+
- pnpm 8+
Note: this is a python project but some of our dependent tools are in typescript. As such all this is needed
Installing
To install everything you need for development just do the following:
poetry install
pnpm install
Running tests
We have tests that should work entirely locally. You may see a db.db file appear in the root of the repository when these tests are run. It can be safely ignored or deleted.
We run tests with pytest like so:
poetry run pytest
Running the "sample" dagster project
In the sample/dagster_project directory, is a minimal dagster project with the
accompanying sqlmesh project from sample/sqlmesh_project configured as an
asset. To run the sample dagster project deployment with a UI:
poetry run dagster dev -h 0.0.0.0 -f sample/dagster_project/definitions.py
If you'd like to materialize the dagster assets quickly on the CLI:
dagster asset materialize -f sample/dagster_project/definitions.py --select '*'
Note: The sqlmesh project that is in the sample folder has a dependency on a
table that doesn't exist by default within the defined duckdb database. You'll
notice there's a test_source asset in the dagster project. This asset will
automatically populate that table in duckdb so that the sqlmesh project can be
run properly. Before you run any materializations against the sqlmesh related
assets in dagster, ensure that you've run the test_source at least once.
Future Plans
- Create a new "loader" for sqlmesh and dagster definitions to allow for
automatic creation of administrative jobs for sqlmesh (e.g. migrations).
Additionally, we may want to have this generate assets outside of the
multi_assetparadigm within dagster such that assets can have independent partitions. There is an existing issue for this in dagster itself.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dagster_sqlmesh-0.5.0.tar.gz.
File metadata
- Download URL: dagster_sqlmesh-0.5.0.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.11.5 Darwin/23.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5f0e1ef9dac7ba9bffc47135145225d3b7090495eb7fa3aba08d93fbf0bd76d
|
|
| MD5 |
5587eabe5864492673912d8f081c1717
|
|
| BLAKE2b-256 |
4c98da95e8600173afd6e747f0051d1a0e0f58da59d58b136a83fedb26fd6d94
|
File details
Details for the file dagster_sqlmesh-0.5.0-py3-none-any.whl.
File metadata
- Download URL: dagster_sqlmesh-0.5.0-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.11.5 Darwin/23.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4aa0a2292d78993ce90c77d4045e6f55fe3dfdad86709c0fc4a0aed913ea45cf
|
|
| MD5 |
e561b2557300a8d3fa53d1007646ae2f
|
|
| BLAKE2b-256 |
de17ab2ee3167e4e780086dbe5eee7c2c978cc32e74dc9e4c0385adf9a10d9bd
|