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

Wip/first UI #15

Merged
merged 27 commits into from
Jul 10, 2023
Merged

Wip/first UI #15

merged 27 commits into from
Jul 10, 2023

Conversation

luigibrancati
Copy link
Collaborator

@luigibrancati luigibrancati commented Jul 5, 2023

Added a first UI with the following features:

  • Homepage with country selection. This also allows the user to select multiple countries either with the multiselect (top box) or using polygons on the map. The sidebar should show up to 3 countries and a country count after the 4th
  • Page for GHG yearly plot
  • Page for EAC4 anomalies plot
  • Page for both Hovmoeller latitude and Hovmoeller Pressure/Model level plots. The plotting api isn't quite there yet, but this page will allow the user to select one the these 3 plots types

I also added a CLI that starts the streamlit app. To use it, install the package with pip install . and run atmospheric-explorer on a the terminal.

Small changes to other modules.

@luigibrancati luigibrancati requested a review from elisaliv July 5, 2023 22:31
atmospheric_explorer/data_transformations.py Show resolved Hide resolved
atmospheric_explorer/shapefile.py Outdated Show resolved Hide resolved
atmospheric_explorer/ui/Home.py Show resolved Hide resolved
atmospheric_explorer/ui/interactive_map/interactive_map.py Outdated Show resolved Hide resolved
atmospheric_explorer/ui/interactive_map/interactive_map.py Outdated Show resolved Hide resolved
atmospheric_explorer/ui/utils.py Outdated Show resolved Hide resolved
atmospheric_explorer/ui/utils.py Outdated Show resolved Hide resolved
@elisaliv
Copy link
Collaborator

elisaliv commented Jul 9, 2023

General note: are there also more complex ways to manage state in Streamlit? Or patterns like separating state management in different files? I have looked a bit online in the documentation, but it doesn't seem so.

Another general question/idea: we could add all state variable default values to a config file (or similar). Maybe not right now but during the final refactoring and refining phase.

@luigibrancati
Copy link
Collaborator Author

@elisaliv I answered you comment and added Issue #18, but will reply here too.

As far as I can tell, Streamlit only provides the session_state dict-like to keep track of app state, this dict is shared between refreshes and also between different app pages. Why would we want to separate session between pages? Things like the selected_country are used by all app pages after all.
We could define a wrapper around st.session_state, but I'm afraid that would mostly over-complicate things.

About the session state in a config file, I can't think of a way to do it. Config files are used to define things, not to initialize them:

  • If we use a config.py file and put code to initialize the session state, we must import it in every module and will overwrite the session state with every import
  • If we use a config.cfg or YAML or JSON for what matters, we'll have to import it, fetch the keys we need on every page and initialize them, i.e. exactly what we do here with just one more step

@luigibrancati luigibrancati merged commit 10a5b0b into main Jul 10, 2023
@luigibrancati luigibrancati deleted the wip/first_ui branch July 10, 2023 20:20
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.

3 participants