Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "tags:" prefix from model config selectors #1387

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yoshimaru46
Copy link

@yoshimaru46 yoshimaru46 commented Dec 12, 2024

Description

closes #1367 (comment)

Related Issue(s)

Breaking Change?

Checklist

  • I have made corresponding changes to the documentation (if required)
  • I have added tests that prove my fix is effective or that my feature works

@yoshimaru46 yoshimaru46 force-pushed the yoshimaru46/fix-tag-on-load-mode-custom branch from 807cd58 to 53f1083 Compare December 12, 2024 20:27
@yoshimaru46 yoshimaru46 marked this pull request as ready for review December 12, 2024 20:36
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. area:selector Related to selector, like DAG selector, DBT selector, etc labels Dec 12, 2024
@@ -654,6 +654,8 @@ def load_via_custom_parser(self) -> None:
for model_name, model in models:
config = {item.split(":")[0]: item.split(":")[-1] for item in model.config.config_selectors}
tags = [selector for selector in model.config.config_selectors if selector.startswith("tags:")]
# Remove the "tags:" prefix
tags = [tag.split(":")[-1] for tag in tags]
Copy link
Collaborator

@tatiana tatiana Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not represent tags in different ways depending on the parsing mode. Either we remove the prefix for all LoadModes that set this configuration (not only LoadMode.CUSTOM, but also LoadMode.DBT_MANIFEST), or we remove for none of them.

By changing this here, I'm afraid we may be breaking the behaviour ahead in the selector, for instance:
https://github.com/astronomer/astronomer-cosmos/blob/main/cosmos/dbt/selector.py#L177

The prefix "tag:" is currently being used in the selector module in at least four places via the TAG_SELECTOR constant: https://github.com/astronomer/astronomer-cosmos/blob/110fb0760cb1a21a2a21ca1a06370c44613ba085/cosmos/dbt/selector.py#L20C1-L20C13

Since the select_nodes is being used not only by RenderMode.CUSTOM, but also by RenderMode.DBT_MANIFEST, I believe this change will break the overall behaviour.

I'm surprised no unit tests broke with this change of interface.

Copy link
Collaborator

@tatiana tatiana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yoshimaru46 thanks for identifying the bug and proposing a fix.

I have shared a concern in-line.

I agree the following line will likely fail in your use case:

if not (set(self.config.tags) <= set(node.tags)):

I have two requests:

  1. Could you confirm it also fails if you use LoadMode.DBT_MANIFEST
  2. Would it make sense to make the change in this method itself, to avoid breaking other parts, as mentioned in my other comment?

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.24%. Comparing base (110fb07) to head (53f1083).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1387   +/-   ##
=======================================
  Coverage   96.24%   96.24%           
=======================================
  Files          67       67           
  Lines        4051     4052    +1     
=======================================
+ Hits         3899     3900    +1     
  Misses        152      152           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tatiana tatiana modified the milestones: Cosmos 1.8.0, Cosmos 1.9.0 Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:selector Related to selector, like DAG selector, DBT selector, etc size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't filter dbt nodes by tags when using LoadMode.CUSTOM
2 participants