Skip to content

Commit

Permalink
Moved native app artifacts logic to common API (#1877)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-bdufour committed Dec 6, 2024
1 parent 251de3e commit e4dc824
Show file tree
Hide file tree
Showing 27 changed files with 2,287 additions and 2,203 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
**/__snapshots__/ @snowflakedb/snowcli @snowflakedb/nade
**/test_data @snowflakedb/snowcli @snowflakedb/nade
**/testing_utils/ @snowflakedb/snowcli @snowflakedb/nade
src/snowflake/cli/api/artifacts/ @snowflakedb/snowcli @snowflakedb/nade
src/snowflake/cli/api/metrics.py @snowflakedb/snowcli @snowflakedb/nade
src/snowflake/cli/api/project/definition_conversion.py @snowflakedb/snowcli @snowflakedb/nade
src/snowflake/cli/api/utils/ @snowflakedb/snowcli @snowflakedb/nade
tests/api/artifacts/ @snowflakedb/snowcli @snowflakedb/nade
tests/api/metrics/ @snowflakedb/snowcli @snowflakedb/nade
tests/api/test_metrics.py @snowflakedb/snowcli @snowflakedb/nade
tests/api/utils/ @snowflakedb/snowcli @snowflakedb/nade
tests_common/__init__.py @snowflakedb/snowcli @snowflakedb/nade
tests_common/conftest.py @snowflakedb/snowcli @snowflakedb/nade
tests_common/deflake.py @snowflakedb/snowcli @snowflakedb/nade
Expand Down
628 changes: 5 additions & 623 deletions src/snowflake/cli/_plugins/nativeapp/artifacts.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import yaml
from click import ClickException
from snowflake.cli._plugins.nativeapp.artifacts import (
BundleMap,
find_manifest_file,
find_setup_script_file,
)
Expand All @@ -37,6 +36,7 @@
execute_script_in_sandbox,
)
from snowflake.cli._plugins.stage.diff import to_stage_path
from snowflake.cli.api.artifacts.bundle_map import BundleMap
from snowflake.cli.api.console import cli_console as cc
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import (
PathMapping,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

from pydantic import ValidationError
from snowflake.cli._plugins.nativeapp.artifacts import (
BundleMap,
find_setup_script_file,
)
from snowflake.cli._plugins.nativeapp.codegen.artifact_processor import (
Expand All @@ -48,6 +47,7 @@
NativeAppExtensionFunction,
)
from snowflake.cli._plugins.stage.diff import to_stage_path
from snowflake.cli.api.artifacts.bundle_map import BundleMap
from snowflake.cli.api.cli_global_context import get_cli_context, span
from snowflake.cli.api.console import cli_console as cc
from snowflake.cli.api.metrics import CLICounterField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
from typing import Any, Optional

import jinja2
from snowflake.cli._plugins.nativeapp.artifacts import BundleMap
from snowflake.cli._plugins.nativeapp.codegen.artifact_processor import (
ArtifactProcessor,
)
from snowflake.cli._plugins.nativeapp.exceptions import InvalidTemplateInFileError
from snowflake.cli.api.artifacts.bundle_map import BundleMap
from snowflake.cli.api.cli_global_context import get_cli_context, span
from snowflake.cli.api.console import cli_console as cc
from snowflake.cli.api.metrics import CLICounterField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from pydantic import Field, field_validator
from snowflake.cli._plugins.connection.util import UIParameter
from snowflake.cli._plugins.nativeapp.artifacts import (
BundleMap,
VersionInfo,
build_bundle,
find_version_info_in_manifest_file,
Expand Down Expand Up @@ -50,6 +49,7 @@
from snowflake.cli._plugins.stage.diff import DiffResult
from snowflake.cli._plugins.stage.manager import StageManager
from snowflake.cli._plugins.workspace.context import ActionContext
from snowflake.cli.api.artifacts.bundle_map import BundleMap
from snowflake.cli.api.cli_global_context import span
from snowflake.cli.api.entities.common import (
EntityBase,
Expand Down
3 changes: 2 additions & 1 deletion src/snowflake/cli/_plugins/snowpark/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import typer
from click import ClickException, UsageError
from snowflake.cli._plugins.nativeapp.artifacts import BundleMap, symlink_or_copy
from snowflake.cli._plugins.object.commands import (
describe as object_describe,
)
Expand Down Expand Up @@ -62,6 +61,8 @@
)
from snowflake.cli._plugins.snowpark.zipper import zip_dir, zip_dir_using_bundle_map
from snowflake.cli._plugins.stage.manager import StageManager
from snowflake.cli.api.artifacts.bundle_map import BundleMap
from snowflake.cli.api.artifacts.utils import symlink_or_copy
from snowflake.cli.api.cli_global_context import (
get_cli_context,
)
Expand Down
2 changes: 1 addition & 1 deletion src/snowflake/cli/_plugins/snowpark/zipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from typing import Dict, List, Literal
from zipfile import ZIP_DEFLATED, ZipFile

from snowflake.cli._plugins.nativeapp.artifacts import BundleMap
from snowflake.cli.api.artifacts.bundle_map import BundleMap
from snowflake.cli.api.console import cli_console

log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/snowflake/cli/_plugins/stage/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pathlib import Path, PurePosixPath
from typing import Collection, Dict, List, Optional, Tuple

from snowflake.cli._plugins.nativeapp.artifacts import BundleMap
from snowflake.cli.api.artifacts.bundle_map import BundleMap
from snowflake.cli.api.exceptions import (
SnowflakeSQLExecutionError,
)
Expand Down
3 changes: 1 addition & 2 deletions src/snowflake/cli/_plugins/stage/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from snowflake.cli.api.secure_path import SecurePath
from snowflake.cli.api.sql_execution import SqlExecutionMixin
from snowflake.cli.api.stage_path import StagePath
from snowflake.cli.api.utils.path_utils import path_resolver
from snowflake.cli.api.utils.path_utils import path_resolver, resolve_without_follow
from snowflake.connector import DictCursor, ProgrammingError
from snowflake.connector.cursor import SnowflakeCursor

Expand Down Expand Up @@ -345,7 +345,6 @@ def put(

@staticmethod
def _symlink_or_copy(source_root: Path, source_file_or_dir: Path, dest_dir: Path):
from snowflake.cli._plugins.nativeapp.artifacts import resolve_without_follow

absolute_src = resolve_without_follow(source_file_or_dir)
dest_path = dest_dir / source_file_or_dir.relative_to(source_root)
Expand Down
2 changes: 1 addition & 1 deletion src/snowflake/cli/_plugins/stage/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Optional

from snowflake.cli._plugins.nativeapp.artifacts import BundleMap
from snowflake.cli._plugins.stage.diff import (
DiffResult,
_to_diff_line,
_to_src_dest_pair,
)
from snowflake.cli.api.artifacts.bundle_map import BundleMap
from snowflake.cli.api.console import cli_console as cc


Expand Down
3 changes: 2 additions & 1 deletion src/snowflake/cli/_plugins/streamlit/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
MissingConnectionRegionError,
make_snowsight_url,
)
from snowflake.cli._plugins.nativeapp.artifacts import BundleMap, symlink_or_copy
from snowflake.cli._plugins.object.manager import ObjectManager
from snowflake.cli._plugins.stage.manager import StageManager
from snowflake.cli._plugins.streamlit.streamlit_entity_model import (
Expand All @@ -33,6 +32,8 @@
from snowflake.cli._plugins.streamlit.streamlit_project_paths import (
StreamlitProjectPaths,
)
from snowflake.cli.api.artifacts.bundle_map import BundleMap
from snowflake.cli.api.artifacts.utils import symlink_or_copy
from snowflake.cli.api.commands.experimental_behaviour import (
experimental_behaviour_enabled,
)
Expand Down
2 changes: 1 addition & 1 deletion src/snowflake/cli/_plugins/workspace/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

import typer
import yaml
from snowflake.cli._plugins.nativeapp.artifacts import BundleMap
from snowflake.cli._plugins.nativeapp.common_flags import (
ForceOption,
InteractiveOption,
ValidateOption,
)
from snowflake.cli._plugins.workspace.manager import WorkspaceManager
from snowflake.cli.api.artifacts.bundle_map import BundleMap
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 SnowTyperFactory
Expand Down
13 changes: 13 additions & 0 deletions src/snowflake/cli/api/artifacts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2024 Snowflake Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
Loading

0 comments on commit e4dc824

Please sign in to comment.