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

build and leverage child and parent maps to properly evaluate cross project dependencies #145

Merged
merged 7 commits into from
Aug 25, 2023

Conversation

dave-connors-3
Copy link
Collaborator

resolves #143

I will also split an additional issue out to track the question of "what happens if a downstream node has two cross-project parents?

this PR adds:

  • logic to build the child_map and parent_map objects into dbt projects
  • uses those maps to simplify and clarify the logic that detects cross project parents and children
  • updates the logic in update_child_refs to only evaluate children of the model called in the split operation (the original motivation of this PR!)

Copy link
Collaborator

@nicholasyager nicholasyager left a comment

Choose a reason for hiding this comment

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

@dave-connors-3 I feel like this is a solid approach, but I have one question about return logic on build_parent_and_child_maps, and another low-level question about {}.

Comment on lines +136 to +138
for model in self.project.child_map[resource.unique_id]:
if model in self.project.resources:
continue
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is such a better solution!

Comment on lines 94 to 95
if hasattr(self.manifest, "child_map") and hasattr(self, "parent_map"):
return
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure that I understand what this logic is here for. Can I get a quick explanation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this logic looks a little drunk tbh -- let me double check whether this was a type check thing that may be eschewed altogether

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed the self.child_map = {} and self.parent_map = {} from the init method, and removed this. IIRC i was battling with mypy when i was writing this manifest method in a slightly different order. I think this should be sufficient!

for resource in self.resources:
if resource.startswith("test"):
continue
all_children.update(self.child_map.get(resource, {}))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if {} evaluates as an empty set, or an empty dict. Might want to confirm this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

in fact, the maps return lists! updated the types accordingly, and confirmed that a list is an acceptable arg to the Set.update() method

@nicholasyager nicholasyager added the bug Something isn't working label Aug 25, 2023
Copy link
Collaborator

@nicholasyager nicholasyager left a comment

Choose a reason for hiding this comment

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

@dave-connors-3 Thanks for simplifying this 👍🏻 ✅

@dave-connors-3 dave-connors-3 merged commit edfc9b5 into main Aug 25, 2023
@nicholasyager nicholasyager deleted the only-evaluate-children-of-node branch September 1, 2023 12:53
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
Development

Successfully merging this pull request may close these issues.

update_child_refs failure - evaluating each cross project children on each iteration
2 participants