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

LoadMode.CUSTOM cannot select tags #693

Closed
Tracked by #1103
adammarples opened this issue Nov 20, 2023 · 6 comments · Fixed by #1100
Closed
Tracked by #1103

LoadMode.CUSTOM cannot select tags #693

adammarples opened this issue Nov 20, 2023 · 6 comments · Fixed by #1100
Assignees
Labels
area:config Related to configuration, like YAML files, environment variables, or executer configuration area:parsing Related to parsing DAG/DBT improvement, issues, or fixes bug Something isn't working dbt:parse Primarily related to dbt parse command or functionality epic-assigned good first issue Good for newcomers parsing:custom Related to custom parsing, like custom DAG parsing, custom DBT parsing, etc triage-needed Items need to be reviewed / assigned to milestone
Milestone

Comments

@adammarples
Copy link
Contributor

https://github.com/astronomer/astronomer-cosmos/blob/d28d3df7eacac74d0fbb016be70434bcc30c51be/cosmos/dbt/graph.py#L314C17-L314C25

load_via_custom_parser hard codes DbtNode.tags attribute to be an empty list

        for model_name, model in models:
           config = {item.split(":")[0]: item.split(":")[-1] for item in model.config.config_selectors}
           node = DbtNode(
               unique_id=f"{model.type.value}.{self.project.project_name}.{model_name}",
               resource_type=DbtResourceType(model.type.value),
               depends_on=list(model.config.upstream_models),
               file_path=Path(
                   model.path.as_posix().replace(
                       self.render_config.project_path.as_posix(), self.execution_config.project_path.as_posix()
                   )
               ),
               tags=[],
               config=config,
           )

This causes _is_tags_subset to return False every time

    def _is_tags_subset(self, node: DbtNode) -> bool:
      """Checks if the node's tags are a subset of the config's tags."""
      if not (set(self.config.tags) <= set(node.tags)):
          return False
      return True

because set(node.tags) is always empty.

Copy link

dosubot bot commented Nov 20, 2023

🤖

Hi @adammarples,

Great to see you again! Thanks for bringing this to our attention. I'm diving into the issue you've raised and will get back to you with a detailed response soon.

@dosubot dosubot bot added area:config Related to configuration, like YAML files, environment variables, or executer configuration area:parsing Related to parsing DAG/DBT improvement, issues, or fixes dbt:parse Primarily related to dbt parse command or functionality parsing:custom Related to custom parsing, like custom DAG parsing, custom DBT parsing, etc priority:high High priority issues are blocking or critical issues without a workaround and large impact labels Nov 20, 2023
Copy link

dosubot bot commented Nov 20, 2023

🤖

Hello @adammarples, it's great to see you again! I hope you're doing well.

Thank you for bringing this to our attention. You're correct that the load_via_custom_parser method currently sets the DbtNode.tags attribute to an empty list, which causes _is_tags_subset to return False every time since set(node.tags) is always empty.

This is because the custom parser does not currently support parsing tags from the dbt project. It's a limitation of the custom parser and not a deliberate design decision to always return False for _is_tags_subset.

If you need to use tags in your dbt project with Cosmos, you might want to consider using a different load method that supports tags, such as load_via_dbt_ls or load_from_dbt_manifest, if your project setup allows for it.

In the load_via_dbt_ls and load_from_dbt_manifest methods, the tags are loaded directly from the dbt project's metadata. In the load_via_dbt_ls method, the tags are loaded from the output of the dbt ls command, as seen in the parse_dbt_ls_output function:

tags=node_dict["tags"],

In the load_from_dbt_manifest method, the tags are loaded from the dbt project's manifest file:

tags=node_dict["tags"],

On the other hand, the load_via_custom_parser method does not handle the DbtNode.tags attribute at all. In this method, a DbtNode instance is created for each model in the dbt project, but the tags attribute is left as an empty list:

tags=[],

This means that any tags associated with the models in the dbt project are not loaded when the load_via_custom_parser method is used.

I hope this clarifies the current behavior of the load_via_custom_parser method in relation to the DbtNode.tags attribute. If you have any further questions or need additional clarification, please let me know.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@tatiana
Copy link
Collaborator

tatiana commented Nov 23, 2023

@adammarples I just checked on the main branch, and the latest versions of Cosmos, both 1.2.5 and 1.3.0a2 should have this fixed:

tags=node_dict["tags"],

Could you upgrade and confirm if it works as expected, please?

@adammarples
Copy link
Contributor Author

Hi @tatiana this is not a problem with DBT_LS but with load via custom parser

which is still there in 1.2.5 etc

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Feb 25, 2024
Copy link

dosubot bot commented Feb 25, 2024

🤖

Hi, @adammarples,

I'm helping the Cosmos team manage their backlog and am marking this issue as stale. The issue you raised regarding the load_via_custom_parser function in the graph.py file, which sets the DbtNode.tags attribute to an empty list, has been acknowledged by the bot and discussed by other users. It seems that there was a suggestion for alternative methods that support tags, and there was mention of the issue being fixed in the latest versions of Cosmos. However, you clarified that the problem still persists in the load_via_custom_parser method.

Could you please confirm if this issue is still relevant to the latest version of the Cosmos repository? If it is, please let the Cosmos team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and cooperation.

@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 13, 2024
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Mar 13, 2024
@tatiana tatiana reopened this May 14, 2024
@tatiana tatiana removed the priority:high High priority issues are blocking or critical issues without a workaround and large impact label May 14, 2024
@tatiana tatiana added this to the 1.5.0 milestone May 14, 2024
@tatiana tatiana added the bug Something isn't working label May 14, 2024
@tatiana
Copy link
Collaborator

tatiana commented May 17, 2024

HI @adammarples , please, could you confirm if this is still an issue in Cosmos 1.4?
Would you like to contribute to the fix?

@tatiana tatiana added good first issue Good for newcomers triage-needed Items need to be reviewed / assigned to milestone labels May 17, 2024
@tatiana tatiana self-assigned this May 17, 2024
@tatiana tatiana mentioned this issue May 17, 2024
@tatiana tatiana removed this from the Cosmos 1.7.0 milestone Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:config Related to configuration, like YAML files, environment variables, or executer configuration area:parsing Related to parsing DAG/DBT improvement, issues, or fixes bug Something isn't working dbt:parse Primarily related to dbt parse command or functionality epic-assigned good first issue Good for newcomers parsing:custom Related to custom parsing, like custom DAG parsing, custom DBT parsing, etc triage-needed Items need to be reviewed / assigned to milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants