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

Fix: The group command will check for existing group file paths. #195

Merged
merged 3 commits into from
Jan 31, 2024

Conversation

nicholasyager
Copy link
Collaborator

@nicholasyager nicholasyager commented Jan 15, 2024

Description and Motivation

There was a small defect in dbt-meshify, in which the tool would ignore existing files that define groups, instead always defaulting to _group.yml. The desired behavior would be to default to a single file that already contains groups if one exists. To that end, I've implemented a check that finds all files that define groups, and if there is one and only one, it will default to that file. If there are none, it will use _groups.yml. If there are multiple, it will raise a fatal error and prompt the user to provide a --group-file-yaml path.

Along the way, I also added tests to confirm that the functionality works as expected.

Resolves: #188

@nicholasyager nicholasyager added the bug Something isn't working label Jan 15, 2024
@nicholasyager nicholasyager self-assigned this Jan 15, 2024
@nicholasyager nicholasyager marked this pull request as ready for review January 15, 2024 20:10
Copy link
Collaborator

@dave-connors-3 dave-connors-3 left a comment

Choose a reason for hiding this comment

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

🦞 nice work!

paths: Dict[Path, int] = {}
for group in self.manifest.groups.values():
path = self.path / Path(group.original_file_path)
paths[path] = paths.get(path, 0) + 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

clever!

path = self.path / Path(group.original_file_path)
paths[path] = paths.get(path, 0) + 1

self._group_definition_files = list(
Copy link
Collaborator

Choose a reason for hiding this comment

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

just want to make sure i follow this logic -- you're sorting the paths by the count of groups defined in that path, and only returning a list of paths?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep. Looking at it now, however, I realize that sorting actually isn't necessary, since it should error out if len(x) > 1. I can pull this out to free up a few milliseconds

Copy link
Collaborator

@dave-connors-3 dave-connors-3 left a comment

Choose a reason for hiding this comment

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

woot

@dave-connors-3 dave-connors-3 merged commit dcb4d97 into dbt-labs:main Jan 31, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants