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

add macros to flat graph #332

Merged
merged 12 commits into from
Mar 17, 2017
Merged

add macros to flat graph #332

merged 12 commits into from
Mar 17, 2017

Conversation

cmcarthur
Copy link
Member

No description provided.

Copy link
Contributor

@drewbanin drewbanin left a comment

Choose a reason for hiding this comment

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

this is great so far! keen to see how you avoid compiling only the relevant macros for each model

name = macro.get('name')
package_name = macro.get('package_name')

if context.get(package_name, {}).get(name) is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

how would this happen?

Copy link
Member Author

@cmcarthur cmcarthur Mar 15, 2017

Choose a reason for hiding this comment

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

we parse each macro once, but parsing a "macro" is really parsing the file that macro is in. so, without this code, if a file contained 3 macros, we'd parse that file 3 times.

Copy link
Contributor

Choose a reason for hiding this comment

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

got it

@@ -425,16 +439,7 @@ def compile_nodes(self, linker, nodes, macro_generator):
if cycle:
raise RuntimeError("Found a cycle: {}".format(cycle))

return wrapped_nodes, written_nodes

def generate_macros(self, all_macros):
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 👍 👍


compiled_nodes, written_nodes = self.compile_nodes(linker, all_nodes,
macro_generator)
compiled_graph, written_nodes = self.compile_graph(linker, flat_graph)

self.write_graph_file(linker)

stats = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

we can use a defaultdict here :)

stats = defaultdict(int)
stats[node.get('resource_type')] += 1

... just sayin

dbt/parser.py Outdated
return to_return


class FakeProject:
Copy link
Contributor

Choose a reason for hiding this comment

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

what's going on here?

Copy link
Contributor

@drewbanin drewbanin left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -30,6 +29,45 @@
graph_file_name = 'graph.gpickle'


def recursively_parse_macros_for_node(node, flat_graph, context):
# this once worked, but is now long dead
Copy link
Contributor

Choose a reason for hiding this comment

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

hah

@cmcarthur cmcarthur merged commit de06d65 into development Mar 17, 2017
@cmcarthur cmcarthur deleted the graph/macros branch March 17, 2017 18:31
iknox-fa pushed a commit that referenced this pull request Feb 8, 2022
automatic commit by git-black, original commits:
  de06d65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants