Fix streamlit deploy failure when pages/*.py overlaps with pages/ directory#2780
Open
sfc-gh-moczko wants to merge 2 commits intomainfrom
Open
Fix streamlit deploy failure when pages/*.py overlaps with pages/ directory#2780sfc-gh-moczko wants to merge 2 commits intomainfrom
sfc-gh-moczko wants to merge 2 commits intomainfrom
Conversation
iter_stage() was reconstructing file paths from Snowflake ls output, which only contains the unqualified stage name. This caused GET commands to resolve against the connection default database instead of the database specified in the FQN. Now preserves the original stage_path FQN by using root_path() and joining only the relative file path. Fixes SNOW-3074550 .... Generated with [Cortex Code](https://docs.snowflake.com/user-guide/snowflake-cortex/cortex-agents) Co-Authored-By: Cortex Code <noreply@snowflake.com>
5ee660a to
26c478a
Compare
…ectory (#2741) When both `pages/` and `pages/*.py` appear in artifacts, the bundle map created duplicate destination mappings that caused `NotInDeployRootError` during symlink resolution. Fix by tracking directory-walked children in `__dest_to_src` to detect and deduplicate overlapping mappings, and by filtering redundant `additional_source_files` during V1-to-V2 definition conversion. .... Generated with [Cortex Code](https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code) Co-Authored-By: Cortex Code <noreply@snowflake.com>
26c478a to
35039f3
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2741.
snow streamlit deployfails withNotInDeployRootErrorwhen bothpages/(directory) andpages/*.py(glob) appear in artifacts and apages/directory exists on disk.Root cause
_ArtifactPathMap.put()walks directory sources to mark children in_dest_is_dir, but does not register those children in__dest_to_src. When a glob likepages/*.pylater resolves to the same files,__dest_to_src.get(dest)returnsNoneinstead of the existing source, so the duplicate mapping is silently added. Duringsymlink_or_copy(), the second mapping callsPath.resolve()on an already-created symlink, which follows it back to the project source directory — outside the deploy root — and raisesNotInDeployRootError.Fix
_ArtifactPathMap.put()(bundle_map.py) — Two changes in theput()method:__dest_to_src: Each file discovered duringos.walkis recorded as__dest_to_src[child_dest] = child_src. If a different source already maps to that destination,TooManyFilesErroris raised immediately.current_source == src, the mapping is redundant (already covered by a parent directory walk), soput()returns without adding a duplicate entry.convert_streamlit_to_v2_data()(definition_conversion.py) — Defense-in-depth:Adds
_is_path_covered_by_directory()helper. During V1→V2 definition conversion,additional_source_filesentries likepages/*.pyare skipped if they fall under a directory already included as an artifact (e.g.pages/). This prevents the overlapping mappings from reaching_ArtifactPathMapin the first place.Test plan
test_bundle_map_deduplicates_directory_and_glob_overlap— directorysrc/snowparkadded first, then explicitsrc/snowpark/main.py → snowpark/main.py; verifies the duplicate is silently deduplicated and only the directory mapping remainstest_bundle_map_disallows_different_source_collision_with_directory_child— directorysrc/snowparkadded first, thenapp/manifest.yml → snowpark/main.py(different source, same dest); verifiesTooManyFilesErroris raisedtest_bundle_map_disallows_collisions_anywhere_in_deployed_hierarchy— previously@pytest.mark.skip; now passes because directory children are tracked in__dest_to_srctest_bundle_deduplicates_pages_directory_and_glob— end-to-endStreamlitEntity.bundle()withartifacts: ["streamlit_app.py", "pages/", "pages/*.py"]; verifies the bundle completes and produces the correct output filestest_v1_to_v2_streamlit_conversion_deduplicates_pages— V1 streamlit withadditional_source_files: [pages/*.py]and apages/directory on disk; verifiespages/*.pyis filtered from the converted V2 artifactstest_v1_to_v2_streamlit_conversion_keeps_non_overlapping_additional_files— same setup but withutils/helper.pyadded; verifies non-overlapping files are preserved whilepages/*.pyis still filtered