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

SNOW-1011771: Added generic REPLACE, IF EXISTS, IF NOT EXISTS flags #826

Merged
merged 17 commits into from
Mar 5, 2024

Conversation

sfc-gh-davwang
Copy link
Contributor

@sfc-gh-davwang sfc-gh-davwang commented Feb 24, 2024

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.
  • 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

Added generic flags for REPLACE. IF EXISTS and IF NOT EXISTS to flags.py. Added these flags to spcs service create, spcs compute-pool create, and spcs image-repository create. Also replaced existing usages of --replace with the new flag.

Usage:
image

02/26/24: Added validation that at most one create mode option is set to true
image

passed_kwargs.pop("param_decls", None)
return typer.Option(default, *param_decls, **passed_kwargs)


Copy link
Contributor Author

@sfc-gh-davwang sfc-gh-davwang Feb 24, 2024

Choose a reason for hiding this comment

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

this chunk moves OverrideableOption to the top of the file and also implements mutually_exclusive and _callback_factory

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.

I would like to approve because it provides a lot of customer value, but am not doing so because NADE has no ownership over the affected files. Added some food-for-thought comments... if your time is limited I'm happy to take this PR over but first we need some feedback from the Snowflake CLI folks.

src/snowflake/cli/api/commands/flags.py Outdated Show resolved Hide resolved
src/snowflake/cli/plugins/spcs/image_repository/manager.py Outdated Show resolved Hide resolved
@sfc-gh-davwang sfc-gh-davwang force-pushed the SNOW-1011771-create-exists-replace branch from 7dadbf8 to c52e33a Compare February 28, 2024 20:13
@sfc-gh-davwang sfc-gh-davwang changed the title SNOW-1011771: Added generic CREATE, IF EXISTS, IF NOT EXISTS flags SNOW-1011771: Added generic REPLACE, IF EXISTS, IF NOT EXISTS flags Mar 1, 2024
tests/api/commands/test_flags.py Outdated Show resolved Hide resolved


def test_overrideable_option_invalid_callback_signature():
pass
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 test needed?

tests/spcs/test_image_repository.py Show resolved Hide resolved
tests/api/commands/test_flags.py Outdated Show resolved Hide resolved
@@ -13,6 +14,106 @@
_CLI_BEHAVIOUR = "Global configuration"


class OverrideableOption:
Copy link
Contributor

Choose a reason for hiding this comment

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

This class needs more tests, has a lot of ifs which should be tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, I've added more tests to test_flags but let me know if there's any cases I haven't thought of

@sfc-gh-davwang sfc-gh-davwang force-pushed the SNOW-1011771-create-exists-replace branch 3 times, most recently from ec9ff48 to e8f7f98 Compare March 4, 2024 08:33
@sfc-gh-davwang sfc-gh-davwang force-pushed the SNOW-1011771-create-exists-replace branch from 4b51d67 to 9ebed5e Compare March 4, 2024 18:28
@sfc-gh-davwang sfc-gh-davwang force-pushed the SNOW-1011771-create-exists-replace branch from 9ebed5e to 50ee873 Compare March 5, 2024 09:37
@sfc-gh-davwang sfc-gh-davwang force-pushed the SNOW-1011771-create-exists-replace branch from 50ee873 to d3b39bd Compare March 5, 2024 09:40
@sfc-gh-davwang sfc-gh-davwang merged commit 1e939d6 into main Mar 5, 2024
18 checks passed
@sfc-gh-davwang sfc-gh-davwang deleted the SNOW-1011771-create-exists-replace branch March 5, 2024 10:17
sfc-gh-jsikorski pushed a commit that referenced this pull request Mar 6, 2024
This reverts commit 80467b3.

