-
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
Feature: Block-level copying of Jinja content between split projects #192
Feature: Block-level copying of Jinja content between split projects #192
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.
i dig it! nice work on this
if node is None: | ||
continue | ||
|
||
if hasattr(node, "raw_code"): |
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.
forgetting which nodes have raw_code
-- does this indicate we'd be searching the content of a model for docs blocks? are we looking for docs in the definition of YML only resources in this step?
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.
I think you've figured this out already, but yes. This checks raw_code
, and the next check on line 482 checks wihtin the YAML file, too.
if hasattr(node, "raw_code"): | ||
docs.update(find_doc_reference(node.raw_code)) | ||
|
||
if hasattr(node, "patch_path"): |
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.
ah i think this answers my above question
@@ -53,7 +58,8 @@ models: | |||
to: ref('stg_customers') | |||
field: customer_id | |||
- name: location_id | |||
description: The foreign key relating to the location the order was placed | |||
description: |
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.
a note for future us -- we gotta see if ruamel can stop editing newlines 😅
Description and Motivation
There are two PRs related to copying Jinja blocks to split dbt projects. One has to do with block-level copying of macros, to prevent multiple macros in the same file being copyied to a split project, and the other has to do with doc blocks not being copied over due to an absence of references. This PR resolves both issues.
JinjaBlocks
at a character position level. This is accomplished by usingdocs
andmacros
properties of aManifest
, coupled with some clever RegEx, to find where things start and end. Note that the RegEx may be brittle, so 👀append
Operation to our file editors, allowing us to append-only edit files (like if we're moving a Jinja block from one place to another!).DbtSubProject
so we know which doc blocks are being referenced in which code and patch files. This allows us to track which Doc blocks need to be copied, too!Resolves: #142
Resolves: #158