Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into jsikorski/snowpark_en…
Browse files Browse the repository at this point in the history
…tities_basic

# Conflicts:
#	src/snowflake/cli/_plugins/streamlit/streamlit_entity.py
  • Loading branch information
sfc-gh-jsikorski committed Dec 20, 2024
2 parents 71bcdb6 + 1c2ef97 commit 5d1c94f
Show file tree
Hide file tree
Showing 57 changed files with 7,081 additions and 311 deletions.
15 changes: 15 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,26 @@
## Backward incompatibility

## Deprecations
* Added deprecation message for default Streamlit warehouse

## New additions
* Add support for Release Directives by introducing the following commands:
* `snow app release-directive list`
* `snow app release-directive set`
* `snow app release-directive unset`
* `snow app version create` now returns version, patch, and label in JSON format.
* Add support for release channels:
* Add support for release channels feature in native app version creation/drop.
* Add ability to specify release channel when creating application instance from release directive: `snow app run --from-release-directive --channel=<channel>`
* Add ability to list release channels through `snow app release-channel list` command
* Add ability to add and remove accounts from release channels through `snow app release-channel add-accounts` and snow app release-channel remove-accounts` commands.
* Add ability to add/remove versions to/from release channels through `snow app release-channel add-version` and `snow app release-channel remove-version` commands.

## Fixes and improvements
* Fixed crashes with older x86_64 Intel CPUs.
* Fixed inability to add patches to lowercase quoted versions
* Fixes label being set to blank instead of None when not provided.
* Added a feature flag `ENABLE_SPCS_LOG_STREAMING` to control the rollout of the log streaming feature

# v3.2.0

Expand Down
20 changes: 19 additions & 1 deletion src/snowflake/cli/_plugins/nativeapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
from snowflake.cli._plugins.nativeapp.entities.application_package import (
ApplicationPackageEntityModel,
)
from snowflake.cli._plugins.nativeapp.release_channel.commands import (
app as release_channels_app,
)
from snowflake.cli._plugins.nativeapp.release_directive.commands import (
app as release_directives_app,
)
from snowflake.cli._plugins.nativeapp.sf_facade import get_snowflake_facade
from snowflake.cli._plugins.nativeapp.v2_conversions.compat import (
find_entity,
Expand Down Expand Up @@ -67,6 +73,8 @@
help="Manages a Snowflake Native App",
)
app.add_typer(versions_app)
app.add_typer(release_directives_app)
app.add_typer(release_channels_app)

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -147,6 +155,12 @@ def app_run(
The command fails if no release directive exists for your Snowflake account for a given application package, which is determined from the project definition file. Default: unset.""",
is_flag=True,
),
channel: str = typer.Option(
None,
show_default=False,
help=f"""The name of the release channel to use when creating or upgrading an application instance from a release directive.
Requires the `--from-release-directive` flag to be set. If unset, the default channel will be used.""",
),
interactive: bool = InteractiveOption,
force: Optional[bool] = ForceOption,
validate: bool = ValidateOption,
Expand Down Expand Up @@ -175,6 +189,7 @@ def app_run(
paths=[],
interactive=interactive,
force=force,
release_channel=channel,
)
app = ws.get_entity(app_id)
return MessageResult(
Expand Down Expand Up @@ -358,7 +373,10 @@ def app_validate(
if cli_context.output_format == OutputFormat.JSON:
return ObjectResult(
package.get_validation_result(
use_scratch_stage=True, interactive=False, force=True
action_ctx=ws.action_ctx,
use_scratch_stage=True,
interactive=False,
force=True,
)
)

Expand Down
4 changes: 4 additions & 0 deletions src/snowflake/cli/_plugins/nativeapp/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
OWNER_COL = "owner"
VERSION_COL = "version"
PATCH_COL = "patch"
CHANNEL_COL = "release_channel_name"
AUTHORIZE_TELEMETRY_COL = "authorize_telemetry_event_sharing"

INTERNAL_DISTRIBUTION = "internal"
EXTERNAL_DISTRIBUTION = "external"

DEFAULT_CHANNEL = "DEFAULT"
DEFAULT_DIRECTIVE = "DEFAULT"
18 changes: 18 additions & 0 deletions src/snowflake/cli/_plugins/nativeapp/entities/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def action_deploy(
prune: bool,
recursive: bool,
paths: List[Path],
release_channel: Optional[str] = None,
validate: bool = ValidateOption,
stage_fqn: Optional[str] = None,
interactive: bool = InteractiveOption,
Expand Down Expand Up @@ -356,15 +357,25 @@ def action_deploy(

# same-account release directive
if from_release_directive:
release_channel = package_entity.get_sanitized_release_channel(
release_channel
)

self.create_or_upgrade_app(
package=package_entity,
stage_fqn=stage_fqn,
install_method=SameAccountInstallMethod.release_directive(),
release_channel=release_channel,
policy=policy,
interactive=interactive,
)
return

if release_channel:
raise UsageError(
f"Release channel is only supported when --from-release-directive is used."
)

# versioned dev
if version:
try:
Expand Down Expand Up @@ -603,6 +614,7 @@ def _upgrade_app(
event_sharing: EventSharingHandler,
policy: PolicyBase,
interactive: bool,
release_channel: Optional[str] = None,
) -> list[tuple[str]] | None:
self.console.step(f"Upgrading existing application object {self.name}.")

Expand All @@ -613,6 +625,7 @@ def _upgrade_app(
stage_fqn=stage_fqn,
debug_mode=self.debug,
should_authorize_event_sharing=event_sharing.should_authorize_event_sharing(),
release_channel=release_channel,
role=self.role,
warehouse=self.warehouse,
)
Expand All @@ -627,6 +640,7 @@ def _create_app(
install_method: SameAccountInstallMethod,
event_sharing: EventSharingHandler,
package: ApplicationPackageEntity,
release_channel: Optional[str] = None,
) -> list[tuple[str]]:
self.console.step(f"Creating new application object {self.name} in account.")

Expand Down Expand Up @@ -665,6 +679,7 @@ def _create_app(
should_authorize_event_sharing=event_sharing.should_authorize_event_sharing(),
role=self.role,
warehouse=self.warehouse,
release_channel=release_channel,
)

@span("update_app_object")
Expand All @@ -675,6 +690,7 @@ def create_or_upgrade_app(
install_method: SameAccountInstallMethod,
policy: PolicyBase,
interactive: bool,
release_channel: Optional[str] = None,
):
event_sharing = EventSharingHandler(
telemetry_definition=self.telemetry,
Expand All @@ -699,6 +715,7 @@ def create_or_upgrade_app(
event_sharing=event_sharing,
policy=policy,
interactive=interactive,
release_channel=release_channel,
)

# 3. If no existing application found, or we performed a drop before the upgrade, we proceed to create
Expand All @@ -708,6 +725,7 @@ def create_or_upgrade_app(
install_method=install_method,
event_sharing=event_sharing,
package=package,
release_channel=release_channel,
)

print_messages(self.console, create_or_upgrade_result)
Expand Down
Loading

0 comments on commit 5d1c94f

Please sign in to comment.