-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
305 lines (271 loc) · 12.5 KB
/
main.py
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
import streamlit as st
from ft.utils import get_env_variable
from ft.consts import IconPaths
from streamlit_navigation_bar import st_navbar
import os
# Module for custom CSS
if os.getenv("IS_COMPOSABLE", "") != "":
def apply_custom_css():
css = '''
<style>
h3 {
font-size: 1.1rem;
}
.stTabs [data-baseweb="tab-list"] button [data-testid="stMarkdownContainer"] p {
font-size: 0.9rem;
}
</style>
'''
st.markdown(css, unsafe_allow_html=True)
# Module for setting up navigation
def setup_navigation():
pg = st.navigation([
st.Page("pgs/home.py", title="Home"),
st.Page("pgs/database.py", title="Database Import and Export"),
st.Page("pgs/datasets.py", title="Import Datasets"),
st.Page("pgs/view_datasets.py", title="View Datasets"),
st.Page("pgs/models.py", title="Import Base Models"),
st.Page("pgs/view_models.py", title="View Base Models"),
st.Page("pgs/prompts.py", title="Create Prompts"),
st.Page("pgs/view_prompts.py", title="View Prompts"),
st.Page("pgs/train_adapter.py", title="Train a New Adapter"),
st.Page("pgs/jobs.py", title="Training Job Tracking"),
st.Page("pgs/evaluate.py", title="Local Adapter Comparison"),
st.Page("pgs/mlflow.py", title="Run MLFlow Evaluation"),
st.Page("pgs/mlflow_jobs.py", title="View MLflow Runs"),
st.Page("pgs/export.py", title="Export And Deploy Model"),
st.Page("pgs/sample_ticketing_agent_app_embed.py", title="Sample Ticketing Agent App"),
st.Page("pgs/feedback.py", title="Feedback"),
], position="hidden")
# pg.run()
return pg
# Main function to orchestrate the setup
st.set_page_config(
page_title="Fine Tuning Studio",
page_icon=IconPaths.FineTuningStudio.FINE_TUNING_STUDIO,
layout="wide"
)
styles = {
"nav": {
"background-color": "white",
"display": "flex",
"height": ".01rem"
},
}
options = {
'show_menu': False
}
pages = ['Home']
page = st_navbar(pages,
styles=styles,
options=options
)
# Include Material Icons stylesheet
st.markdown('<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">', unsafe_allow_html=True)
# Bootstrap CSS for styling
st.markdown('<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">', unsafe_allow_html=True)
# Custom CSS for bigger dropdown menus and icons for links
st.markdown("""
<style>
.navbar {
background-color: #132329;
position: fixed;
top: 0;
width: 100%;
z-index: 1000;
padding: 10px;
margin: 0;
left: 0;
display: flex;
justify-content: flex-start;
gap: 20px; /* Control space between navbar items */
}
.navbar a {
color: white;
padding: 10px 20px; /* Adjust padding to control spacing around each item */
text-decoration: none;
font-size: 16px;
display: inline-block;
}
.navbar a:hover {
background-color: #2980B9;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 325px; /* Increased width of the dropdown by 30% (from 250px to 325px) */
padding: 13px 0; /* Increased padding for dropdown items */
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 14px 25px; /* Increased padding to make dropdown items bigger */
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #ddd;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #2980B9;
}
.material-icons {
font-size: 18px;
vertical-align: middle;
margin-right: 8px;
}
</style>
""", unsafe_allow_html=True)
# Navbar HTML with bigger dropdown menus and icons for each link
st.markdown("""
<nav class="navbar">
<a href="/home" target="_self"><span class="material-icons">home</span>Fine Tuning Studio</a>
<div class="dropdown">
<a class="dropbtn" href="#" target="_self"><span class="material-icons">build</span> Database Import Export</a>
<div class="dropdown-content">
<a href="/database" target="_self"><span class="material-icons">publish</span>Import and Export Application Database</a>
</div>
</div>
<div class="dropdown">
<a class="dropbtn" href="#" target="_self"><span class="material-icons">build</span> Resources</a>
<div class="dropdown-content">
<a href="/datasets" target="_self"><span class="material-icons">publish</span> Import Datasets</a>
<a href="/view_datasets" target="_self"><span class="material-icons">data_object</span> View Datasets</a>
<a href="/models" target="_self"><span class="material-icons">download</span> Import Base Models</a>
<a href="/view_models" target="_self"><span class="material-icons">view_day</span> View Base Models</a>
<a href="/prompts" target="_self"><span class="material-icons">chat</span> Create Prompts</a>
<a href="/view_prompts" target="_self"><span class="material-icons">forum</span> View Prompts</a>
</div>
</div>
<div class="dropdown">
<a class="dropbtn" href="#" target="_self"><span class="material-icons">science</span> Experiment</a>
<div class="dropdown-content">
<a href="/train_adapter" target="_self"><span class="material-icons">forward</span> Train a New Adapter</a>
<a href="/jobs" target="_self"><span class="material-icons">subscriptions</span> Monitor Training Jobs</a>
<a href="/evaluate" target="_self"><span class="material-icons">difference</span> Local Adapter Comparison</a>
<a href="/mlflow" target="_self"><span class="material-icons">model_training</span> Run MLFlow Evaluation</a>
<a href="/mlflow_jobs" target="_self"><span class="material-icons">dashboard</span> View MLflow Runs</a>
</div>
</div>
<div class="dropdown">
<a class="dropbtn" href="#" target="_self"><span class="material-icons">cloud</span> AI Workbench</a>
<div class="dropdown-content">
<a href="/export" target="_self"><span class="material-icons">upgrade</span> Export And Deploy Model</a>
</div>
</div>
<div class="dropdown">
<a class="dropbtn" href="#" target="_self"><span class="material-icons">subscriptions</span> Examples</a>
<div class="dropdown-content">
<a href="/sample_ticketing_agent_app_embed" target="_self"><span class="material-icons">forward</span> Ticketing Agent App</a>
</div>
</div>
<div class="dropdown">
<a class="dropbtn" href="#" target="_self"><span class="material-icons">subscriptions</span> Feedback</a>
<div class="dropdown-content">
<a href="/feedback" target="_self"><span class="material-icons">forward</span> Provide Feedback</a>
</div>
</div>
</nav>
""", unsafe_allow_html=True)
apply_custom_css()
pg = setup_navigation()
pg.run()
else:
def apply_custom_css_sidebar():
css = '''
<style>
h3 {
font-size: 1.1rem;
}
.stTabs [data-baseweb="tab-list"] button [data-testid="stMarkdownContainer"] p {
font-size: 0.9rem;
}
[data-testid="stHeader"] {
color: #4CAF50;
background-color: #f0f0f0;
}
[data-testid="stSidebarContent"] {
background: #16262c;
color: white;
}
[data-testid="stSidebarContent"] * {
color: white;
}
</style>
'''
st.markdown(css, unsafe_allow_html=True)
# Module for setting up navigation
def setup_navigation_sidebar():
pg = st.navigation([
st.Page("pgs/home.py", title="Home"),
st.Page("pgs/database.py", title="Database Import and Export"),
st.Page("pgs/datasets.py", title="Import Datasets"),
st.Page("pgs/view_datasets.py", title="View Datasets"),
st.Page("pgs/models.py", title="Import Base Models"),
st.Page("pgs/view_models.py", title="View Base Models"),
st.Page("pgs/prompts.py", title="Create Prompts"),
st.Page("pgs/view_prompts.py", title="View Prompts"),
st.Page("pgs/train_adapter.py", title="Train a New Adapter"),
st.Page("pgs/jobs.py", title="Training Job Tracking"),
st.Page("pgs/evaluate.py", title="Local Adapter Comparison"),
st.Page("pgs/mlflow.py", title="Run MLFlow Evaluation"),
st.Page("pgs/mlflow_jobs.py", title="View MLflow Runs"),
st.Page("pgs/export.py", title="Export And Deploy Model"),
st.Page("pgs/sample_ticketing_agent_app_embed.py", title="Sample Ticketing Agent App"),
st.Page("pgs/feedback.py", title="Feedback"),
], position="hidden")
pg.run()
# Module for sidebar content
def setup_sidebar():
with st.sidebar:
st.image("./resources/images/ft-logo.png")
st.subheader("")
st.markdown("Navigation")
st.page_link("pgs/home.py", label="Home", icon=":material/home:")
st.page_link("pgs/database.py", label="Database Import and Export", icon=":material/database:")
st.write("\n")
st.markdown("Resources")
st.page_link("pgs/datasets.py", label="Import Datasets", icon=":material/publish:")
st.page_link("pgs/view_datasets.py", label="View Datasets", icon=":material/data_object:")
st.page_link("pgs/models.py", label="Import Base Models", icon=":material/neurology:")
st.page_link("pgs/view_models.py", label="View Base Models", icon=":material/view_day:")
st.page_link("pgs/prompts.py", label="Create Prompts", icon=":material/chat:")
st.page_link("pgs/view_prompts.py", label="View Prompts", icon=":material/forum:")
st.write("\n")
st.markdown("Experiments")
st.page_link("pgs/train_adapter.py", label="Train a New Adapter", icon=":material/forward:")
st.page_link("pgs/jobs.py", label="Monitor Training Jobs", icon=":material/subscriptions:")
st.page_link("pgs/evaluate.py", label="Local Adapter Comparison", icon=":material/difference:")
st.page_link("pgs/mlflow.py", label="Run MLFlow Evaluation", icon=":material/model_training:")
st.page_link("pgs/mlflow_jobs.py", label="View MLflow Runs", icon=":material/monitoring:")
st.write("\n")
st.markdown("AI Workbench")
st.page_link("pgs/export.py", label="Export And Deploy Model", icon=":material/move_group:")
st.write("\n")
st.markdown("Examples")
st.page_link("pgs/sample_ticketing_agent_app_embed.py", label="Ticketing Agent App", icon=":material/deployed_code:")
st.markdown("Feedback")
st.page_link("pgs/feedback.py", label="Feedback", icon=":material/feedback:")
st.subheader("", divider="green")
project_owner = get_env_variable('PROJECT_OWNER', 'User')
cdsw_url = get_env_variable('CDSW_DOMAIN', 'CDSW Url')
st.page_link(f"https://{cdsw_url}", label=f"{project_owner}", icon=":material/account_circle:")
# Main function to orchestrate the setup
st.set_page_config(
page_title="Fine Tuning Studio",
page_icon=IconPaths.FineTuningStudio.FINE_TUNING_STUDIO,
layout="wide"
)
apply_custom_css_sidebar()
setup_navigation_sidebar()
setup_sidebar()