Skip to content

Conversation

@sfc-gh-svishnu
Copy link
Contributor

@sfc-gh-svishnu sfc-gh-svishnu commented Nov 4, 2025

SNOW-2665953: Make Streamlit Deployment with Versioned Stages as Default in Snow CLI

Summary

Changes the default Streamlit deployment mode from ROOT_LOCATION to versioned stages

Motivation

  • Modern architecture: Versioned stages is the recommended approach for new Streamlit apps
  • SPCS enablement: Runtime v2 (compute pools) requires versioned deployment
  • Feature parity: Other entity types (Native Apps) use versioned stages by default

Changes

CLI Behavior

# Before
snow streamlit deploy                  # ROOT_LOCATION (old)
snow streamlit deploy --experimental   # Versioned (new)

# After
snow streamlit deploy                  # Versioned (new) ✨
snow streamlit deploy --legacy         # ROOT_LOCATION (old)
snow streamlit deploy --experimental   # Versioned + deprecation warning

Implementation

  • Added --legacy flag for ROOT_LOCATION deployment
  • Inverted deployment logic (if legacy vs if not legacy)
  • Renamed _deploy_experimental()_deploy_versioned() + extracted _deploy_legacy()
  • Removed ENABLE_STREAMLIT_VERSIONED_STAGE feature flag
  • SPCS runtime v2 remains exclusive to versioned mode

Test Updates

  • Updated 12 unit tests requiring ROOT_LOCATION to use --legacy
  • Removed --experimental from tests expecting default behavior
  • Updated integration tests for new default

Deployment Behavior Change

Default mode changes: The snow streamlit deploy command now uses versioned stages by default instead of ROOT_LOCATION.

Impact

  • Existing deployed apps: Continue to work unchanged. No action required.
  • New deployments: Will automatically use versioned stages
  • Re-deployments: When re-deploying an existing app, the CLI shows warnings if the deployment mode changes

Using ROOT_LOCATION (Legacy Mode)

Users who need ROOT_LOCATION deployment can use the --legacy flag:

snow streamlit deploy --legacy

Or in CI/CD:

- run: snow streamlit deploy --legacy

Backward Compatibility

  • --experimental flag still works (shows deprecation warning)
  • Both deployment modes create functionally equivalent Streamlit apps
  • The difference is only in internal stage file organization
  • All existing functionality preserved
  • Zero API changes

Testing

  • All unit tests pass with updated flags
  • Integration tests updated and verified
  • Manual testing: both deployment modes work as expected

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.
  • I've described my changes in the documentation.
    ...

@sfc-gh-svishnu sfc-gh-svishnu requested a review from a team as a code owner November 4, 2025 14:33
@sfc-gh-svishnu sfc-gh-svishnu force-pushed the make-versioned-streamlit-default branch from 18ef70d to 97f75ad Compare November 4, 2025 14:49
Copy link
Contributor

@sfc-gh-jwilkowski sfc-gh-jwilkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! For the most part it looks really good, I'd only like to ask to pay attention to repetitive comments bloat and making user-facing messages clear to them. I don't think that all of that terminology is a common knowledge so it would be better to explain those in a different way. Please also take a look at failing tests

Copy link
Contributor

@sfc-gh-jwilkowski sfc-gh-jwilkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments:

  1. Please add an entry in RELEASE-NOTES.md in Unreleased version section describing briefly this change
  2. please edit the description of PR and remove the part about a breaking change - I don't think it's a BCR since we're changing internals of created streamlit, so I don't want to confuse people reading this PR
  3. There's one case that I'm not sure about - it's possible to deploy a streamlit with --replace flag. If that app existed before, there's a chance that we'd replace old-style streamlit app with new style one. I'm not sure if there would be any negative consequences of that, but feels like something we should handle.

@sfc-gh-svishnu
Copy link
Contributor Author

A couple of comments:

  1. Please add an entry in RELEASE-NOTES.md in Unreleased version section describing briefly this change
  2. please edit the description of PR and remove the part about a breaking change - I don't think it's a BCR since we're changing internals of created streamlit, so I don't want to confuse people reading this PR
  3. There's one case that I'm not sure about - it's possible to deploy a streamlit with --replace flag. If that app existed before, there's a chance that we'd replace old-style streamlit app with new style one. I'm not sure if there would be any negative consequences of that, but feels like something we should handle.