mraba/app-factory: create app with factory (#860)

* mraba/app-factory: create app with factory

SNOW-1043081: Adding support for qualified names for image repositories. (#823)

* SNOW-1043081: Adding support for qualified image repository names

* SNOW-1043081: Fixing test imports

* SNOW-1043081: Adding tests for getting image repository url without db or schema

SNOW-1011771: Added generic REPLACE, IF EXISTS, IF NOT EXISTS flags (#826)

* SNOW-1011771: Adding generic OR REPLACE, IF EXISTS, IF NOT EXISTS flags to flags.py

* SNOW-1011771: Using generic ReplaceOption in snowpark deploy and streamlit deploy

* SNOW-1011771: Using generic IfNotExistsOption in compute pool create and updating unit tests.

* SNOW-1011771: Using generic IfNotExistsOption in service create and updating unit tests

* SNOW-1011771: Using generic ReplaceOption and IfNotExistsOption in image-repository create.

* SNOW-1011771: Fixup

* SNOW-1011771: Update release notes

* SNOW-1011771: Update test_help_messages

* SNOW-1011771: precommit

* SNOW-1011771: Adding validation that only one create mode option can be set at once

* fixup

* SNOW-1011771: Updating tests for REPLACE AND IF NOT EXISTS case on image-repository create to throw error

* SNOW-1011771: Adding snapshots

* SNOW-1011771: Adding a new mutually_exclusive field to OverrideableOption

* formatting

* SNOW-1011771: Adding tests for OverrideableOption

* SNOW-1011771: Fixing test failures due to improperly quoted string

Add snow --help to test_help_messages (#821)

* Add snow --help to test_help_messages

* update snapshot

Avoid plain print, make sure silent is eager flag (#871)

[NADE] Update CODEOWNERS to use NADE team id. (#873)

update to using nade team in codeowners

New workflow to stop running workflows after new commit (#862)

* new workflow

* new workflow

* new workflow

* new workflow

* typo fix

* typo fix

* import fix

* import fix

* import fix

* import fix

* import fix

* import fix

* import fix

* new approach

* new approach

* new approach

* new approach

* new approach

* New approach

* added to test

* Added to more workflows

* Dummy commit

Schemas

adjusting native apps to streamlit

fixing streamlit

fixies after unit tests

fixies after unit tests

fixing for snowflake

fixing for snowflake

Fixes after review

Fixes after review

Fixes after review
sfc-gh-jsikorski added a commit that referenced this pull request Mar 8, 2024
* Revert "Bump tomlkit from 0.12.3 to 0.12.4 (#848)" (#863)

This reverts commit 80467b3.

mraba/app-factory: create app with factory (#860)

* mraba/app-factory: create app with factory

SNOW-1043081: Adding support for qualified names for image repositories. (#823)

* SNOW-1043081: Adding support for qualified image repository names

* SNOW-1043081: Fixing test imports

* SNOW-1043081: Adding tests for getting image repository url without db or schema

SNOW-1011771: Added generic REPLACE, IF EXISTS, IF NOT EXISTS flags (#826)

* SNOW-1011771: Adding generic OR REPLACE, IF EXISTS, IF NOT EXISTS flags to flags.py

* SNOW-1011771: Using generic ReplaceOption in snowpark deploy and streamlit deploy

* SNOW-1011771: Using generic IfNotExistsOption in compute pool create and updating unit tests.

* SNOW-1011771: Using generic IfNotExistsOption in service create and updating unit tests

* SNOW-1011771: Using generic ReplaceOption and IfNotExistsOption in image-repository create.

* SNOW-1011771: Fixup

* SNOW-1011771: Update release notes

* SNOW-1011771: Update test_help_messages

* SNOW-1011771: precommit

* SNOW-1011771: Adding validation that only one create mode option can be set at once

* fixup

* SNOW-1011771: Updating tests for REPLACE AND IF NOT EXISTS case on image-repository create to throw error

* SNOW-1011771: Adding snapshots

* SNOW-1011771: Adding a new mutually_exclusive field to OverrideableOption

* formatting

* SNOW-1011771: Adding tests for OverrideableOption

* SNOW-1011771: Fixing test failures due to improperly quoted string

Add snow --help to test_help_messages (#821)

* Add snow --help to test_help_messages

* update snapshot

Avoid plain print, make sure silent is eager flag (#871)

[NADE] Update CODEOWNERS to use NADE team id. (#873)

update to using nade team in codeowners

New workflow to stop running workflows after new commit (#862)

* new workflow

* new workflow

* new workflow

* new workflow

* typo fix

* typo fix

* import fix

* import fix

* import fix

* import fix

* import fix

* import fix

* import fix

* new approach

* new approach

* new approach

* new approach

* new approach

* New approach

* added to test

* Added to more workflows

* Dummy commit

Schemas

adjusting native apps to streamlit

fixing streamlit

fixies after unit tests

fixies after unit tests

fixing for snowflake

fixing for snowflake

Fixes after review

Fixes after review

Fixes after review

* Fixes after review

* Implemented error class

* Fixes

* Fixes

* Fixes

* Fixes

* typo fix

* Added unit test

* Added unit test

* Fixes after review

* Fixes after review

* Fixes

* Fixes

* Fixes

---------

Co-authored-by: Adam Stus <[email protected]>
sfc-gh-sichen pushed a commit that referenced this pull request Oct 17, 2024
…826)

* SNOW-1011771: Adding generic OR REPLACE, IF EXISTS, IF NOT EXISTS flags to flags.py

* SNOW-1011771: Using generic ReplaceOption in snowpark deploy and streamlit deploy

* SNOW-1011771: Using generic IfNotExistsOption in compute pool create and updating unit tests.

* SNOW-1011771: Using generic IfNotExistsOption in service create and updating unit tests

* SNOW-1011771: Using generic ReplaceOption and IfNotExistsOption in image-repository create.

* SNOW-1011771: Fixup

* SNOW-1011771: Update release notes

* SNOW-1011771: Update test_help_messages

* SNOW-1011771: precommit

* SNOW-1011771: Adding validation that only one create mode option can be set at once

* fixup

* SNOW-1011771: Updating tests for REPLACE AND IF NOT EXISTS case on image-repository create to throw error

* SNOW-1011771: Adding snapshots

* SNOW-1011771: Adding a new mutually_exclusive field to OverrideableOption

* formatting

* SNOW-1011771: Adding tests for OverrideableOption

* SNOW-1011771: Fixing test failures due to improperly quoted string
sfc-gh-sichen pushed a commit that referenced this pull request Oct 17, 2024
* Revert "Bump tomlkit from 0.12.3 to 0.12.4 (#848)" (#863)

This reverts commit a3ed7cc.

mraba/app-factory: create app with factory (#860)

* mraba/app-factory: create app with factory

SNOW-1043081: Adding support for qualified names for image repositories. (#823)

* SNOW-1043081: Adding support for qualified image repository names

* SNOW-1043081: Fixing test imports

* SNOW-1043081: Adding tests for getting image repository url without db or schema

SNOW-1011771: Added generic REPLACE, IF EXISTS, IF NOT EXISTS flags (#826)

* SNOW-1011771: Adding generic OR REPLACE, IF EXISTS, IF NOT EXISTS flags to flags.py

* SNOW-1011771: Using generic ReplaceOption in snowpark deploy and streamlit deploy

* SNOW-1011771: Using generic IfNotExistsOption in compute pool create and updating unit tests.

* SNOW-1011771: Using generic IfNotExistsOption in service create and updating unit tests

* SNOW-1011771: Using generic ReplaceOption and IfNotExistsOption in image-repository create.

* SNOW-1011771: Fixup

* SNOW-1011771: Update release notes

* SNOW-1011771: Update test_help_messages

* SNOW-1011771: precommit

* SNOW-1011771: Adding validation that only one create mode option can be set at once

* fixup

* SNOW-1011771: Updating tests for REPLACE AND IF NOT EXISTS case on image-repository create to throw error

* SNOW-1011771: Adding snapshots

* SNOW-1011771: Adding a new mutually_exclusive field to OverrideableOption

* formatting

* SNOW-1011771: Adding tests for OverrideableOption

* SNOW-1011771: Fixing test failures due to improperly quoted string

Add snow --help to test_help_messages (#821)

* Add snow --help to test_help_messages

* update snapshot

Avoid plain print, make sure silent is eager flag (#871)

[NADE] Update CODEOWNERS to use NADE team id. (#873)

update to using nade team in codeowners

New workflow to stop running workflows after new commit (#862)

* new workflow

* new workflow

* new workflow

* new workflow

* typo fix

* typo fix

* import fix

* import fix

* import fix

* import fix

* import fix

* import fix

* import fix

* new approach

* new approach

* new approach

* new approach

* new approach

* New approach

* added to test

* Added to more workflows

* Dummy commit

Schemas

adjusting native apps to streamlit

fixing streamlit

fixies after unit tests

fixies after unit tests

fixing for snowflake

fixing for snowflake

Fixes after review

Fixes after review

Fixes after review

* Fixes after review

* Implemented error class

* Fixes

* Fixes

* Fixes

* Fixes

* typo fix

* Added unit test

* Added unit test

* Fixes after review

* Fixes after review

* Fixes

* Fixes

* Fixes

---------

Co-authored-by: Adam Stus <[email protected]>
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.

3 participants