Skip to content

Commit

Permalink
Move set_page_config out of beta (#2102)
Browse files Browse the repository at this point in the history
* Move set_page_config out of beta

* Support beta_foo, but with a warning

* Remove "beta feature" notice

* Change changelog link to a versioned link
  • Loading branch information
akrolsmir committed Oct 19, 2020
1 parent da59905 commit 5aecf45
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ app, provide help using doc strings, and get and modify configuration options.
.. autofunction:: streamlit.help
.. autofunction:: streamlit.get_option
.. autofunction:: streamlit.set_option
.. autofunction:: streamlit.beta_set_page_config
.. autofunction:: streamlit.set_page_config
```

## Mutate data
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ _Release date: August 12, 2020_

**Highlights:**

- ⚙️ Ability to set page title, favicon, sidebar state, and wide mode via st.beta_set_page_config(). See our [documentation](https://docs.streamlit.io/en/latest/api.html#streamlit.beta_set_page_config) for details.
- ⚙️ Ability to set page title, favicon, sidebar state, and wide mode via st.beta_set_page_config(). See our [documentation](https://docs.streamlit.io/en/0.65.0/api.html#streamlit.set_page_config) for details.
- 📝 Add stateful behaviors through the use of query parameters with st.experimental_set_query_params and st.experimental_get_query_params. Thanks [@zhaoooyue](https://github.com/zhaoooyue)!
- 🐼 Improved pandas dataframe support for st.radio, st.selectbox, and st.multiselect.
- 🛑 Break out of your Streamlit app with st.stop.
Expand Down
2 changes: 1 addition & 1 deletion e2e/scripts/st_set_page_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import streamlit as st

st.beta_set_page_config(
st.set_page_config(
page_title="Heya, world?",
page_icon=":shark:",
layout="wide",
Expand Down
38 changes: 37 additions & 1 deletion lib/streamlit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,43 @@ def _update_logger():
# Config

get_option = _config.get_option
from streamlit.commands.page_config import beta_set_page_config
from streamlit.commands.page_config import set_page_config


def _beta_warning(func, date):
"""Wrapper for functions that are no longer in beta.
Wrapped functions will run as normal, but then proceed to show an st.warning
saying that the beta_ version will be removed in ~3 months.
Parameters
----------
func: function
The `st.` function that used to be in beta.
date: str
A date like "2020-01-01", indicating the last day we'll guarantee
support for the beta_ prefix.
"""

def wrapped(*args, **kwargs):
# Note: Since we use a wrapper, beta_ functions will not autocomplete
# correctly on VSCode.
result = func(*args, **kwargs)
warning(
f"`st.{func.__name__}` has graduated out of beta. "
+ f"On {date}, the beta_ version will be removed.\n\n"
+ f"Before then, update your code from `st.beta_{func.__name__}` to `st.{func.__name__}`."
)
return result

# Update the wrapped func's name & docstring so st.help does the right thing
wrapped.__name__ = "beta_" + func.__name__
wrapped.__doc__ = func.__doc__
return wrapped


beta_set_page_config = _beta_warning(set_page_config, "2021-01-06")


def set_option(key, value):
Expand Down
8 changes: 2 additions & 6 deletions lib/streamlit/commands/page_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from streamlit.errors import StreamlitAPIException


def beta_set_page_config(
def set_page_config(
page_title=None, page_icon=None, layout="centered", initial_sidebar_state="auto"
):
"""
Expand All @@ -29,10 +29,6 @@ def beta_set_page_config(
This must be the first Streamlit command used in your app, and must only
be set once.
This is a beta feature. See
https://docs.streamlit.io/en/latest/api.html#pre-release-features for more
information.
Parameters
----------
page_title: str or None
Expand All @@ -54,7 +50,7 @@ def beta_set_page_config(
Example
-------
>>> st.beta_set_page_config(
>>> st.set_page_config(
... page_title="Ex-stream-ly Cool App",
... page_icon="🧊",
... layout="wide",
Expand Down
4 changes: 2 additions & 2 deletions lib/streamlit/report_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def reset(self, query_string=""):
def enqueue(self, msg):
if msg.HasField("page_config_changed") and not self._set_page_config_allowed:
raise StreamlitAPIException(
"`beta_set_page_config()` can only be called once per app, "
"`set_page_config()` can only be called once per app, "
+ "and must be called as the first Streamlit command in your script.\n\n"
+ "For more information refer to the [docs]"
+ "(https://docs.streamlit.io/en/stable/api.html#streamlit.beta_set_page_config)."
+ "(https://docs.streamlit.io/en/stable/api.html#streamlit.set_page_config)."
)

if msg.HasField("delta") or msg.HasField("page_config_changed"):
Expand Down

0 comments on commit 5aecf45

Please sign in to comment.