Addressed

## Changes

### CLI Behavior
- `snow streamlit deploy` now uses versioned deployment (FROM syntax) by default
- Added `--legacy` flag to use old ROOT_LOCATION deployment
- `--experimental` flag is now deprecated but still works (shows warning)

### Code Changes
- Added `--legacy` flag to streamlit deploy command
- Inverted deployment logic: `if experimental` → `if not legacy`
- Renamed `_deploy_experimental()` → `_deploy_versioned()`
- Removed `ENABLE_STREAMLIT_VERSIONED_STAGE` feature flag
- Updated `_is_spcs_runtime_v2_mode()` to not require experimental flag
- SPCS runtime v2 (compute pools) only available in versioned mode

### Test Updates
- Added `--legacy` flag to 12 unit tests expecting ROOT_LOCATION behavior
- Removed `--experimental` flag from tests now using default behavior
- Removed `with_feature_flags` wrapper and parametrization
- Updated integration tests to reflect new default

## Breaking Change
The default deployment mode changes from ROOT_LOCATION to versioned deployment.
Users who want the old behavior must use `--legacy` flag.
For consistency with _deploy_versioned(), extracted the else block's
deployment logic into a dedicated _deploy_legacy() method. This improves
code organization and makes the deploy() method cleaner.
Changed from 'if not legacy' to 'if legacy' for better readability.
The positive condition directly maps to the flag name and avoids mental negation.
- Split long comment in _deploy_legacy() method
- Break deprecation warning string across multiple lines
- Format long test invocation call
- Fix typo: elswhere → elsewhere
Update test_streamlit_flow and test_streamlit_deploy_prune_flag to work with
versioned Streamlit deployment (now the default behavior).

Changes:
- test_streamlit_flow: Update stage paths from legacy app_1_stage to versioned
  snow://streamlit/{DB}.{SCHEMA}.app_1/versions/live/
- test_streamlit_deploy_prune_flag: Rewrite to use managed versioned stages
  instead of user-created stages

Files are now uploaded to managed stages at versions/live/ path instead of
user-specified ROOT_LOCATION stages.
- Add mock for describe() method to return versioned stage path
- Update test_deploy to use legacy=True for testing old behavior
- Replace experimental parameter with legacy parameter in SPCS runtime v2 tests
- Fix test_deploy_with_spcs_runtime_v2_and_legacy_flag_raises_error invalid parameters

Changes reflect that versioned deployment is now the default, and the
experimental flag has been replaced with a legacy flag to opt into old behavior.
- Add --legacy flag to streamlit deploy help text
- Remove oauth-token-request-url parameter (deprecated)

These changes reflect the new default versioned deployment behavior.
…commands except streamlit

The previous commit incorrectly removed oauth-token-request-url from ALL commands.
This parameter should only be excluded from streamlit.deploy command, but remain
in all other commands' help text.
This parameter is a standard connection option that applies to all commands
including streamlit. Cannot be removed from just streamlit.deploy.
…lit stage

Snowflake requires overwrite=true when uploading to streamlit versioned stages.
The test was failing because stage copy needs --overwrite flag when uploading
to snow://streamlit/ managed stages.
Versioned stages are managed by Snowflake's FBE and have different file
lifecycle behavior. The prune flag functionality is primarily for legacy
ROOT_LOCATION stages where the CLI has full control over file management.

Changed the test to use --legacy flag to properly test the prune
functionality on legacy stages instead of versioned stages.
@sfc-gh-svishnu sfc-gh-svishnu force-pushed the make-versioned-streamlit-default branch from f4cfb7f to 731b0da Compare November 12, 2025 19:10
@sfc-gh-svishnu sfc-gh-svishnu force-pushed the make-versioned-streamlit-default branch from 1f5027a to 81a480e Compare November 13, 2025 06:30
@sfc-gh-svishnu sfc-gh-svishnu force-pushed the make-versioned-streamlit-default branch from 81a480e to 78d7301 Compare November 13, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants