Skip to content
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

Make st.write call st.json to display Streamlit secrets object #8659

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

snehankekre
Copy link
Collaborator

Describe your changes

When you call st.write(st.secrets), the output is displayed as inline code with st.markdown. This PR makes st.write call st.json on objects of type streamlit.runtime.secrets.Secrets

GitHub Issue Link (if applicable)

Closes #2905.

Testing Plan

  • Added Python unit test

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

Copy link
Collaborator

@LukasMasuch LukasMasuch left a comment

Choose a reason for hiding this comment

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

Overall, I think this LGTM 👍 But it might be worth to evaluate if we actually want to add an explicit to_dict (preferred) or to_json method to st.secrets. The __repr__ call isn't necessarily guaranteeing that it returns a valid json, its just doing that at the moment.

@snehankekre
Copy link
Collaborator Author

snehankekre commented May 14, 2024

Thanks, Lukas!

The repr call isn't necessarily guaranteeing that it returns a valid json

Good point, I've added a to_dict method to the Secrets class. Is this what you had in mind?

@LukasMasuch
Copy link
Collaborator

Yep, I think that looks good 👍 added one comment above. And have you tested it manually with nested secrets if it works as expected?

@snehankekre
Copy link
Collaborator Author

snehankekre commented May 14, 2024

And have you tested it manually with nested secrets?

I did and it works as expected 😄

secrets

lib/streamlit/runtime/secrets.py Dismissed Show dismissed Hide dismissed
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update how st.write(st.beta_secrets) displays secrets
2 participants