-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into SNOW-1232599-refactor-package-create
- Loading branch information
Showing
12 changed files
with
205 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/snowflake/cli/plugins/snowpark/snowpark_package_paths.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from dataclasses import dataclass | ||
|
||
from snowflake.cli.api.project.schemas.snowpark.snowpark import Snowpark | ||
from snowflake.cli.api.secure_path import SecurePath | ||
|
||
_DEFINED_REQUIREMENTS = "requirements.txt" | ||
_REQUIREMENTS_SNOWFLAKE = "requirements.snowflake.txt" | ||
_REQUIREMENTS_OTHER = "requirements.other.txt" | ||
_PACKAGES_DIR = ".packages" | ||
|
||
|
||
@dataclass | ||
class SnowparkPackagePaths: | ||
source: SecurePath | ||
artifact_file: SecurePath | ||
defined_requirements_file: SecurePath = SecurePath(_DEFINED_REQUIREMENTS) | ||
snowflake_requirements_file: SecurePath = SecurePath(_REQUIREMENTS_SNOWFLAKE) | ||
other_requirements_file: SecurePath = SecurePath(_REQUIREMENTS_OTHER) | ||
downloaded_packages_dir: SecurePath = SecurePath(_PACKAGES_DIR) | ||
|
||
@classmethod | ||
def for_snowpark_project( | ||
cls, project_root: SecurePath, snowpark_project_definition: Snowpark | ||
) -> "SnowparkPackagePaths": | ||
defined_source_path = SecurePath(snowpark_project_definition.src) | ||
return cls( | ||
source=cls._get_snowpark_project_source_absolute_path( | ||
project_root=project_root, | ||
defined_source_path=defined_source_path, | ||
), | ||
artifact_file=cls._get_snowpark_project_artifact_absolute_path( | ||
project_root=project_root, | ||
defined_source_path=defined_source_path, | ||
), | ||
defined_requirements_file=project_root / _DEFINED_REQUIREMENTS, | ||
snowflake_requirements_file=project_root / _REQUIREMENTS_SNOWFLAKE, | ||
other_requirements_file=project_root / _REQUIREMENTS_OTHER, | ||
downloaded_packages_dir=project_root / _PACKAGES_DIR, | ||
) | ||
|
||
@classmethod | ||
def _get_snowpark_project_source_absolute_path( | ||
cls, project_root: SecurePath, defined_source_path: SecurePath | ||
) -> SecurePath: | ||
if defined_source_path.path.is_absolute(): | ||
return defined_source_path | ||
return SecurePath((project_root / defined_source_path.path).path.resolve()) | ||
|
||
@classmethod | ||
def _get_snowpark_project_artifact_absolute_path( | ||
cls, project_root: SecurePath, defined_source_path: SecurePath | ||
) -> SecurePath: | ||
source_path = cls._get_snowpark_project_source_absolute_path( | ||
project_root=project_root, defined_source_path=defined_source_path | ||
) | ||
artifact_file = project_root / (source_path.path.name + ".zip") | ||
return artifact_file |
Oops, something went wrong.