-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path02_Explore_Data.py
53 lines (44 loc) · 1.52 KB
/
02_Explore_Data.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
import streamlit as st
import os
import traceback
import sys
import pandas as pd
from batch.utilities.helpers.env_helper import EnvHelper
from batch.utilities.search.search import Search
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
env_helper: EnvHelper = EnvHelper()
st.set_page_config(
page_title="Explore Data",
page_icon=os.path.join("images", "favicon.ico"),
layout="wide",
menu_items=None,
)
mod_page_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
header {visibility: hidden;}
</style>
"""
st.markdown(mod_page_style, unsafe_allow_html=True)
# CSS to inject contained in a string
hide_table_row_index = """
<style>
thead tr th:first-child {display:none}
tbody th {display:none}
</style>
"""
# Inject CSS with Markdown
st.markdown(hide_table_row_index, unsafe_allow_html=True)
try:
search_handler = Search.get_search_handler(env_helper)
results = search_handler.search_with_facets("*", ["title"])
unique_files = search_handler.get_unique_files(results, "title")
filename = st.selectbox("Select your file:", unique_files)
st.write("Showing chunks for:", filename)
results = search_handler.perform_search(filename)
data = search_handler.process_results(results)
df = pd.DataFrame(data, columns=("Chunk", "Content")).sort_values(by=["Chunk"])
st.table(df)
except Exception:
st.error(traceback.format_exc())