dagster-sqlmesh


Namedagster-sqlmesh JSON
Version 0.3.1 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-12-28 08:08:28
maintainerNone
docs_urlNone
authorReuven Gonzales
requires_python<3.13,>=3.11
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dagster-sqlmesh

_WARNING: THIS IS A WORK IN PROGRESS_

SQLMesh library for dagster integration.

## Current features

* A `@sqlmesh_assets` decorator akin to `dagster-dbt`'s `@dbt_assets` decorator.
* A `SQLMeshResource` that allows you to call sqlmesh from inside an asset
  (likely one defined by the `@sqlmesh_assets` decorator)
* A `SQLMeshDagsterTranslator` that 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:

```python
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:

```bash
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:

```bash
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:

```bash
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:

```bash
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_asset` paradigm within dagster such that assets can have independent
  partitions. There is an existing issue for this in [dagster
  itself](https://github.com/dagster-io/dagster/issues/14228).
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dagster-sqlmesh",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "Reuven Gonzales",
    "author_email": "reuven@karibalabs.co",
    "download_url": "https://files.pythonhosted.org/packages/12/dd/6cfb7813c0e73770ec5b53747a8535b0f72c364fc78ab0e76dd2a3179358/dagster_sqlmesh-0.3.1.tar.gz",
    "platform": null,
    "description": "# dagster-sqlmesh\n\n_WARNING: THIS IS A WORK IN PROGRESS_\n\nSQLMesh library for dagster integration.\n\n## Current features\n\n* A `@sqlmesh_assets` decorator akin to `dagster-dbt`'s `@dbt_assets` decorator.\n* A `SQLMeshResource` that allows you to call sqlmesh from inside an asset\n  (likely one defined by the `@sqlmesh_assets` decorator)\n* A `SQLMeshDagsterTranslator` that allows customizing the translation of\n  sqlmesh models into dagster assets.\n\n## Basic Usage\n\nThis dagster sqlmesh adapter is intended to work in a similar pattern to that of\n`dagster-dbt` in the most basic case by using the `@sqlmesh_assets`\n\nAssuming that your sqlmesh project is located in a directory `/home/foo/sqlmesh_project`, this is how you'd setup your dagster assets:\n\n```python\nfrom dagster import (\n    AssetExecutionContext,\n    Definitions,\n)\nfrom dagster_sqlmesh import sqlmesh_assets, SQLMeshContextConfig, SQLMeshResource\n\nsqlmesh_config = SQLMeshContextConfig(path=\"/home/foo/sqlmesh_project\", gateway=\"name-of-your-gateway\")\n\n@sqlmesh_assets(environment=\"dev\", config=sqlmesh_config)\ndef sqlmesh_project(context: AssetExecutionContext, sqlmesh: SQLMeshResource):\n    yield from sqlmesh.run(context)\n\ndefs = Definitions(\n    assets=[sqlmesh_project],\n    resources={\n        \"sqlmesh\": SQLMeshResource(config=sqlmesh_config),\n    },\n)\n```\n\n\n## Contributing\n\n_We are very open to contributions!_\n\nIn order to build the project you'll need the following:\n\n* python 3.11 or 3.12\n* node 18+\n* pnpm 8+\n\n_Note: this is a python project but some of our dependent tools are in typescript. As such all this is needed_\n\n### Installing\n\nTo install everything you need for development just do the following:\n\n```bash\npoetry install\npnpm install\n```\n\n### Running tests\n\nWe 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.\n\nWe run tests with `pytest` like so:\n\n```bash\npoetry run pytest\n```\n\n### Running the \"sample\" dagster project\n\nIn the `sample/dagster_project` directory, is a minimal dagster project with the\naccompanying sqlmesh project from `sample/sqlmesh_project` configured as an\nasset. To run the sample dagster project deployment with a UI:\n\n```bash\npoetry run dagster dev -h 0.0.0.0 -f sample/dagster_project/definitions.py\n```\n\nIf you'd like to materialize the dagster assets quickly on the CLI:\n\n```bash\ndagster asset materialize -f sample/dagster_project/definitions.py --select '*'\n```\n\n_Note: The sqlmesh project that is in the sample folder has a dependency on a\ntable that doesn't exist by default within the defined duckdb database. You'll\nnotice there's a `test_source` asset in the dagster project. This asset will\nautomatically populate that table in duckdb so that the sqlmesh project can be\nrun properly. Before you run any materializations against the sqlmesh related\nassets in dagster, ensure that you've run the `test_source` at least once._\n\n## Future Plans\n\n* Create a new \"loader\" for sqlmesh and dagster definitions to allow for\n  automatic creation of administrative jobs for sqlmesh (e.g. migrations).\n  Additionally, we may want to have this generate assets outside of the\n  `multi_asset` paradigm within dagster such that assets can have independent\n  partitions. There is an existing issue for this in [dagster\n  itself](https://github.com/dagster-io/dagster/issues/14228).",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": null,
    "version": "0.3.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dafdcef3ff6f365e913f6031fec2b995fca9ee76f541e040c000efea5897813a",
                "md5": "c74a244c689db839c5c6df1ab12ae27a",
                "sha256": "0b8fd1346d6a85565c2665226fb14553faa3d1964136c9ea9cc8d5c472004389"
            },
            "downloads": -1,
            "filename": "dagster_sqlmesh-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c74a244c689db839c5c6df1ab12ae27a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.11",
            "size": 25368,
            "upload_time": "2024-12-28T08:08:27",
            "upload_time_iso_8601": "2024-12-28T08:08:27.044978Z",
            "url": "https://files.pythonhosted.org/packages/da/fd/cef3ff6f365e913f6031fec2b995fca9ee76f541e040c000efea5897813a/dagster_sqlmesh-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "12dd6cfb7813c0e73770ec5b53747a8535b0f72c364fc78ab0e76dd2a3179358",
                "md5": "463cc6fe87134811d7159cf9f7c46da4",
                "sha256": "3bfb06d0d9108ec8a7465b64ee55014c160eab3f5854dd9e297daa219fe97c1b"
            },
            "downloads": -1,
            "filename": "dagster_sqlmesh-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "463cc6fe87134811d7159cf9f7c46da4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.11",
            "size": 21352,
            "upload_time": "2024-12-28T08:08:28",
            "upload_time_iso_8601": "2024-12-28T08:08:28.583917Z",
            "url": "https://files.pythonhosted.org/packages/12/dd/6cfb7813c0e73770ec5b53747a8535b0f72c364fc78ab0e76dd2a3179358/dagster_sqlmesh-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-28 08:08:28",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "dagster-sqlmesh"
}
        
Elapsed time: 0.39064s