diff --git a/.snyk/req-auto-generated.txt b/.snyk/req-auto-generated.txt index 5e8953bb24..c3e932688f 100644 --- a/.snyk/req-auto-generated.txt +++ b/.snyk/req-auto-generated.txt @@ -7,7 +7,6 @@ requests==2.31.0 requirements-parser==0.5.0 setuptools==69.1.1 snowflake-connector-python[secure-local-storage]==3.7.1 -strictyaml==1.7.3 tomlkit==0.12.3 typer==0.9.0 urllib3>=1.21.1,<2.3 diff --git a/pyproject.toml b/pyproject.toml index 0716704b4a..81b5f154ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,6 @@ dependencies = [ "requirements-parser==0.5.0", "setuptools==69.1.1", "snowflake-connector-python[secure-local-storage]==3.7.1", - "strictyaml==1.7.3", "tomlkit==0.12.3", "typer==0.9.0", "urllib3>=1.21.1,<2.3", diff --git a/src/snowflake/cli/plugins/spcs/services/manager.py b/src/snowflake/cli/plugins/spcs/services/manager.py index 4f16df4ca4..b445ed7349 100644 --- a/src/snowflake/cli/plugins/spcs/services/manager.py +++ b/src/snowflake/cli/plugins/spcs/services/manager.py @@ -1,6 +1,8 @@ +import json from pathlib import Path from typing import List, Optional +import yaml from snowflake.cli.api.constants import DEFAULT_SIZE_LIMIT_MB, ObjectType from snowflake.cli.api.secure_path import SecurePath from snowflake.cli.api.sql_execution import SqlExecutionMixin @@ -69,10 +71,6 @@ def create( def _read_yaml(self, path: Path) -> str: # TODO(aivanou): Add validation towards schema - import json - - import yaml - with SecurePath(path).open("r", read_file_limit_mb=DEFAULT_SIZE_LIMIT_MB) as fh: data = yaml.safe_load(fh) return json.dumps(data) diff --git a/tests/spcs/test_services.py b/tests/spcs/test_services.py index e7ee202e75..b0e4a82719 100644 --- a/tests/spcs/test_services.py +++ b/tests/spcs/test_services.py @@ -4,7 +4,6 @@ from unittest.mock import Mock, patch import pytest -import strictyaml from click import ClickException from snowflake.cli.api.constants import ObjectType from snowflake.cli.api.project.util import to_string_literal @@ -13,6 +12,7 @@ from snowflake.cli.plugins.spcs.services.commands import _service_name_callback from snowflake.cli.plugins.spcs.services.manager import ServiceManager from snowflake.connector.cursor import SnowflakeCursor +from yaml import YAMLError from tests.spcs.test_common import SPCS_OBJECT_EXISTS_ERROR @@ -185,9 +185,9 @@ def test_create_service_with_invalid_spec(mock_read_yaml): max_instances = 42 external_access_integrations = query_warehouse = tags = comment = None auto_resume = False - mock_read_yaml.side_effect = strictyaml.YAMLError("Invalid YAML") + mock_read_yaml.side_effect = YAMLError("Invalid YAML") - with pytest.raises(strictyaml.YAMLError): + with pytest.raises(YAMLError): ServiceManager().create( service_name=service_name, compute_pool=compute_pool, diff --git a/tests_integration/conftest.py b/tests_integration/conftest.py index 5ad04ff127..faf02cda0c 100644 --- a/tests_integration/conftest.py +++ b/tests_integration/conftest.py @@ -11,11 +11,11 @@ from typing import Any, Dict, List, Optional import pytest -import strictyaml +import yaml + from snowflake.cli.api.cli_global_context import cli_context_manager from snowflake.cli.api.project.definition import merge_left from snowflake.cli.app.cli_app import app_factory -from strictyaml import as_document from typer import Typer from typer.testing import CliRunner @@ -134,10 +134,11 @@ def _temporary_project_directory( test_data_file = test_root_path / "test_data" / "projects" / project_name shutil.copytree(test_data_file, temporary_working_directory, dirs_exist_ok=True) if merge_project_definition: - project_definition = strictyaml.load(Path("snowflake.yml").read_text()).data + with Path("snowflake.yml").open("r") as fh: + project_definition = yaml.safe_load(fh) merge_left(project_definition, merge_project_definition) with open(Path(temporary_working_directory) / "snowflake.yml", "w") as file: - file.write(as_document(project_definition).as_yaml()) + yaml.dump(project_definition, file) yield temporary_working_directory