From b9f4afc86d2a14ebff200069c1ec763d6969c6ab Mon Sep 17 00:00:00 2001 From: Jorge Vasquez Rojas Date: Tue, 17 Sep 2024 03:34:22 -0600 Subject: [PATCH 1/5] Adding experimental integration test for large lobs feature (#1534) Add test with large lobs in memory enabled --- tests_integration/test_sql.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests_integration/test_sql.py b/tests_integration/test_sql.py index d2fb80e14b..4d02b6d547 100644 --- a/tests_integration/test_sql.py +++ b/tests_integration/test_sql.py @@ -17,6 +17,8 @@ import pytest +from tests_integration.testing_utils import ObjectNameProvider + @pytest.mark.integration def test_query_parameter(runner, snowflake_session): @@ -158,3 +160,21 @@ def test_sql_execute_query_prints_query(runner): assert result.exit_code == 0, result.output assert "select 1 as A" in result.output assert "select 2 as B" in result.output + + +@pytest.mark.integration_experimental +def test_sql_large_lobs_in_memory_tables(runner): + table_name = ObjectNameProvider( + "table_with_default" + ).create_and_get_next_object_name() + result = runner.invoke_with_connection( + [ + "sql", + "-q", + f"create or replace table {table_name}(x int, v text default x::varchar);" + f"select get_ddl('table', '{table_name}');" + f"drop table {table_name};", + ] + ) + + assert "VARCHAR(134217728)" in result.output From c17fde7d08c90e07419328507601d12fe44c0706 Mon Sep 17 00:00:00 2001 From: Adam Stus Date: Tue, 17 Sep 2024 12:24:35 +0200 Subject: [PATCH 2/5] Bump version to 3.0.0rc2 (#1582) --- src/snowflake/cli/__about__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/snowflake/cli/__about__.py b/src/snowflake/cli/__about__.py index c3de55e6a7..991af05d92 100644 --- a/src/snowflake/cli/__about__.py +++ b/src/snowflake/cli/__about__.py @@ -14,4 +14,4 @@ from __future__ import annotations -VERSION = "3.0.0.dev0" +VERSION = "3.0.0rc2" From cc61401094aa36ca5a437bc611645748b44f0a31 Mon Sep 17 00:00:00 2001 From: Francois Campbell Date: Tue, 17 Sep 2024 11:05:52 -0400 Subject: [PATCH 3/5] Add `snow ws version list` command (#1574) Adds `snow ws version list` command to be invoked on an app package entity. Behaves the same as `snow app version list`. --- .../cli/_plugins/nativeapp/run_processor.py | 19 +- .../cli/_plugins/workspace/commands.py | 34 +- .../cli/_plugins/workspace/plugin_spec.py | 2 +- .../entities/application_package_entity.py | 27 +- src/snowflake/cli/api/entities/common.py | 2 + .../test_application_package_entity.py | 23 + .../nativeapp/__snapshots__/test_version.ambr | 62 ++- tests_integration/nativeapp/test_version.py | 442 +++++++++--------- 8 files changed, 356 insertions(+), 255 deletions(-) diff --git a/src/snowflake/cli/_plugins/nativeapp/run_processor.py b/src/snowflake/cli/_plugins/nativeapp/run_processor.py index 3344dbe6f3..4cd1ce8fae 100644 --- a/src/snowflake/cli/_plugins/nativeapp/run_processor.py +++ b/src/snowflake/cli/_plugins/nativeapp/run_processor.py @@ -31,6 +31,9 @@ from snowflake.cli.api.entities.application_entity import ( ApplicationEntity, ) +from snowflake.cli.api.entities.application_package_entity import ( + ApplicationPackageEntity, +) from snowflake.cli.api.entities.utils import ( generic_sql_error_handler, ) @@ -38,7 +41,6 @@ APPLICATION_NO_LONGER_AVAILABLE, APPLICATION_OWNS_EXTERNAL_OBJECTS, ) -from snowflake.cli.api.exceptions import SnowflakeSQLExecutionError from snowflake.cli.api.project.schemas.native_app.native_app import NativeApp from snowflake.connector import ProgrammingError from snowflake.connector.cursor import SnowflakeCursor @@ -49,18 +51,9 @@ def __init__(self, project_definition: NativeApp, project_root: Path): super().__init__(project_definition, project_root) def get_all_existing_versions(self) -> SnowflakeCursor: - """ - Get all existing versions, if defined, for an application package. - It executes a 'show versions in application package' query and returns all the results. - """ - with self.use_role(self.package_role): - show_obj_query = f"show versions in application package {self.package_name}" - show_obj_cursor = self._execute_query(show_obj_query) - - if show_obj_cursor.rowcount is None: - raise SnowflakeSQLExecutionError(show_obj_query) - - return show_obj_cursor + return ApplicationPackageEntity.version_list( + self.package_name, self.package_role + ) def get_existing_version_info(self, version: str) -> Optional[dict]: return ApplicationEntity.get_existing_version_info( diff --git a/src/snowflake/cli/_plugins/workspace/commands.py b/src/snowflake/cli/_plugins/workspace/commands.py index 2b2625a0eb..3d45f0cc68 100644 --- a/src/snowflake/cli/_plugins/workspace/commands.py +++ b/src/snowflake/cli/_plugins/workspace/commands.py @@ -30,17 +30,17 @@ from snowflake.cli._plugins.workspace.manager import WorkspaceManager from snowflake.cli.api.cli_global_context import get_cli_context from snowflake.cli.api.commands.decorators import with_project_definition -from snowflake.cli.api.commands.snow_typer import SnowTyper +from snowflake.cli.api.commands.snow_typer import SnowTyperFactory from snowflake.cli.api.entities.common import EntityActions from snowflake.cli.api.exceptions import IncompatibleParametersError -from snowflake.cli.api.output.types import MessageResult +from snowflake.cli.api.output.types import MessageResult, QueryResult from snowflake.cli.api.project.definition_conversion import ( convert_project_definition_to_v2, ) from snowflake.cli.api.project.definition_manager import DefinitionManager from snowflake.cli.api.secure_path import SecurePath -ws = SnowTyper( +ws = SnowTyperFactory( name="ws", help="Deploy and interact with snowflake.yml-based entities.", ) @@ -224,3 +224,31 @@ def validate( entity_id, EntityActions.VALIDATE, ) + + +version = SnowTyperFactory( + name="version", + help="Manages versions for project entities.", +) +ws.add_typer(version) + + +@version.command(name="list", requires_connection=True, hidden=True) +@with_project_definition() +def version_list( + entity_id: str = typer.Option( + help="The ID of the entity you want to list versions for.", + ), + **options, +): + """Lists the versions of the specified entity.""" + cli_context = get_cli_context() + ws = WorkspaceManager( + project_definition=cli_context.project_definition, + project_root=cli_context.project_root, + ) + cursor = ws.perform_action( + entity_id, + EntityActions.VERSION_LIST, + ) + return QueryResult(cursor) diff --git a/src/snowflake/cli/_plugins/workspace/plugin_spec.py b/src/snowflake/cli/_plugins/workspace/plugin_spec.py index 67d14188f5..54a7746725 100644 --- a/src/snowflake/cli/_plugins/workspace/plugin_spec.py +++ b/src/snowflake/cli/_plugins/workspace/plugin_spec.py @@ -26,5 +26,5 @@ def command_spec(): return CommandSpec( parent_command_path=SNOWCLI_ROOT_COMMAND_PATH, command_type=CommandType.COMMAND_GROUP, - typer_instance=commands.ws, + typer_instance=commands.ws.create_instance(), ) diff --git a/src/snowflake/cli/api/entities/application_package_entity.py b/src/snowflake/cli/api/entities/application_package_entity.py index 26a8430610..c81b87b9e5 100644 --- a/src/snowflake/cli/api/entities/application_package_entity.py +++ b/src/snowflake/cli/api/entities/application_package_entity.py @@ -55,7 +55,7 @@ get_basic_jinja_env, ) from snowflake.connector import ProgrammingError -from snowflake.connector.cursor import DictCursor +from snowflake.connector.cursor import DictCursor, SnowflakeCursor class ApplicationPackageEntity(EntityBase[ApplicationPackageEntityModel]): @@ -155,6 +155,15 @@ def deploy_to_scratch_stage_fn(): ) ctx.console.message("Setup script is valid") + def action_version_list( + self, ctx: ActionContext, *args, **kwargs + ) -> SnowflakeCursor: + model = self._entity_model + return self.version_list( + package_name=model.fqn.identifier, + package_role=(model.meta and model.meta.role) or ctx.default_role, + ) + @staticmethod def bundle( project_root: Path, @@ -266,6 +275,22 @@ def deploy( return diff + @staticmethod + def version_list(package_name: str, package_role: str) -> SnowflakeCursor: + """ + Get all existing versions, if defined, for an application package. + It executes a 'show versions in application package' query and returns all the results. + """ + sql_executor = get_sql_executor() + with sql_executor.use_role(package_role): + show_obj_query = f"show versions in application package {package_name}" + show_obj_cursor = sql_executor.execute_query(show_obj_query) + + if show_obj_cursor.rowcount is None: + raise SnowflakeSQLExecutionError(show_obj_query) + + return show_obj_cursor + @staticmethod def get_existing_app_pkg_info( package_name: str, diff --git a/src/snowflake/cli/api/entities/common.py b/src/snowflake/cli/api/entities/common.py index 7dbbd238b3..a05fe3f3c0 100644 --- a/src/snowflake/cli/api/entities/common.py +++ b/src/snowflake/cli/api/entities/common.py @@ -11,6 +11,8 @@ class EntityActions(str, Enum): DROP = "action_drop" VALIDATE = "action_validate" + VERSION_LIST = "action_version_list" + T = TypeVar("T") diff --git a/tests/workspace/test_application_package_entity.py b/tests/workspace/test_application_package_entity.py index 131e8c79cc..da86b24bad 100644 --- a/tests/workspace/test_application_package_entity.py +++ b/tests/workspace/test_application_package_entity.py @@ -163,3 +163,26 @@ def test_deploy( package_warehouse="wh", ) assert mock_execute.mock_calls == expected + + +@mock.patch(SQL_EXECUTOR_EXECUTE) +def test_version_list(mock_execute, mock_cursor): + package_role = "package_role" + package_name = "test_pkg" + side_effects, expected = mock_execute_helper( + [ + ( + mock_cursor([{"CURRENT_ROLE()": "old_role"}], []), + mock.call("select current_role()", cursor_class=DictCursor), + ), + (None, mock.call(f"use role {package_role}")), + ( + mock_cursor([], []), + mock.call(f"show versions in application package {package_name}"), + ), + (None, mock.call("use role old_role")), + ] + ) + mock_execute.side_effect = side_effects + ApplicationPackageEntity.version_list(package_name, package_role) + assert mock_execute.mock_calls == expected diff --git a/tests_integration/nativeapp/__snapshots__/test_version.ambr b/tests_integration/nativeapp/__snapshots__/test_version.ambr index 104bfefae5..1c36118341 100644 --- a/tests_integration/nativeapp/__snapshots__/test_version.ambr +++ b/tests_integration/nativeapp/__snapshots__/test_version.ambr @@ -1,52 +1,78 @@ # serializer version: 1 -# name: test_nativeapp_version_create_package_no_magic_comment[integration] +# name: test_nativeapp_version_create_package_no_magic_comment[app version list-napp_init_v1] list([ dict({ - 'comment': 'Default version used for development. Override for actual deployment.', + 'comment': None, 'dropped_on': None, - 'label': 'Dev Version', - 'log_level': 'INFO', + 'label': None, + 'log_level': 'OFF', 'patch': 0, 'review_status': 'NOT_REVIEWED', 'state': 'READY', - 'trace_level': 'ALWAYS', + 'trace_level': 'OFF', 'version': 'V1', }), dict({ - 'comment': 'Default version used for development. Override for actual deployment.', + 'comment': None, 'dropped_on': None, - 'label': 'Dev Version', - 'log_level': 'INFO', + 'label': None, + 'log_level': 'OFF', 'patch': 1, 'review_status': 'NOT_REVIEWED', 'state': 'READY', - 'trace_level': 'ALWAYS', + 'trace_level': 'OFF', 'version': 'V1', }), ]) # --- -# name: test_nativeapp_version_create_package_no_magic_comment[integration_v2] +# name: test_nativeapp_version_create_package_no_magic_comment[app version list-napp_init_v2] list([ dict({ - 'comment': 'Default version used for development. Override for actual deployment.', + 'comment': None, 'dropped_on': None, - 'label': 'Dev Version', - 'log_level': 'INFO', + 'label': None, + 'log_level': 'OFF', 'patch': 0, 'review_status': 'NOT_REVIEWED', 'state': 'READY', - 'trace_level': 'ALWAYS', + 'trace_level': 'OFF', 'version': 'V1', }), dict({ - 'comment': 'Default version used for development. Override for actual deployment.', + 'comment': None, 'dropped_on': None, - 'label': 'Dev Version', - 'log_level': 'INFO', + 'label': None, + 'log_level': 'OFF', 'patch': 1, 'review_status': 'NOT_REVIEWED', 'state': 'READY', - 'trace_level': 'ALWAYS', + 'trace_level': 'OFF', + 'version': 'V1', + }), + ]) +# --- +# name: test_nativeapp_version_create_package_no_magic_comment[ws version list --entity-id=pkg-napp_init_v2] + list([ + dict({ + 'comment': None, + 'dropped_on': None, + 'label': None, + 'log_level': 'OFF', + 'patch': 0, + 'review_status': 'NOT_REVIEWED', + 'state': 'READY', + 'trace_level': 'OFF', + 'version': 'V1', + }), + dict({ + 'comment': None, + 'dropped_on': None, + 'label': None, + 'log_level': 'OFF', + 'patch': 1, + 'review_status': 'NOT_REVIEWED', + 'state': 'READY', + 'trace_level': 'OFF', 'version': 'V1', }), ]) diff --git a/tests_integration/nativeapp/test_version.py b/tests_integration/nativeapp/test_version.py index aa198cf50d..47ebad2916 100644 --- a/tests_integration/nativeapp/test_version.py +++ b/tests_integration/nativeapp/test_version.py @@ -11,166 +11,172 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from shlex import split from tests.project.fixtures import * -from tests_integration.test_utils import ( - pushd, - contains_row_with, - not_contains_row_with, - row_from_snowflake_session, -) +from tests_integration.test_utils import contains_row_with, row_from_snowflake_session # Tests a simple flow of an existing project, executing snow app version create, drop and teardown, all with distribution=internal @pytest.mark.integration @pytest.mark.parametrize( - "project_definition_files", ["integration", "integration_v2"], indirect=True + "list_command,test_project", + [ + ["app version list", "napp_init_v1"], + ["app version list", "napp_init_v2"], + ["ws version list --entity-id=pkg", "napp_init_v2"], + ], ) def test_nativeapp_version_create_and_drop( runner, snowflake_session, default_username, resource_suffix, - nativeapp_teardown, - project_definition_files: List[Path], + nativeapp_project_directory, + list_command, + test_project, ): - project_name = "integration" - project_dir = project_definition_files[0].parent - with pushd(project_dir): + project_name = "myapp" + with nativeapp_project_directory(test_project): result_create = runner.invoke_with_connection_json( ["app", "version", "create", "v1", "--force", "--skip-git-check"] ) assert result_create.exit_code == 0 - with nativeapp_teardown(): - # package exist - package_name = ( - f"{project_name}_pkg_{default_username}{resource_suffix}".upper() - ) - assert contains_row_with( - row_from_snowflake_session( - snowflake_session.execute_string( - f"show application packages like '{package_name}'", - ) - ), - dict(name=package_name), - ) + # package exist + package_name = f"{project_name}_pkg_{default_username}{resource_suffix}".upper() + assert contains_row_with( + row_from_snowflake_session( + snowflake_session.execute_string( + f"show application packages like '{package_name}'", + ) + ), + dict(name=package_name), + ) - # app package contains version v1 - expect = snowflake_session.execute_string( - f"show versions in application package {package_name}" - ) - actual = runner.invoke_with_connection_json(["app", "version", "list"]) - assert actual.json == row_from_snowflake_session(expect) + # app package contains version v1 + expect = snowflake_session.execute_string( + f"show versions in application package {package_name}" + ) + actual = runner.invoke_with_connection_json(split(list_command)) + assert actual.json == row_from_snowflake_session(expect) - result_drop = runner.invoke_with_connection_json( - ["app", "version", "drop", "v1", "--force"] - ) - assert result_drop.exit_code == 0 - actual = runner.invoke_with_connection_json(["app", "version", "list"]) - assert len(actual.json) == 0 + result_drop = runner.invoke_with_connection_json( + ["app", "version", "drop", "v1", "--force"] + ) + assert result_drop.exit_code == 0 + actual = runner.invoke_with_connection_json(split(list_command)) + assert len(actual.json) == 0 # Tests upgrading an app from an existing loose files installation to versioned installation. @pytest.mark.integration @pytest.mark.parametrize( - "project_definition_files", ["integration", "integration_v2"], indirect=True + "list_command,test_project", + [ + ["app version list", "napp_init_v1"], + ["app version list", "napp_init_v2"], + ["ws version list --entity-id=pkg", "napp_init_v2"], + ], ) def test_nativeapp_upgrade( runner, snowflake_session, default_username, resource_suffix, - nativeapp_teardown, - project_definition_files: List[Path], + nativeapp_project_directory, + list_command, + test_project, ): - project_name = "integration" - project_dir = project_definition_files[0].parent - with pushd(project_dir): + project_name = "myapp" + with nativeapp_project_directory(test_project): runner.invoke_with_connection_json(["app", "run"]) runner.invoke_with_connection_json( ["app", "version", "create", "v1", "--force", "--skip-git-check"] ) - with nativeapp_teardown(): - # package exist - package_name = ( - f"{project_name}_pkg_{default_username}{resource_suffix}".upper() - ) - app_name = f"{project_name}_{default_username}{resource_suffix}".upper() - # app package contains version v1 - expect = snowflake_session.execute_string( - f"show versions in application package {package_name}" - ) - actual = runner.invoke_with_connection_json(["app", "version", "list"]) - assert actual.json == row_from_snowflake_session(expect) + # package exist + package_name = f"{project_name}_pkg_{default_username}{resource_suffix}".upper() + app_name = f"{project_name}_{default_username}{resource_suffix}".upper() + # app package contains version v1 + expect = snowflake_session.execute_string( + f"show versions in application package {package_name}" + ) + actual = runner.invoke_with_connection_json(split(list_command)) + assert actual.json == row_from_snowflake_session(expect) - runner.invoke_with_connection_json( - ["app", "run", "--version", "v1", "--force"] - ) + runner.invoke_with_connection_json(["app", "run", "--version", "v1", "--force"]) - expect = row_from_snowflake_session( - snowflake_session.execute_string(f"desc application {app_name}") - ) - assert contains_row_with(expect, {"property": "name", "value": app_name}) - assert contains_row_with(expect, {"property": "version", "value": "V1"}) - assert contains_row_with(expect, {"property": "patch", "value": "0"}) + expect = row_from_snowflake_session( + snowflake_session.execute_string(f"desc application {app_name}") + ) + assert contains_row_with(expect, {"property": "name", "value": app_name}) + assert contains_row_with(expect, {"property": "version", "value": "V1"}) + assert contains_row_with(expect, {"property": "patch", "value": "0"}) - runner.invoke_with_connection_json( - ["app", "version", "drop", "v1", "--force"] - ) + runner.invoke_with_connection_json(["app", "version", "drop", "v1", "--force"]) # Make sure we can create 3+ patches on the same version @pytest.mark.integration -@pytest.mark.parametrize("project_definition_files", ["integration"], indirect=True) +@pytest.mark.parametrize( + "list_command,test_project", + [ + ["app version list", "napp_init_v1"], + ["app version list", "napp_init_v2"], + ["ws version list --entity-id=pkg", "napp_init_v2"], + ], +) def test_nativeapp_version_create_3_patches( runner, snowflake_session, default_username, resource_suffix, nativeapp_teardown, - project_definition_files: List[Path], + nativeapp_project_directory, + list_command, + test_project, ): - project_name = "integration" - project_dir = project_definition_files[0].parent - with pushd(project_dir): - with nativeapp_teardown(): - package_name = ( - f"{project_name}_pkg_{default_username}{resource_suffix}".upper() - ) - - # create three patches (deploys too) - for _ in range(3): - result = runner.invoke_with_connection_json( - ["app", "version", "create", "v1", "--force", "--skip-git-check"] - ) - assert result.exit_code == 0 + project_name = "myapp" + with nativeapp_project_directory(test_project): + package_name = f"{project_name}_pkg_{default_username}{resource_suffix}".upper() - # app package contains 3 patches for version v1 - expect = row_from_snowflake_session( - snowflake_session.execute_string( - f"show versions in application package {package_name}" - ) + # create three patches (deploys too) + for _ in range(3): + result = runner.invoke_with_connection_json( + ["app", "version", "create", "v1", "--force", "--skip-git-check"] ) - assert contains_row_with(expect, {"version": "V1", "patch": 0}) - assert contains_row_with(expect, {"version": "V1", "patch": 1}) - assert contains_row_with(expect, {"version": "V1", "patch": 2}) + assert result.exit_code == 0 - # drop the version - result_drop = runner.invoke_with_connection_json( - ["app", "version", "drop", "v1", "--force"] + # app package contains 3 patches for version v1 + expect = row_from_snowflake_session( + snowflake_session.execute_string( + f"show versions in application package {package_name}" ) - assert result_drop.exit_code == 0 + ) + assert contains_row_with(expect, {"version": "V1", "patch": 0}) + assert contains_row_with(expect, {"version": "V1", "patch": 1}) + assert contains_row_with(expect, {"version": "V1", "patch": 2}) + + # drop the version + result_drop = runner.invoke_with_connection_json( + ["app", "version", "drop", "v1", "--force"] + ) + assert result_drop.exit_code == 0 - # ensure there are no versions now - actual = runner.invoke_with_connection_json(["app", "version", "list"]) - assert len(actual.json) == 0 + # ensure there are no versions now + actual = runner.invoke_with_connection_json(split(list_command)) + assert len(actual.json) == 0 @pytest.mark.integration @pytest.mark.parametrize( - "project_definition_files", ["integration", "integration_v2"], indirect=True + "list_command,test_project", + [ + ["app version list", "napp_init_v1"], + ["app version list", "napp_init_v2"], + ["ws version list --entity-id=pkg", "napp_init_v2"], + ], ) def test_nativeapp_version_create_patch_is_integer( runner, @@ -178,72 +184,72 @@ def test_nativeapp_version_create_patch_is_integer( default_username, resource_suffix, nativeapp_teardown, - project_definition_files: List[Path], + nativeapp_project_directory, + list_command, + test_project, ): - project_name = "integration" - project_dir = project_definition_files[0].parent - with pushd(project_dir): - with nativeapp_teardown(): - package_name = ( - f"{project_name}_pkg_{default_username}{resource_suffix}".upper() - ) - - # create initial version - result = runner.invoke_with_connection_json( - ["app", "version", "create", "v1", "--force", "--skip-git-check"] - ) - assert result.exit_code == 0 - - # create non-integer patch - result = runner.invoke_with_connection_json( - [ - "app", - "version", - "create", - "v1", - "--force", - "--skip-git-check", - "--patch", - "foo", - ], - ) - assert result.exit_code == 2 - assert ( - "Invalid value for '--patch': 'foo' is not a valid integer." - in result.output - ) + with nativeapp_project_directory(test_project): + # create initial version + result = runner.invoke_with_connection_json( + ["app", "version", "create", "v1", "--force", "--skip-git-check"] + ) + assert result.exit_code == 0 + + # create non-integer patch + result = runner.invoke_with_connection_json( + [ + "app", + "version", + "create", + "v1", + "--force", + "--skip-git-check", + "--patch", + "foo", + ], + ) + assert result.exit_code == 2 + assert ( + "Invalid value for '--patch': 'foo' is not a valid integer." + in result.output + ) - # create integer patch - result = runner.invoke_with_connection_json( - [ - "app", - "version", - "create", - "v1", - "--force", - "--skip-git-check", - "--patch", - "1", - ], - ) - assert result.exit_code == 0 + # create integer patch + result = runner.invoke_with_connection_json( + [ + "app", + "version", + "create", + "v1", + "--force", + "--skip-git-check", + "--patch", + "1", + ], + ) + assert result.exit_code == 0 - # drop the version - result_drop = runner.invoke_with_connection_json( - ["app", "version", "drop", "v1", "--force"] - ) - assert result_drop.exit_code == 0 + # drop the version + result_drop = runner.invoke_with_connection_json( + ["app", "version", "drop", "v1", "--force"] + ) + assert result_drop.exit_code == 0 - # ensure there are no versions now - actual = runner.invoke_with_connection_json(["app", "version", "list"]) - assert len(actual.json) == 0 + # ensure there are no versions now + actual = runner.invoke_with_connection_json(split(list_command)) + assert len(actual.json) == 0 # Tests creating a version for a package that was not created by the CLI # (doesn't have the magic CLI comment) @pytest.mark.integration @pytest.mark.parametrize( - "project_definition_files", ["integration", "integration_v2"], indirect=True + "list_command,test_project", + [ + ["app version list", "napp_init_v1"], + ["app version list", "napp_init_v2"], + ["ws version list --entity-id=pkg", "napp_init_v2"], + ], ) def test_nativeapp_version_create_package_no_magic_comment( runner, @@ -252,76 +258,74 @@ def test_nativeapp_version_create_package_no_magic_comment( resource_suffix, nativeapp_teardown, snapshot, - project_definition_files: List[Path], + nativeapp_project_directory, + list_command, + test_project, ): - project_name = "integration" - project_dir = project_definition_files[0].parent - with pushd(project_dir): + project_name = "myapp" + with nativeapp_project_directory(test_project): result_create_abort = runner.invoke_with_connection_json(["app", "deploy"]) assert result_create_abort.exit_code == 0 - with nativeapp_teardown(): - # package exist - package_name = ( - f"{project_name}_pkg_{default_username}{resource_suffix}".upper() - ) - assert contains_row_with( - row_from_snowflake_session( - snowflake_session.execute_string( - f"show application packages like '{package_name}'", - ) - ), - dict(name=package_name), - ) + # package exist + package_name = f"{project_name}_pkg_{default_username}{resource_suffix}".upper() + assert contains_row_with( + row_from_snowflake_session( + snowflake_session.execute_string( + f"show application packages like '{package_name}'", + ) + ), + dict(name=package_name), + ) - assert contains_row_with( - row_from_snowflake_session( - snowflake_session.execute_string( - f"alter application package {package_name} set comment = 'not the magic comment'" - ) - ), - dict(status="Statement executed successfully."), - ) + assert contains_row_with( + row_from_snowflake_session( + snowflake_session.execute_string( + f"alter application package {package_name} set comment = 'not the magic comment'" + ) + ), + dict(status="Statement executed successfully."), + ) - # say no - result_create_abort = runner.invoke_with_connection( - ["app", "version", "create", "v1", "--skip-git-check", "--interactive"], - input="n\n", - ) - assert result_create_abort.exit_code == 1 - assert ( - f"An Application Package {package_name} already exists in account " - "that may have been created without Snowflake CLI.".upper() - in result_create_abort.output.upper() - ) - assert "Aborted." in result_create_abort.output + # say no + result_create_abort = runner.invoke_with_connection( + ["app", "version", "create", "v1", "--skip-git-check", "--interactive"], + input="n\n", + ) + assert result_create_abort.exit_code == 1 + assert ( + f"An Application Package {package_name} already exists in account " + "that may have been created without Snowflake CLI.".upper() + in result_create_abort.output.upper() + ) + assert "Aborted." in result_create_abort.output - # say yes - result_create_yes = runner.invoke_with_connection( - ["app", "version", "create", "v1", "--skip-git-check", "--interactive"], - input="y\n", - ) - assert result_create_yes.exit_code == 0 - assert ( - f"An Application Package {package_name} already exists in account " - "that may have been created without Snowflake CLI.".upper() - in result_create_yes.output.upper() - ) + # say yes + result_create_yes = runner.invoke_with_connection( + ["app", "version", "create", "v1", "--skip-git-check", "--interactive"], + input="y\n", + ) + assert result_create_yes.exit_code == 0 + assert ( + f"An Application Package {package_name} already exists in account " + "that may have been created without Snowflake CLI.".upper() + in result_create_yes.output.upper() + ) - # force - result_create_force = runner.invoke_with_connection( - ["app", "version", "create", "v1", "--force", "--skip-git-check"] - ) - assert result_create_force.exit_code == 0 - assert ( - f"An Application Package {package_name} already exists in account " - "that may have been created without Snowflake CLI.".upper() - in result_create_force.output.upper() - ) + # force + result_create_force = runner.invoke_with_connection( + ["app", "version", "create", "v1", "--force", "--skip-git-check"] + ) + assert result_create_force.exit_code == 0 + assert ( + f"An Application Package {package_name} already exists in account " + "that may have been created without Snowflake CLI.".upper() + in result_create_force.output.upper() + ) - # app package contains version v1 with 2 patches - actual = runner.invoke_with_connection_json(["app", "version", "list"]) - for row in actual.json: - # Remove date field - row.pop("created_on", None) - assert actual.json == snapshot + # app package contains version v1 with 2 patches + actual = runner.invoke_with_connection_json(split(list_command)) + for row in actual.json: + # Remove date field + row.pop("created_on", None) + assert actual.json == snapshot From f7fdf66098b5ed52c726fc8e2f1459e6885f1e74 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Sep 2024 11:47:29 +0200 Subject: [PATCH 4/5] Bump rich from 13.8.0 to 13.8.1 (#1579) Bumps [rich](https://github.com/Textualize/rich) from 13.8.0 to 13.8.1. - [Release notes](https://github.com/Textualize/rich/releases) - [Changelog](https://github.com/Textualize/rich/blob/master/CHANGELOG.md) - [Commits](https://github.com/Textualize/rich/compare/v13.8.0...v13.8.1) --- updated-dependencies: - dependency-name: rich dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- snyk/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b3cb6bc11a..5b5ced1e51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ "pluggy==1.5.0", "PyYAML==6.0.2", "packaging", - "rich==13.8.0", + "rich==13.8.1", "requests==2.32.3", "requirements-parser==0.11.0", "setuptools==74.1.2", diff --git a/snyk/requirements.txt b/snyk/requirements.txt index a6364e6bc1..5245fd1d6a 100644 --- a/snyk/requirements.txt +++ b/snyk/requirements.txt @@ -2,7 +2,7 @@ jinja2==3.1.4 pluggy==1.5.0 PyYAML==6.0.2 packaging -rich==13.8.0 +rich==13.8.1 requests==2.32.3 requirements-parser==0.11.0 setuptools==74.1.2 From 486e3dff95b9096570b3d8da381d63801cc055e5 Mon Sep 17 00:00:00 2001 From: Tomasz Urbaszek Date: Wed, 18 Sep 2024 12:25:14 +0200 Subject: [PATCH 5/5] Bump snowflake.core to 0.12.1 (#1587) --- pyproject.toml | 2 +- snyk/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5b5ced1e51..c5af7b3fff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ "requests==2.32.3", "requirements-parser==0.11.0", "setuptools==74.1.2", - 'snowflake.core==0.8.0; python_version < "3.12"', + 'snowflake.core==0.12.1; python_version < "3.12"', "snowflake-connector-python[secure-local-storage]==3.12.1", 'snowflake-snowpark-python>=1.15.0;python_version < "3.12"', "tomlkit==0.13.2", diff --git a/snyk/requirements.txt b/snyk/requirements.txt index 5245fd1d6a..fef6d3e831 100644 --- a/snyk/requirements.txt +++ b/snyk/requirements.txt @@ -6,7 +6,7 @@ rich==13.8.1 requests==2.32.3 requirements-parser==0.11.0 setuptools==74.1.2 -snowflake.core==0.8.0; python_version < "3.12" +snowflake.core==0.12.1; python_version < "3.12" snowflake-connector-python[secure-local-storage]==3.12.1 snowflake-snowpark-python>=1.15.0;python_version < "3.12" tomlkit==0.13.2