Skip to content

Commit

Permalink
Add deprecation warnings for init commands (#1360)
Browse files Browse the repository at this point in the history
* Deprecation warning

* Update readme

* fix
  • Loading branch information
sfc-gh-jsikorski authored Jul 25, 2024
1 parent b01693e commit a29aefb
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 41 deletions.
3 changes: 2 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
## Backward incompatibility

## Deprecations

* `snow snowpark init` and `snow streamlit init` are marked as deprecated. The commands are still functional,
but should be replaced with `snow init`
## New additions
* Added connection option `--token-file-path` allowing passing OAuth token using a file. The function is also
supported by setting `token_file_path` in connection definition.
Expand Down
5 changes: 4 additions & 1 deletion src/snowflake/cli/api/commands/project_initialisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def add_init_command(
template: str,
help_message: Optional[str] = None,
):
@app.command()
@app.command(deprecated=True)
def init(
project_name: str = Argument(
f"example_{project_type.lower()}",
Expand All @@ -47,6 +47,7 @@ def init(
),
**options,
) -> CommandResult:

_create_project_template(template, project_directory=project_name)
return MessageResult(f"Initialized the new project in {project_name}/")

Expand All @@ -57,6 +58,8 @@ def init(
init.__doc__ = (
f"Initializes this directory with a sample set "
f"of files for creating a {project_type_doc} project."
f"This command is deprecated and will be removed soon."
f"Please use 'snow init' instead"
)

return init
98 changes: 60 additions & 38 deletions tests/__snapshots__/test_help_messages.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -3623,8 +3623,10 @@

Usage: default snowpark init [OPTIONS] [PROJECT_NAME]

(deprecated)
Initializes this directory with a sample set of files for creating a Snowpark
project.
project.This command is deprecated and will be removed soon.Please use 'snow
init' instead

+- Arguments ------------------------------------------------------------------+
| project_name [PROJECT_NAME] Name of the Snowpark project you want to |
Expand Down Expand Up @@ -3995,19 +3997,24 @@
| --help -h Show this message and exit. |
+------------------------------------------------------------------------------+
+- Commands -------------------------------------------------------------------+
| build Builds the Snowpark project as a `.zip` archive that can be used |
| by `deploy` command. The archive is built using only the `src` |
| directory specified in the project file. |
| deploy Deploys procedures and functions defined in project. Deploying |
| the project alters all objects defined in it. By default, if any |
| of the objects exist already the commands will fail unless |
| `--replace` flag is provided. All deployed objects use the same |
| artifact which is deployed only once. |
| build Builds the Snowpark project as a `.zip` archive |
| that can be used by `deploy` command. The archive |
| is built using only the `src` directory specified |
| in the project file. |
| deploy Deploys procedures and functions defined in |
| project. Deploying the project alters all objects |
| defined in it. By default, if any of the objects |
| exist already the commands will fail unless |
| `--replace` flag is provided. All deployed objects |
| use the same artifact which is deployed only once. |
| describe Provides description of a procedure or function. |
| drop Drop procedure or function. |
| execute Executes a procedure or function in a specified environment. |
| init Initializes this directory with a sample set of files for |
| creating a Snowpark project. |
| execute Executes a procedure or function in a specified |
| environment. |
| init Initializes this directory with a sample set of (deprecated) |
| files for creating a Snowpark project.This command |
| is deprecated and will be removed soon.Please use |
| 'snow init' instead |
| list Lists all available procedures or functions. |
| package Manages custom Python packages for Snowpark |
+------------------------------------------------------------------------------+
Expand Down Expand Up @@ -7908,8 +7915,10 @@

Usage: default streamlit init [OPTIONS] [PROJECT_NAME]

(deprecated)
Initializes this directory with a sample set of files for creating a Streamlit
app project.
app project.This command is deprecated and will be removed soon.Please use
'snow init' instead

+- Arguments ------------------------------------------------------------------+
| project_name [PROJECT_NAME] Name of the Streamlit app project |
Expand Down Expand Up @@ -8095,16 +8104,20 @@
| --help -h Show this message and exit. |
+------------------------------------------------------------------------------+
+- Commands -------------------------------------------------------------------+
| deploy Deploys a Streamlit app defined in the project definition file |
| (snowflake.yml). By default, the command uploads environment.yml |
| and any other pages or folders, if present. If you don’t specify |
| a stage name, the `streamlit` stage is used. If the specified |
| stage does not exist, the command creates it. |
| deploy Deploys a Streamlit app defined in the project |
| definition file (snowflake.yml). By default, the |
| command uploads environment.yml and any other |
| pages or folders, if present. If you don’t specify |
| a stage name, the `streamlit` stage is used. If |
| the specified stage does not exist, the command |
| creates it. |
| describe Provides description of streamlit. |
| drop Drops streamlit with given name. |
| get-url Returns a URL to the specified Streamlit app |
| init Initializes this directory with a sample set of files for |
| creating a Streamlit app project. |
| init Initializes this directory with a sample set of (deprecated) |
| files for creating a Streamlit app project.This |
| command is deprecated and will be removed |
| soon.Please use 'snow init' instead |
| list Lists all available streamlits. |
| share Shares a Streamlit app with another role. |
+------------------------------------------------------------------------------+
Expand Down Expand Up @@ -8357,19 +8370,24 @@
| --help -h Show this message and exit. |
+------------------------------------------------------------------------------+
+- Commands -------------------------------------------------------------------+
| build Builds the Snowpark project as a `.zip` archive that can be used |
| by `deploy` command. The archive is built using only the `src` |
| directory specified in the project file. |
| deploy Deploys procedures and functions defined in project. Deploying |
| the project alters all objects defined in it. By default, if any |
| of the objects exist already the commands will fail unless |
| `--replace` flag is provided. All deployed objects use the same |
| artifact which is deployed only once. |
| build Builds the Snowpark project as a `.zip` archive |
| that can be used by `deploy` command. The archive |
| is built using only the `src` directory specified |
| in the project file. |
| deploy Deploys procedures and functions defined in |
| project. Deploying the project alters all objects |
| defined in it. By default, if any of the objects |
| exist already the commands will fail unless |
| `--replace` flag is provided. All deployed objects |
| use the same artifact which is deployed only once. |
| describe Provides description of a procedure or function. |
| drop Drop procedure or function. |
| execute Executes a procedure or function in a specified environment. |
| init Initializes this directory with a sample set of files for |
| creating a Snowpark project. |
| execute Executes a procedure or function in a specified |
| environment. |
| init Initializes this directory with a sample set of (deprecated) |
| files for creating a Snowpark project.This command |
| is deprecated and will be removed soon.Please use |
| 'snow init' instead |
| list Lists all available procedures or functions. |
| package Manages custom Python packages for Snowpark |
+------------------------------------------------------------------------------+
Expand Down Expand Up @@ -8559,16 +8577,20 @@
| --help -h Show this message and exit. |
+------------------------------------------------------------------------------+
+- Commands -------------------------------------------------------------------+
| deploy Deploys a Streamlit app defined in the project definition file |
| (snowflake.yml). By default, the command uploads environment.yml |
| and any other pages or folders, if present. If you don’t specify |
| a stage name, the `streamlit` stage is used. If the specified |
| stage does not exist, the command creates it. |
| deploy Deploys a Streamlit app defined in the project |
| definition file (snowflake.yml). By default, the |
| command uploads environment.yml and any other |
| pages or folders, if present. If you don’t specify |
| a stage name, the `streamlit` stage is used. If |
| the specified stage does not exist, the command |
| creates it. |
| describe Provides description of streamlit. |
| drop Drops streamlit with given name. |
| get-url Returns a URL to the specified Streamlit app |
| init Initializes this directory with a sample set of files for |
| creating a Streamlit app project. |
| init Initializes this directory with a sample set of (deprecated) |
| files for creating a Streamlit app project.This |
| command is deprecated and will be removed |
| soon.Please use 'snow init' instead |
| list Lists all available streamlits. |
| share Shares a Streamlit app with another role. |
+------------------------------------------------------------------------------+
Expand Down
5 changes: 4 additions & 1 deletion tests/test_project_initialisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def test_adds_init_command(mock_copy):
add_init_command(app, "my_project_type", template="my_template")
result = runner.invoke(app.create_instance(), ["my_dir"])
assert result.exit_code == 0
assert result.output == "Initialized the new project in my_dir/\n"
assert (
result.output
== "DeprecationWarning: The command 'init' is deprecated.\nInitialized the new project in my_dir/\n"
)

mock_copy.assert_called_once_with("my_dir", dirs_exist_ok=True)

0 comments on commit a29aefb

Please sign in to comment.