forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stabilize the vega-lite spec for altair-based charts (streamlit#8628)
## Describe your changes Altair uses global counters to name unnamed parameter & view/subchart names (see this issue [here](vega/altair#3416)). This leads to different vega-lite chart specs across reruns for the same charts since the auto-named parameters will change the counter on every new chart creation. Some of our features like forward message cache & the upcoming chart selections will require a stable identity for the chart element. Therefore, we are applying a (temporary) slightly hacky solution to replace these generated names with names that are stable across reruns. The relevant naming patterns are: `view_<number>` and `param_<number>`. Eventually, we can replace this hack if it gets addressed in Altair (see issue [here](vega/altair#3416)) I performance-tested the `_stabilize_vega_json_spec` method with a bigger concatenated chart spec by running it 10k times. The total runtime was ~0.3s, about ~0.03 milliseconds per execution. There are a couple of ways to make this a lot more performant, but I think it would be fine to put that into a follow-up PR after the selections release. ## Testing Plan - Added unit tests. --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
- Loading branch information
1 parent
3583f26
commit 9f28b0a
Showing
10 changed files
with
368 additions
and
13 deletions.
There are no files selected for viewing
Binary file modified
BIN
+1.16 KB
(100%)
...apshots__/linux/st_chat_message_test/st_chat_message-3[dark_theme-chromium].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.24 KB
(100%)
...napshots__/linux/st_chat_message_test/st_chat_message-3[dark_theme-firefox].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.56 KB
(100%)
...snapshots__/linux/st_chat_message_test/st_chat_message-3[dark_theme-webkit].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.12 KB
(100%)
...pshots__/linux/st_chat_message_test/st_chat_message-3[light_theme-chromium].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.43 KB
(110%)
...apshots__/linux/st_chat_message_test/st_chat_message-3[light_theme-firefox].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.53 KB
(110%)
...napshots__/linux/st_chat_message_test/st_chat_message-3[light_theme-webkit].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.