Skip to content

feat(streamlit): resolve STREAMLIT grants at plan time (fetch_streamlit)#24

Open
usbrandon wants to merge 1 commit into
datacoves:mainfrom
usbrandon:feat/streamlit-grants-upstream
Open

feat(streamlit): resolve STREAMLIT grants at plan time (fetch_streamlit)#24
usbrandon wants to merge 1 commit into
datacoves:mainfrom
usbrandon:feat/streamlit-grants-upstream

Conversation

@usbrandon

Copy link
Copy Markdown
Contributor

What

snowcap plan errors whenever a grant references a Streamlit app:

module 'snowcap.data_provider' has no attribute 'fetch_streamlit'

StreamlitPriv, SchemaPriv.CREATE_STREAMLIT, and the Streamlit resource class already exist, so grant SQL renders — but because Streamlit has a concrete resource class, resolving on: streamlit <db>.<schema>.<app> drives fetch_resourcefetch_streamlit, which is missing.

Change

  • snowcap/data_provider.py: add fetch_streamlit()SHOW STREAMLITS + DESC STREAMLIT, mapping root_locationfrom_, plus main_file/title/query_warehouse/comment/owner (mirrors fetch_notebook).
  • tests/test_grant.py: test_grant_on_streamlit.
  • tests/test_privs.py: TestStreamlitPriv.
  • docs/resources/streamlit.md: "Granting access" section; docs/resources/grant.md: streamlit example.

Validation

Verified end-to-end against a live account: GRANT USAGE ON STREAMLIT now plans and applies (the previously-fatal fetch error is gone; the grant shows as a normal create). Full unit suite green.

🤖 Generated with Claude Code

STREAMLIT was a supported schema-scoped resource for rendering grant SQL,
but `snowcap plan` errored when a grant referenced a streamlit object:

    module 'snowcap.data_provider' has no attribute 'fetch_streamlit'

Because Streamlit has a concrete resource class (unlike CORTEX SEARCH SERVICE,
which is SchemaScope-only), resolving a `on: streamlit <db>.<schema>.<app>`
grant reference drives fetch_resource -> fetch_streamlit, which didn't exist.
This adds it so grants on streamlit apps can be planned and applied:

    grants:
      - priv: USAGE
        on: streamlit <db>.<schema>.<app>
        to: <viewer_role>

- snowcap/data_provider.py: fetch_streamlit() — SHOW STREAMLITS + DESC
  STREAMLIT, mapping root_location -> from_, plus main_file / title /
  query_warehouse / comment / owner (mirrors fetch_notebook).
- tests/test_grant.py: test_grant_on_streamlit (USAGE renders correctly).
- tests/test_privs.py: TestStreamlitPriv (enum values).
- docs/resources/streamlit.md: "Granting access" section.
- docs/resources/grant.md: streamlit example in the Object Grants block.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016L3b4GTh5nyFy5vxQ6e9TY
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.

1 participant