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 override tag support in mixins #1568

Merged
merged 3 commits into from
Sep 17, 2024
Merged

Conversation

sfc-gh-turbaszek
Copy link
Collaborator

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.

Changes description

Adds !override tag for mixins

Copy link
Contributor

@sfc-gh-melnacouzi sfc-gh-melnacouzi left a comment

Choose a reason for hiding this comment

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

I have an overall comment on this.

  1. Have we considered having the flag on the mixin itself?
  2. We don't have only 2 options. We could override, we could append, we could keep (!override). Do we still want to use "!" in the name?

src/snowflake/cli/api/project/definition.py Outdated Show resolved Hide resolved
@@ -277,7 +277,9 @@ def _add_defaults_to_definition(original_definition: Definition) -> Definition:
with context({"skip_validation_on_templates": True}):
# pass a flag to Pydantic to skip validation for templated scalars
# populate the defaults
project_definition = build_project_definition(**original_definition)
project_definition = build_project_definition(
**copy.deepcopy(original_definition)
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't see Pydantics modify the passed in object. Is the copy necessary here or is build_project_definition modifying it now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's necessary because applying mixin was changing YamlOverride to dictionary in original definition thus removing the necessary information.

Copy link
Contributor

@sfc-gh-cgorrie sfc-gh-cgorrie left a comment

Choose a reason for hiding this comment

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

LGTM, but Michel's comments need addressing.

@sfc-gh-turbaszek
Copy link
Collaborator Author

sfc-gh-turbaszek commented Sep 16, 2024

  1. Have we considered having the flag on the mixin itself?

The override behavior is specific to single entity attribute. So it should be a flag on entity field not mixin. In such way the implementation would be even more ciomplex.

  1. We don't have only 2 options. We could override, we could append, we could keep (!override). Do we still want to use "!" in the name?

We decided to use !override tag because that's what docker compose is using and we considered this as battle tested approach.

@sfc-gh-turbaszek sfc-gh-turbaszek enabled auto-merge (squash) September 17, 2024 08:04
@sfc-gh-turbaszek sfc-gh-turbaszek merged commit e659fb3 into main Sep 17, 2024
21 checks passed
@sfc-gh-turbaszek sfc-gh-turbaszek deleted the add-override-support branch September 17, 2024 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants