Skip to content

Commit

Permalink
Remove snow app init command (#1630)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pjafari authored Sep 27, 2024
1 parent 091947c commit 20cec62
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 1,157 deletions.
3 changes: 2 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
## Backward incompatibility
* Dropped support for Python below 3.10 version.
* `snow object stage` commands are removed in favour of `snow stage`.
* `snow snowpark init` and `snow streamlit init` commands are removed in favor of `snow init` command.
* `snow snowpark init`, `snow streamlit init`, and `snow app init` commands are removed in favor of `snow init` command.
* Removed deprecated flags from `snow snowpark` commands.
* Default Python version for Snowpark functions and procedures was bumped to 3.10 from 3.8.
* Snowpark commands
Expand All @@ -43,6 +43,7 @@
* `snow snowpark package` commands no longer fallback to Anaconda Channel metadata when fetching available packages info fails.
* Added `snow streamlit execute app-name` command to run Streamlit apps in a Snowflake environment in headless mode.


## Deprecations
* Renamed `private-key-path` flag to `private-key-file`, added `private-key-path` as an alias for backward compatibility.

Expand Down
87 changes: 6 additions & 81 deletions src/snowflake/cli/_plugins/nativeapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from typing import Generator, Iterable, List, Optional, cast

import typer
from click.exceptions import ClickException
from snowflake.cli._plugins.nativeapp.common_flags import (
ForceOption,
InteractiveOption,
Expand All @@ -31,10 +32,6 @@
from snowflake.cli._plugins.nativeapp.entities.application_package import (
ApplicationPackageEntityModel,
)
from snowflake.cli._plugins.nativeapp.init import (
OFFICIAL_TEMPLATES_GITHUB_URL,
nativeapp_init,
)
from snowflake.cli._plugins.nativeapp.manager import NativeAppManager
from snowflake.cli._plugins.nativeapp.policy import (
AllowAlwaysPolicy,
Expand All @@ -45,10 +42,6 @@
from snowflake.cli._plugins.nativeapp.teardown_processor import (
NativeAppTeardownProcessor,
)
from snowflake.cli._plugins.nativeapp.utils import (
get_first_paragraph_from_markdown_file,
shallow_git_clone,
)
from snowflake.cli._plugins.nativeapp.v2_conversions.v2_to_v1_decorator import (
find_entity,
nativeapp_definition_v2_to_v1,
Expand All @@ -69,15 +62,13 @@
from snowflake.cli.api.exceptions import IncompatibleParametersError
from snowflake.cli.api.output.formats import OutputFormat
from snowflake.cli.api.output.types import (
CollectionResult,
CommandResult,
MessageResult,
ObjectResult,
StreamResult,
)
from snowflake.cli.api.project.project_verification import assert_project_type
from snowflake.cli.api.project.schemas.project_definition import ProjectDefinitionV1
from snowflake.cli.api.secure_path import SecurePath
from typing_extensions import Annotated

app = SnowTyperFactory(
Expand All @@ -89,81 +80,15 @@
log = logging.getLogger(__name__)


@app.command("init")
def app_init(
path: str = typer.Argument(
...,
help=f"""Directory to be initialized with the Snowflake Native App project. This directory must not already exist.""",
show_default=False,
),
name: str = typer.Option(
None,
help=f"""The name of the Snowflake Native App project to include in snowflake.yml. When not specified, it is
generated from the name of the directory. Names are assumed to be unquoted identifiers whenever possible, but
can be forced to be quoted by including the surrounding quote characters in the provided value.""",
),
template_repo: str = typer.Option(
None,
help=f"""Specifies the git URL to a template repository, which can be a template itself or contain many templates inside it,
such as https://github.com/snowflakedb/native-apps-templates.git for all official Snowflake Native App with Snowflake CLI templates.
If using a private Github repo, you might be prompted to enter your Github username and password.
Please use your personal access token in the password prompt, and refer to
https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.""",
),
template: str = typer.Option(
None,
help="A specific template name within the template repo to use as template for the Snowflake Native App project. Example: Default is basic if `--template-repo` is https://github.com/snowflakedb/native-apps-templates.git, and None if any other --template-repo is specified.",
),
**options,
) -> CommandResult:
@app.command("init", hidden=True)
def app_init(**options):
"""
Initializes a Snowflake Native App project.
"""
project = nativeapp_init(
path=path, name=name, git_url=template_repo, template=template
)
return MessageResult(
f"Snowflake Native App project {project.name} has been created at: {path}"
)

*** Deprecated. Use snow init instead ***
@app.command("list-templates", hidden=True)
def app_list_templates(**options) -> CommandResult:
"""
Prints information regarding the official templates that can be used with snow app init.
Initializes a Snowflake Native App project.
"""
with SecurePath.temporary_directory() as temp_path:
from git import rmtree as git_rmtree

repo = shallow_git_clone(OFFICIAL_TEMPLATES_GITHUB_URL, temp_path.path)

# Mark a directory as a template if a project definition jinja template is inside
template_directories = [
entry.name
for entry in repo.head.commit.tree
if (temp_path / entry.name / "snowflake.yml.jinja").exists()
]

# get the template descriptions from the README.md in its directory
template_descriptions = [
get_first_paragraph_from_markdown_file(
(temp_path / directory / "README.md").path
)
for directory in template_directories
]

result = (
{"template": directory, "description": description}
for directory, description in zip(
template_directories, template_descriptions
)
)

# proactively clean up here to avoid permission issues on Windows
repo.close()
git_rmtree(temp_path.path)

return CollectionResult(result)
raise ClickException("This command has been removed. Use `snow init` instead.")


@app.command("bundle")
Expand Down
Loading

0 comments on commit 20cec62

Please sign in to comment.