-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Features/unification artifacts #1920
Conversation
85d1c72
to
9cb87b3
Compare
Check if --project in streamlit works on this branch. |
bf62cfb
to
7cd92a3
Compare
2bee685
to
c15cca5
Compare
1ce276f
to
1d6e6c1
Compare
class BundleMap: | ||
""" | ||
Computes the mapping between project directory artifacts (aka source artifacts) to their deploy root location | ||
(aka destination artifact). This information is primarily used when bundling a native applications project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring mentions Native Apps- we probably should make it CLI-wide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
|
||
def __init__(self, *, project_root: Path, deploy_root: Path): | ||
# If a relative path ends up here, it's a bug in the app and can lead to other | ||
# subtle bugs as paths would be resolved relative to the current working directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this docstring just copied from Native App application?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is
Returns the canonical version of a source path, relative to the project root. | ||
""" | ||
absolute_src = self._absolute_src(src) | ||
return absolute_src.relative_to(self._project_root) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if artifact is in a different subtree? Do we handle the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nativeapp code moved to common package.
:param deploy_root: The directory where artifacts should be copied to. Must be an absolute path. | ||
""" | ||
|
||
def __init__(self, *, project_root: Path, deploy_root: Path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sfc-gh-pczajka - shouldn't we use SecurePath everywhere? What's your opinion on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wherever possible - so if it won't cause cascade of changes, I'd change Path to SecurePath.
I remember that refactor to use it everywhere was problematic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will cause cascade :( , there will be a lot of changes in nativeapp code.
|
||
|
||
@dataclass(unsafe_hash=True) | ||
class Artefact: | ||
"""Helper for getting paths related to given artefact.""" | ||
|
||
project_root: Path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this logic to main bundle map files? It seems quite similiar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Artefact logic is only for Snowpark, for me better fits here.
) | ||
for artifact in self._entity_model.artifacts | ||
], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bundle is an action, so it should not return bundle but rather copy the files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
878d715
to
9b6b495
Compare
RELEASE-NOTES.md
Outdated
@@ -41,6 +41,8 @@ | |||
* Add `snow spcs service metrics` command to fetch service metrics: | |||
* Supports filtering by service name, container name, instance ID, and time intervals (`--since`, `--until`). | |||
* Use `--all` to fetch all columns. | |||
* Added support for glob pattern in artifact paths in snowflake.yml for Streamlit. | |||
* Added support for glob pattern in artifact paths in snowflake.yml for Snowpark, requires ENABLE_SNOWPARK_GLOB_SUPPORT feature flag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any change to existing behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Streamlit is changed, Snowpark needs feature flag enabled, otherwise stays the same.
@pytest.mark.parametrize( | ||
"artifact, local_path, stage_path", | ||
[ | ||
("src", bundle_root / "src.zip", "/"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All paths in tests seem to start on src/
. Do we support glob patterns like **/snowpark/*.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, **
introduce more complexity, so I decided to not add that. This PR is huge even without **
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added that to release notes.
1169da8
to
1a17d7e
Compare
@@ -214,6 +222,43 @@ def _standardize(packages: List[str]) -> Set[str]: | |||
return _standardize(old_dependencies) != _standardize(new_dependencies) | |||
|
|||
|
|||
def map_path_mapping_to_artifact( | |||
project_paths: SnowparkProjectPaths, artifacts: List[PathMapping] | |||
) -> List[Artefact]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: would be nice to use one spelling for Artifact throughout the code base :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do this in next PR.
if ( | ||
(isinstance(artifact, str) and glob.has_magic(artifact)) | ||
or (isinstance(artifact, PathMapping) and glob.has_magic(artifact.src)) | ||
) and FeatureFlag.ENABLE_SNOWPARK_GLOB_SUPPORT.is_disabled(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we know if user is intending to use glob pattern or not? If we can know the intent, then what's the purpose of the feature flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I check if artifact path has glob magic
. Feature flag changes build and deploy commands behaviour, they use deploy/bundle/...
directory.
return False | ||
return re.search(r"\.[a-zA-Z0-9]{2,4}$", self.dest) is not None | ||
|
||
def _path_until_asterisk(self) -> Path: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this glob logic, isn't it already implement for native apps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry let me rephrase. This Artifact class, can't it also be used for Native Apps and other entities? If not, what's special about Snowpark artifacts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Snowpark we build zip files for artifacts which are not single file. It is easier to import one zip file than multiple py files. Artifact class should be used only in Snowpark.
) | ||
|
||
return self | ||
@field_validator("artifacts") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why aren't we using ArtifactsBase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is ArtefactsBase? Can't find in code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I meant ArtifactsBaseModel (now EntityModelBaseWithArtifacts)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! There is no problem with Snowpark, but Streamlit's artifacts were optional and when I changed to EntityModelBaseWithArtifacts now are required. It is BCR, I will talk with the team what we want to do with it.
SecurePath(self.bundle_root).rmdir(recursive=True) | ||
|
||
|
||
def bundle_root(root: Path, app_type: str | None = None) -> Path: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is app_type in the path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To separate Streamlit and Snowpark artifacts, you can run
snowpark build
streamlit deploy
snowpark deploy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we use entity ids instead, since you have multiple entities of each?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was that idea before but would introduce more complexity, so we decided to go simple way at the beginning.
* Added glob support for Snowpark and Streamlit * Added glob support for Snowpark and Streamlit * Added glob support for Snowpark and Streamlit * Changed PathMapping.src to Path * Changes after review * Changes after review 2 * Revert "Changed PathMapping.src to Path" This reverts commit 3eb543d. * Changes after review 3 * Changes after review 4 * Added full global support * Renamed feature flag and added release notes * Removed or None
Fix feature branch gates
#1909) Moved Snowpark and Streamlit artifacts to separate directory in output/deploy
6ef2d27
1a17d7e
to
6ef2d27
Compare
Pre-review checklist
Changes description