-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure filtering with manifest loading works with single model (#576)
## Description <!-- Add a brief but complete description of the change. --> This PR fixes an issue with Cosmos' custom filtering methods. Previously, when using the manifest loading method (and thus Cosmos' custom filtering), a user could not filter by path to a specific model (only a directory). This PR fixes that issue and makes some minor refactors to the selecting logic to make it more intuitive and performant. ## Related Issue(s) <!-- If this PR closes an issue, you can use a keyword to auto-close. --> <!-- i.e. "closes #0000" --> ## Breaking Change? <!-- If this introduces a breaking change, specify that here. --> No breaking changes. ## Checklist - [ ] I have made corresponding changes to the documentation (if required) - [x] I have added tests that prove my fix is effective or that my feature works --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Harel Shein <[email protected]>
- Loading branch information
1 parent
6609f76
commit 2e3e4fd
Showing
7 changed files
with
25,838 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
An example DAG that uses Cosmos to render a dbt project. | ||
""" | ||
|
||
import os | ||
from datetime import datetime | ||
from pathlib import Path | ||
|
||
from cosmos import DbtDag, ProjectConfig, ProfileConfig, RenderConfig, LoadMode | ||
from cosmos.profiles import PostgresUserPasswordProfileMapping | ||
|
||
DEFAULT_DBT_ROOT_PATH = Path(__file__).parent / "dbt" | ||
DBT_ROOT_PATH = Path(os.getenv("DBT_ROOT_PATH", DEFAULT_DBT_ROOT_PATH)) | ||
|
||
profile_config = ProfileConfig( | ||
profile_name="default", | ||
target_name="dev", | ||
profile_mapping=PostgresUserPasswordProfileMapping( | ||
conn_id="airflow_db", | ||
profile_args={"schema": "public"}, | ||
), | ||
) | ||
|
||
# [START local_example] | ||
cosmos_manifest_example = DbtDag( | ||
# dbt/cosmos-specific parameters | ||
project_config=ProjectConfig( | ||
DBT_ROOT_PATH / "jaffle_shop", | ||
manifest_path=DBT_ROOT_PATH / "jaffle_shop" / "target" / "manifest.json", | ||
), | ||
profile_config=profile_config, | ||
render_config=RenderConfig(load_method=LoadMode.DBT_MANIFEST, select=["path:models/customers.sql"]), | ||
operator_args={"install_deps": True}, | ||
# normal dag parameters | ||
schedule_interval="@daily", | ||
start_date=datetime(2023, 1, 1), | ||
catchup=False, | ||
dag_id="cosmos_manifest_example", | ||
) | ||
# [END local_example] |
Oops, something went wrong.