|
11 | 11 | print("Please install streamlit - python3 -m pip install streamlit") |
12 | 12 | exit(1) |
13 | 13 |
|
14 | | - |
15 | | -import gotran |
| 14 | +try: |
| 15 | + import gotranx as gotran |
| 16 | +except ImportError: |
| 17 | + import gotran |
16 | 18 |
|
17 | 19 | from modelgraph import DependencyGraph |
18 | 20 |
|
19 | 21 |
|
20 | 22 | here = Path(__file__).absolute().parent |
21 | 23 |
|
22 | 24 |
|
23 | | -@st.cache(allow_output_mutation=True) |
| 25 | +@st.cache_data |
24 | 26 | def get_graph(): |
25 | 27 | ode = gotran.load_ode(os.getenv("MODELGRAPH_FILENAME")) |
26 | 28 | return DependencyGraph(ode) |
@@ -52,26 +54,28 @@ def inv_dependency_graph(): |
52 | 54 | st.image(temp.name) |
53 | 55 |
|
54 | 56 |
|
55 | | -# Page settings |
56 | | -st.set_page_config(page_title="modelgraph") |
| 57 | +if __name__ == "__main__": |
| 58 | + # Page settings |
| 59 | + st.set_page_config(page_title="modelgraph") |
57 | 60 |
|
58 | | -# Sidebar settings |
59 | | -pages = { |
60 | | - "Dendencency graph": dependency_graph, |
61 | | - "Inverse dendencency graph": inv_dependency_graph, |
62 | | -} |
| 61 | + # Sidebar settings |
| 62 | + pages = { |
| 63 | + "Dendencency graph": dependency_graph, |
| 64 | + "Inverse dendencency graph": inv_dependency_graph, |
| 65 | + } |
63 | 66 |
|
64 | | -st.sidebar.title("modelgraph") |
| 67 | + st.sidebar.title("modelgraph") |
65 | 68 |
|
66 | | -# Radio buttons to select desired option |
67 | | -page = st.sidebar.radio("", tuple(pages.keys())) |
| 69 | + # Radio buttons to select desired option |
| 70 | + keys = list(pages.keys()) |
| 71 | + page = st.sidebar.radio("Select a page", keys) |
68 | 72 |
|
69 | | -pages[page]() |
| 73 | + pages[page]() |
70 | 74 |
|
71 | | -# About |
72 | | -st.sidebar.markdown( |
73 | | - """ |
74 | | -- [Source code](https://github.com/ComputationalPhysiology/modelgraph) |
75 | | -- [Documentation](https://computationalphysiology.github.io/modelgraph/) |
76 | | -""", |
77 | | -) |
| 75 | + # About |
| 76 | + st.sidebar.markdown( |
| 77 | + """ |
| 78 | + - [Source code](https://github.com/ComputationalPhysiology/modelgraph) |
| 79 | + - [Documentation](https://computationalphysiology.github.io/modelgraph/) |
| 80 | + """, |
| 81 | + ) |
0 commit comments