Skip to content

Commit

Permalink
Merge branch 'main' into add-pattern-to-snow-stage-list
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pczajka authored Mar 14, 2024
2 parents b5a13c7 + 224f01b commit 204b483
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
1 change: 0 additions & 1 deletion .snyk/req-auto-generated.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 2 additions & 4 deletions src/snowflake/cli/plugins/spcs/services/manager.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions tests/spcs/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions tests_integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 204b483

Please sign in to comment.