Skip to content

Conversation

nikita240
Copy link
Contributor

experimental_get_query_params() and experimental_set_query_params() is deprecated in favor of a new query_params API .

https://docs.streamlit.io/develop/api-reference/caching-and-state/st.query_params#stquery_paramsget_all


streamlit.write("#### Query String")
query_string: typing.Dict[str, str] = streamlit.experimental_get_query_params()
query_string: typing.Dict[str, str] = streamlit.query_params.get_all()
Copy link
Owner

Choose a reason for hiding this comment

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

I get the following error with this:

File "/home/zen/.cache/pypoetry/virtualenvs/streamlit-parameters-Wj2vk3Ob-py3.10/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
    result = func()
File "/home/zen/.cache/pypoetry/virtualenvs/streamlit-parameters-Wj2vk3Ob-py3.10/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
    exec(code, module.__dict__)
File "/workspaces/streamlit_parameters/streamlit_parameters/demos/parameters.py", line 236, in <module>
    main()
File "/workspaces/streamlit_parameters/streamlit_parameters/demos/parameters.py", line 217, in main
    query_string: typing.Dict[str, str] = streamlit.query_params.get_all()
File "/home/zen/.cache/pypoetry/virtualenvs/streamlit-parameters-Wj2vk3Ob-py3.10/lib/python3.10/site-packages/streamlit/runtime/metrics_util.py", line 410, in wrapped_func
    result = non_optional_func(*args, **kwargs)

However, streamlit.write(streamlit.query_params) works fine.

Copy link
Owner

Choose a reason for hiding this comment

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

Perhaps the api changed (only works for get_all on a single key now).

This misses repeated keys, but that's fine since we're only using it for debugging.

@stonier
Copy link
Owner

stonier commented Nov 26, 2024

Patched and merged in #10.

@stonier stonier closed this Nov 26, 2024
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.

2 participants