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

Support node_color and docs.show under the config object #281

Merged
merged 17 commits into from
Aug 4, 2022

Conversation

b-per
Copy link
Contributor

@b-per b-per commented Jun 21, 2022

relates to #279
works in conjunction with dbt-labs/dbt-core#5397

I leveraged @sungchun12's logic and the modifications to dbt Core of dbt-labs/dbt-core#5397 to support defining docs.show and docs.node_color as node configs and have them update the docs accordingly.

With this approach docs.show can be defined in 2 different places. As docs.show, as it has been the case in the past versions (and kept like this to avoid breaking changes), and as config.docs.show when we define the docs as a config item.

The big advantage of the config item is that we can configure models at the folder level in dbt_project.yml

For now, there is no validation of node_color on the dbt-docs side but there is some validation on the dbt-core side.

The following config under dbt_project.yml generates the DAG below:

models:
  jaffle_shop:
      materialized: table
      +docs:
        node_color: criMsON
      staging:
        materialized: view
        +docs:
          node_color: "#e76f51"

image

@cla-bot cla-bot bot added the cla:yes label Jun 21, 2022
@sungchun12
Copy link
Contributor

I know we talked about +docs not being intuitive on a surface level for this config, but that's okay given current UX expects a person to do the same with the config: persist_docs

@@ -19,7 +19,7 @@
<div class="app-links app-sticky">
<div class="app-title">
<div class="app-frame app-pad app-flush-bottom">
<h1 ng-if="model.docs.show === false">
<h1 ng-if="model.docs.show === false || model.config.docs.show === false">
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the if else default here

@sungchun12
Copy link
Contributor

@b-per can you take a first draft of adding the defensive code: https://gist.github.com/stu-k/aac9d0fb7bf5e325f4fa8d260bd28fc8

based on the comment: dbt-labs/dbt-core#5397 (comment)

@b-per
Copy link
Contributor Author

b-per commented Jun 23, 2022

Yes, I will give it a shot 👍

@b-per
Copy link
Contributor Author

b-per commented Jun 27, 2022

I have added Stu's code on color validation and tested it.

With this new code, even thought the node_color is set as "node_color": "invalid_color", the docs do not crash anymore and the color is set to the default one. (example below with the model customers having an invalid code)
image

The question now is whether we would like to keep the validation on the dbt-docs side only or on both dbt-docs and dbt-core

@b-per b-per requested a review from stu-k June 27, 2022 09:30
@sungchun12
Copy link
Contributor

sungchun12 commented Jun 27, 2022

@b-per thanks for much for progressing on this! I'll take a deeper look today/tomorrow. Per Stu's recommendation(dbt-labs/dbt-core#5397 (comment)) , we will keep the defensive code in one place for maintenance consistency. If this code is in two places, contributing to the dbt docs further will become more of a frankenstein than evolution.

NOT APPLICABLE ANYMORE

@jtcohen6
Copy link
Contributor

jtcohen6 commented Jun 29, 2022

Very supportive of the "defensive" color validation logic living in this codebase.

I have a very slight preference for accessing this metadata from node's top-level property always (node.docs), rather than reaching into node.config.docs — and that we should perform the coordination between those two fields within dbt-core (dbt-labs/dbt-core#5397 (comment)). I appreciate that's a bigger lift.

@dbt-labs/core-language very open to your thoughts here, as the team continues to develop its thinking around what should be a config and what should be a top-level property.

@sungchun12
Copy link
Contributor

Doing some manual testing to check for edge cases. No red flags!

I noticed if you import a dbt package that people will have to color code that via code as well. You'll notice dbt_artifacts is left alone as expected.

What's working well?

  • folder level color configs
  • node-specific overrides folder level

image

@sungchun12
Copy link
Contributor

TODO: Also, with docs behaving the way that jerco mentioned, we will need to update the dbt-docs code to look under model.docs instead of model.config.docs (not a huge change but just keeping it in mind)

@sungchun12
Copy link
Contributor

@jtcohen6 any updates on whether we have the node_color under property vs. config hierarchy?

I have a draft in #288 separated out until we answer the above to then officially merge those changes into this PR.

This will require changes to dbt-labs/dbt-core#5397 based on the threads there.

I want to make sure we're aligned on approach before we commit code in the wrong design pattern!

@sungchun12
Copy link
Contributor

I will own this to ensure the property is at the top-level vs. config level

el.data['hidden'] = 1;
}

var color_config = _.get(el, ['data', 'config', 'docs', 'node_color'])
Copy link
Contributor

Choose a reason for hiding this comment

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

@b-per Is this still expected? If I remove the 'config' portion in the list, the custom colors do NOT work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this is expected based on this this line: here

This is ready for review!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just did a test with the latest dbt-core and it works without looking at config. I think that we said we'd want to read from docs directly so I will push a small change.

@sungchun12 sungchun12 self-assigned this Jul 20, 2022
@sungchun12 sungchun12 added the ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering label Jul 20, 2022
@emmyoop emmyoop changed the title [Draft] Support node_color and docs.show under the config object Support node_color and docs.show under the config object Aug 3, 2022
Copy link
Contributor

@stu-k stu-k left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Member

@emmyoop emmyoop left a comment

Choose a reason for hiding this comment

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

Looks good. Can you please add a changelog entry indicating the change and then it should be ready to merge!

@b-per b-per requested a review from emmyoop August 4, 2022 13:29
@b-per
Copy link
Contributor Author

b-per commented Aug 4, 2022

I just modified the CHANGELOG 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants