-
Notifications
You must be signed in to change notification settings - Fork 55
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
Added glob support for Snowpark and Streamlit #1814
base: main
Are you sure you want to change the base?
Conversation
for artifact in artifacts: | ||
if isinstance(artifact, PathMapping): | ||
_artifacts.append(artifact) | ||
else: | ||
_artifacts.append(PathMapping(src=artefact)) | ||
_artifacts.append(PathMapping(src=artifact)) |
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 believe that previous name was correct.
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' is the British spelling, while, 'artifact' is the American spelling.
We have both versions 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.
Why my_page.py
is empty file?
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.
mypy had problems with non existing title function.
tests_integration/test_data/projects/snowpark_glob_patterns/requirements.txt
Show resolved
Hide resolved
3653ce8
to
7ef640a
Compare
Snowpark output directory per stage or leave it for diff/sync PR? |
7ef640a
to
4c3ee60
Compare
5a0fc07
to
c8058c6
Compare
eebdb30
to
19fdf46
Compare
from typing import Dict, Optional, Set, Tuple | ||
|
||
import typer | ||
from click import ClickException, UsageError | ||
from snowflake.cli._plugins.nativeapp.artifacts import BundleMap, symlink_or_copy |
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.
If we're going to use BundleMap for every type of entity, maybe it's best to move it from native app plugin?
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 good idea, but not in this PR.
) | ||
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import PathMapping |
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.
Again, maybe we could extract common objects, instead of cross-plugin imports
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.
Definitely, but not in this PR.
src/snowflake/cli/_plugins/streamlit/streamlit_project_paths.py
Outdated
Show resolved
Hide resolved
2e7278d
to
6968934
Compare
@@ -303,19 +303,18 @@ def _add(self, src: Path, dest: Path, map_as_child: bool) -> None: | |||
src=canonical_src, dest=canonical_dest, dest_is_dir=dest_is_dir | |||
) | |||
|
|||
def _add_mapping(self, src: str, dest: Optional[str] = None): | |||
def _add_mapping(self, src: Path, dest: Optional[str] = None): |
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.
src was a string here because it can be a glob pattern as well, which is odd to represent as a Path. I'm not a big fan of this change (or the matching one in the model)
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.
After discussion we decided to back to string.
@@ -225,8 +228,8 @@ def build_artifacts_mappings( | |||
entities_to_imports_map[entity_id].add(artefact_dto.import_path(stage)) | |||
stages_to_artifact_map[stage].update(required_artifacts) | |||
|
|||
if project_paths.dependencies.exists(): | |||
deps_artefact = project_paths.get_dependencies_artefact() | |||
deps_artefact = project_paths.get_dependencies_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.
nit: we should pick one of british or american spelling for artifact/artefact and use it consistently
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 agree, created ticket for it.
deploy_root=(project_paths.project_root / "output").absolute(), | ||
) | ||
bundle_map.add( | ||
PathMapping(src=str(artefact.path), dest=(artefact.dest or None)) |
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.
Ah, commented above before seeing this conversation. I think representing a glob pattern as a Path is misleading, I'm not in favor. There's a reason we were using str explicitly, as opposed to Path pretty much everywhere else when a Path is resolved. If we want to make this "might be a glob" explicit, happy to consider something like a type alias or similar.
| If we want to make this "might be a glob" explicit, happy to consider something like a type alias or similar. +1 to this idea I think it would make sense to have |
_artifacts.append(artefact) | ||
for artifact in artifacts: | ||
if ( | ||
"*" in artifact |
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.
*
isn't the only glob pattern, so that's a really weak check. What about something like file[1-5].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.
I wanted to to start with basics, I will try with glob.has_magic.
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 tried and it works after small changes!
for artifact in artifacts: | ||
if ( | ||
"*" in artifact | ||
and FeatureFlag.ENABLE_SNOWPARK_BUNDLE_MAP_BUILD.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.
nit: not generally a fan of naming publicly visible concepts by implementation details like "bundle map". Is there a more user-friendly name we could use here?
Also, is it not the default because of backwards compat concerns? I wonder if the solution isn't to make it default, but then give a flag to revert to old behaviour if needed (SNOWPARK_LEGACY_GLOB_BEHAVIOUR=true ?)
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 can not be default, because it is BCR. New build changes zip paths.
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.
Maybe ENABLE_SNOWPARK_GLOB_SUPPORT
?
for (absolute_src, absolute_dest) in bundle_map.all_mappings( | ||
absolute=True, expand_directories=False | ||
): | ||
symlink_or_copy( |
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.
we'll need to apply processors as well, is that planned for a future PR? I can probably help migrate processors to a more general location (and the bundle map too while we're at it), if you want the help. I think there are a few things to fix with processors in the process anyway, this is a good opportunity to make those small, under-the-hood changes.
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 totally forgot about processors, but I thing it should be added in new PR.
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.
None of my comments are blockers, so LGTM for NADE
4e569bd
to
7735817
Compare
This reverts commit 3eb543d.
7735817
to
4a558d8
Compare
def deploy_root(self) -> Path: | ||
return self.project_root / "output" |
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 could cause conflicts with other domains, since native apps uses output/deploy by default. We make ours configurable as well through snowflake.yml. We should probably align the choice of deploy root, and make it per-entity so that multiple entities, even across different domains, don't negatively interfere with each other. We should probably do that as a follow-up PR very quickly.
|
||
@property | ||
def deploy_root(self) -> Path: | ||
return self.project_root / "output" |
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.
native apps uses output/deploy for this. We have other ephemeral directories under output/ as well, e.g. output/bundle as the bundle root. We also make all of those configurable.
4a558d8
to
cfb17bf
Compare
Pre-review checklist
Changes description