-
Notifications
You must be signed in to change notification settings - Fork 4
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
Fix: The group
command will check for existing group file paths.
#195
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🦞 nice work!
dbt_meshify/dbt_projects.py
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clever!
dbt_meshify/dbt_projects.py
Outdated
path = self.path / Path(group.original_file_path) | ||
paths[path] = paths.get(path, 0) + 1 | ||
|
||
self._group_definition_files = list( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woot
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