-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_2.py
More file actions
128 lines (90 loc) · 2.77 KB
/
app_2.py
File metadata and controls
128 lines (90 loc) · 2.77 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
''' FermentDB Streamlit App '''
# - - - - - - - - - - - IMPORT MODULES - - - - - - - - - - - - - - - - -
import os
import streamlit as st
import pandas as pd
import numpy as np
import plotly.graph_objects as go
import plotly.express as pxl
from datetime import datetime
import hashlib
import time
from arango import ArangoClient
from streamlit_arango.config import Config
from streamlit import session_state as ss
from streamlit_d3graph import d3graph
from htbuilder import HtmlElement, div, ul, li, br, hr, a, p, img, styles, classes, fonts
from htbuilder.units import percent, px
from htbuilder.funcs import rgba, rgb
from streamlit_navigation_bar import st_navbar
import pages as pg
st.set_page_config(page_title="FermentDB",page_icon="./assets/images/page_icon.png", initial_sidebar_state="collapsed")
# - - - - - - - - - - - - - - - CSS CODE FOR CUSTOMIZATION - - - - - - - - - - - - -
with open('style.css', "r") as file:
style_css = file.read()
st.markdown(f'<style>{style_css}</style>', unsafe_allow_html=True)
# - - - - - - - - - - - - - - - CONNECT TO ARANGODB - - - - - - - - - - - - -
# Initialize the ArangoDB client.
client = ArangoClient(hosts=Config.ArangoDB.host)
# Initialize connection to database: "fermentdb" as root user
@st.cache_resource
def get_database_session():
if 'db' not in ss:
ss.db = client.db(
name = Config.ArangoDB.database,
username = Config.ArangoDB.username,
password = Config.ArangoDB.password
)
return ss.db
@st.cache_resource
def get_aql():
if 'aql' not in ss:
ss.aql = get_database_session().aql
return ss.aql
# - - - - - - - - - - - - - - - - - - QUERY DATA FROM ARANGODB - - - - - - - - - - - -
# #### ------ NAVBAR SECTION -------- ####
pages = {
"Home": app(),
"About": page_about
}
pages = ["Home","About", "Explore Bioprocess", "Explore iModulon"]
parent_dir = os.path.dirname(os.path.abspath(__file__))
#logo_path = os.path.join(parent_dir, "./assets/images/page_icon.png")
styles_navbar = {
"nav": {
"background-color": "royalblue",
"justify-content": "left",
},
"img": {
"padding-right": "14px",
},
"span": {
"color": "white",
"padding": "14px",
},
"active": {
"background-color": "white",
"color": "var(--text-color)",
"font-weight": "normal",
"padding": "14px",
}
}
options = {
"show_menu": False,
"show_sidebar": False,
}
page = st_navbar(
pages,
#logo_path=logo_path,
styles=styles_navbar,
options=options
)
# functions = {
# "Home": pg.app,
# "About": pg.show_about,
# #"Explore Bioprocess": pg.show_bioprocess,
# #"Explore iModulon": pg.show_imodulon,
# }
# go_to = functions.get(page)
# if go_to:
# go_to()