Fix path selector when manifest.json was created in MS Windows#1601
Merged
Conversation
…d to use Cosmos path selectors after,
such as `path:models/edr/run_results' were unable to do so, because the paths in Windows were different from the selector:
```
"model.elementary.model_run_results": {
"database": "FDH_DEV_DB",
"schema": "MONITORING",
"name": "model_run_results",
"resource_type": "model",
"package_name": "elementary",
"path": "edr\\run_results\\model_run_results.sql",
"original_file_path": "models\\edr\\run_results\\model_run_results.sql",
"unique_id": "model.elementary.model_run_results",
"fqn": [
"elementary",
"edr",
"run_results",
"model_run_results"
],
```
As it can be observedf in this example, the property `original_file_path` used the `\\` character as a divider in the path,
but the selector checked using the Posix notation.
Since Cosmos implements path selectors using: path_selection in str(node.file_path), we have to normalize the input for the
filter to work.
This issue only happened when using `LoadMode.DBT_MANIFEST` and not `LoadMode.DBT_LS`, since dbt normalizes this internally
when handling selectors as part of this command line.
Deploying astronomer-cosmos with
|
| Latest commit: |
8cb710f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c8b29a6b.astronomer-cosmos.pages.dev |
| Branch Preview URL: | https://normalize-manifest-path.astronomer-cosmos.pages.dev |
✅ Deploy Preview for sunny-pastelito-5ecb04 canceled.
|
✅ Deploy Preview for sunny-pastelito-5ecb04 canceled.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1601 +/- ##
=======================================
Coverage 97.46% 97.46%
=======================================
Files 80 80
Lines 4937 4939 +2
=======================================
+ Hits 4812 4814 +2
Misses 125 125 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pankajkoti
approved these changes
Mar 13, 2025
Contributor
pankajkoti
left a comment
There was a problem hiding this comment.
LGTM, thanks for normalising the path here for the selectors to work well on Windows generated manifests 🙌🏽
pankajkoti
pushed a commit
that referenced
this pull request
Mar 13, 2025
Users who generated the `manifest.json` using MS Windows and attempted
to use Cosmos path selectors after, such as
`path:models/edr/run_results' were unable to do so, because the paths in
Windows were different from the selector:
```
"model.elementary.model_run_results": {
"database": "FDH_DEV_DB",
"schema": "MONITORING",
"name": "model_run_results",
"resource_type": "model",
"package_name": "elementary",
"path": "edr\\run_results\\model_run_results.sql",
"original_file_path": "models\\edr\\run_results\\model_run_results.sql",
"unique_id": "model.elementary.model_run_results",
"fqn": [
"elementary",
"edr",
"run_results",
"model_run_results"
],
```
As observed in this example, the property `original_file_path` used the
`\\` character as a divider in the path, but the selector checked using
the Posix notation.
Since Cosmos implements path selectors using: path_selection in
str(node.file_path), we have to normalize the input for the filter to
work.
This issue only happened when using `LoadMode.DBT_MANIFEST` and not
`LoadMode.DBT_LS` since dbt normalizes this internally when handling
selectors as part of this command line.
(cherry picked from commit 9a1c8fe)
Closed
tatiana
added a commit
that referenced
this pull request
Mar 17, 2025
Bug Fixes * Fix import error in dbt bigquery adapter mock for ``dbt-bigquery<1.8`` for ``ExecutionMode.AIRFLOW_ASYNC`` by @pankajkoti in #1548 * Fix ``operator_args`` override configuration by @ghjklw in #1558 * Fix missing ``install_dbt_deps`` in ``ProjectConfig`` ``__init__`` method by @ghjklw in #1556 * Fix dbt project parsing ``dbt_vars`` behavior passed via ``operator_args`` by @AlexandrKhabarov in #1543 * Avoid reading the connection during DAG parsing of the async BigQuery operator by @joppevos in #1582 * Fix: Workaround to incorrectly raised ``gcsfs.retry.HttpError`` (Invalid Credentials, 401) by @tatiana in #1598 * Fix the async execution mode read sql files for dbt packages by @pankajastro in #1588 * Improve BQ async error handling by @tatiana in #1597 * Fix path selector when ``manifest.json`` is created using MS Windows by @tatiana in #1601 * Fix log that prints 'Total filtered nodes' by @tatiana in #1603 * Fix select behaviour using ``LoadMode.MANIFEST`` and a path with star by @tatiana in #1602 * Support ``on_warning_callback`` with ``TestBehavior.BUILD`` and ``ExecutionMode.LOCAL`` by @corsettigyg in #1571 * Fix ``DbtRunLocalOperator.partial()`` support by @tatiana @ashb in #1609 * fix: ``container_name`` is null for ecs integration by @nicor88 in #1592 Docs * Improve MWAA getting-started docs by removing unused imports by @jx2lee in #1562 Others * Disable ``example_cosmos_dbt_build.py`` DAG in CI by @pankajastro in #1567 * Upgrade GitHub Actions Ubuntu version by @tatiana in #1561 * Update GitHub bug issue template by @pankajastro in #1586 * Enable DAG ``example_cosmos_dbt_build.py`` in CI by @pankajastro in #1573 * Run async DAG in DAG without setup/teardown task by @pankajastro in #1599 * Add test case that fully covers recent select issue by @tatiana in #1604 * Add CI job to test multiple dbt versions for the async DAG by @pankajkoti in #1535 * Improve unit tests speed from 89s to 14s by @tatiana in #1600 * Pre-commit updates: #1560, #1583, #1596 Closes: #1550 Mergeable version of #1607 Co-authored-by: Pankaj Singh <98807258+pankajastro@users.noreply.github.com> Co-authored-by: Pankaj Koti <pankajkoti699@gmail.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Users who generated the
manifest.jsonusing MS Windows and attempted to use Cosmos path selectors after, such as `path:models/edr/run_results' were unable to do so, because the paths in Windows were different from the selector:As observed in this example, the property
original_file_pathused the\\character as a divider in the path, but the selector checked using the Posix notation.Since Cosmos implements path selectors using: path_selection in str(node.file_path), we have to normalize the input for the filter to work.
This issue only happened when using
LoadMode.DBT_MANIFESTand notLoadMode.DBT_LSsince dbt normalizes this internally when handling selectors as part of this command line.