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

Use yaml renderer (with target context) for rendering selectors #5136

Merged
merged 7 commits into from
Apr 26, 2022

Conversation

gshank
Copy link
Contributor

@gshank gshank commented Apr 22, 2022

resolves #5131

Description

When we set up "secret" contexts for profiles.yml and packages.yml, we also made the context for rendering selectors.yml into a secret context (which does not include the target), when it should have stayed as a target context.

Checklist

@gshank gshank requested a review from a team as a code owner April 22, 2022 17:54
@gshank gshank requested a review from nathaniel-may April 22, 2022 17:54
@cla-bot cla-bot bot added the cla:yes label Apr 22, 2022
@github-actions
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@gshank
Copy link
Contributor Author

gshank commented Apr 22, 2022

Note: I haven't created tests yet, but wanted to get this out there for inspection and running tests.

@gshank gshank requested a review from a team as a code owner April 22, 2022 17:57
@gshank gshank requested a review from stu-k April 22, 2022 17:57
@gshank
Copy link
Contributor Author

gshank commented Apr 22, 2022

Note: this will be backported, but without the test commits.

@gshank gshank requested a review from ChenyuLInx April 22, 2022 20:51
Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

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

This PR feels like a lot of changes for something we ultimately need to backport to both 1.1.latest + 1.0.latest. After looking through it, most of the changes are:

So, after looking through it, and a bit of local testing, I'm much more comfortable with the change. I'll leave final code review to the Language team. We should aim to merge this ASAP so we can backport and include it in v1.0.6-rc1.

@@ -114,12 +114,10 @@ def __init__(
def name(self):
"Project config"

# Uses SecretRenderer
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Comment on lines +65 to +66
if cli_vars is None:
cli_vars = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this just moving the code from SecretRenderer here?

This is the only part that scares me, insofar as it touches code that's more widely used than just selectors.yml. It's hard to imagine how this could cause issues, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to "make mypy happy", because in some places we have an Optional[Dict[str, Any]] and in other places it's not Optional. So without this mypy will complain. We do a similar thing in a number of other places.

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! Thanks for the explanation

@@ -3,7 +3,7 @@
from dbt.clients.yaml_helper import yaml, Loader, Dumper, load_yaml_text # noqa: F401
from dbt.dataclass_schema import ValidationError

from .renderer import SelectorRenderer
from .renderer import BaseRenderer
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense to just use BaseRenderer, since the context available to selectors.yml is the same as every other yaml files

@gshank
Copy link
Contributor Author

gshank commented Apr 26, 2022

Last time I made the separate ticket to create tests and it didn't actually happen. I really didn't want to leave this without tests this time, so I included them (the conversion was ready to go). I'm going to cherry-pick the non-test commit for backports.

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. Agree with @jtcohen6 that this seemed like a bigger change than it is because of the tests.

@gshank gshank merged commit 1f898c8 into main Apr 26, 2022
@gshank gshank deleted the ct-540-use_target_context_for_selectors branch April 26, 2022 15:42
gshank added a commit that referenced this pull request Apr 26, 2022
* Use yaml renderer (with target context) for rendering selectors

* Changie

* Convert cli_vars tests

* Add test for var in profiles

* Add test for cli vars in packages

* Add test for vars in selectors
github-actions bot pushed a commit that referenced this pull request Apr 26, 2022
* Use yaml renderer (with target context) for rendering selectors

* Changie

* Convert cli_vars tests

* Add test for var in profiles

* Add test for cli vars in packages

* Add test for vars in selectors

(cherry picked from commit 1f898c8)
gshank added a commit that referenced this pull request Apr 26, 2022
…dering selectors (#5161)

* Use yaml renderer (with target context) for rendering selectors (#5136)

* Use yaml renderer (with target context) for rendering selectors

* Changie

* Convert cli_vars tests

* Add test for var in profiles

* Add test for cli vars in packages

* Add test for vars in selectors

(cherry picked from commit 1f898c8)

* Tweak cli_vars_in_packages test to do a run and build an adapter

Co-authored-by: Gerda Shank <[email protected]>
@gshank gshank mentioned this pull request Apr 28, 2022
72 tasks
agoblet pushed a commit to BigDataRepublic/dbt-core that referenced this pull request May 20, 2022
…labs#5136)

* Use yaml renderer (with target context) for rendering selectors

* Changie

* Convert cli_vars tests

* Add test for var in profiles

* Add test for cli vars in packages

* Add test for vars in selectors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-540] [Bug] 'target' suddenly not available at compile time in selectors.yml
4 participants