-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
57 lines (43 loc) · 1.52 KB
/
app.py
File metadata and controls
57 lines (43 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import sys
sys.path.append("src")
import click
import streamlit as st
from life4.data.backends import GoogleSheetsDataSource, OnedriveDataSource
from life4.ddr import DDRDataset
from life4.life4.ranks.a20_plus import amethyst, emerald
from life4.life4_ui import Life4RankDisplay
st.set_page_config(layout="wide")
def data_source_factory(data_source_info: dict):
source = data_source_info.pop("source")
if source == "onedrive":
return OnedriveDataSource(**data_source_info)
elif source == "google":
return GoogleSheetsDataSource(**data_source_info)
else:
raise ValueError("Unsupported data source URL")
@click.command()
@click.option(
"--data-source",
default=st.secrets["data_source"],
type=dict,
help="Information about the data source to read from",
)
def main(data_source: dict):
data_source = data_source_factory(data_source)
data = DDRDataset(data_source=data_source)
_, cent_co, _ = st.columns(3)
with cent_co:
st.image("assets/life4-logo.png", width=10, use_container_width=True)
rank_choice = st.selectbox("Select rank", ("Amethyst", "Emerald"), index=1)
if rank_choice == "Amethyst":
rank = amethyst
else:
rank = emerald
columns = st.columns(5)
placeholders = [column.empty() for column in columns]
for sub_rank, placeholder in zip(rank, placeholders):
with placeholder:
rank_display = Life4RankDisplay(sub_rank, data)
rank_display.visualize()
if __name__ == "__main__":
main()