Arkadiusz Czerwiński commited on
Commit
c5478f1
1 Parent(s): 7100718

feat: initial changes

Browse files
Files changed (3) hide show
  1. .streamlit/config.toml +12 -0
  2. app.py +111 -0
  3. requirements.txt +2 -0
.streamlit/config.toml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [theme]
2
+ primaryColor="#FFFFFF"
3
+ backgroundColor="#FFFFFF"
4
+ secondaryBackgroundColor="#0099aa"
5
+ textColor="#262730"
6
+ font="sans serif"
7
+
8
+ [global]
9
+ showWarningOnDirectExecution = false
10
+
11
+ [logger]
12
+ level = "critical"
app.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import os
4
+ from pathlib import Path
5
+ from streamlit.errors import DuplicateWidgetID
6
+
7
+ main_content, right_sidebar = st.columns([50, 2])
8
+
9
+ @st.cache_data()
10
+ def toggle_state():
11
+ return {"toggled": False}
12
+
13
+ if 'onthology' not in st.session_state:
14
+ st.session_state['onthology'] = "No onthology selected"
15
+
16
+ def get_similar_meta_file(path):
17
+ return path.parent / (str(path.stem) + "_meta.csv")
18
+
19
+ def projects():
20
+ with main_content:
21
+ projects = ["my_project", "make_it_meta"]
22
+ st.markdown("# Project Creation and Naming")
23
+
24
+ markdown = ""
25
+
26
+ for project in projects:
27
+ markdown += f"- {project}\n"
28
+
29
+ st.markdown(markdown)
30
+
31
+ def datasets():
32
+ with main_content:
33
+ try:
34
+ datasets = list((Path("..").resolve() / "samples").glob("*"))
35
+ datasets_not_meta = [x for x in datasets if ("csv" in str(x) or "tsv" in str(x)) and "_meta" not in str(x)]
36
+ datasets_meta = [x for x in datasets if ("csv" in str(x) or "tsv" in str(x)) and "_meta" in str(x)]
37
+
38
+ st.markdown("# Data selection and Uploading")
39
+ selected_option = st.selectbox("Select a dataset", set([x.stem for x in datasets_not_meta if get_similar_meta_file(x) in datasets_meta]))
40
+
41
+ selected_mode = st.selectbox("Select mode", ["Causual", "Makeitmeta"])
42
+
43
+
44
+ for file in datasets:
45
+ if selected_option == file.stem:
46
+ sep = "," if "csv" in file.stem else "\t"
47
+ if selected_mode == "Makeitmeta":
48
+ file = get_similar_meta_file(file)
49
+ sep = ","
50
+
51
+ df = pd.read_csv(str(file), sep=sep)
52
+ st.data_editor(df, key="data_editor_" + str(selected_mode))
53
+
54
+ st.markdown("### If you want to upload a dataset you can do it below:")
55
+
56
+ uploaded_file = st.file_uploader("Upload a file", type=["txt", "pdf", "jpg", "png"])
57
+
58
+ if uploaded_file is not None:
59
+ # Do something with the uploaded file, e.g., display its name
60
+ st.write(uploaded_file.name)
61
+ except DuplicateWidgetID as e:
62
+ pass
63
+ def labeling():
64
+ with main_content:
65
+ st.markdown("# Labeling selection and Uploading")
66
+ if st.session_state.onthology:
67
+ st.markdown(f"### Current onthologdy: {st.session_state.onthology}")
68
+ with right_sidebar:
69
+ query = st.text_input('Search bar', '')
70
+ if query == "":
71
+ st.write("Search results")
72
+ else:
73
+ st.write(f"Printing results for query: {query}")
74
+
75
+
76
+ def ontologies():
77
+ with main_content:
78
+ onthologies = ["caDSR", "UMLS"]
79
+ st.markdown("# Ontology Selection")
80
+ onthology = st.selectbox(
81
+ 'Select your onthology',
82
+ tuple(onthologies)
83
+ )
84
+ st.session_state.onthology = onthology
85
+ st.write('You selected:', onthology)
86
+
87
+
88
+ pages = {
89
+ "Datasets": datasets,
90
+ "Projects": projects,
91
+ "Labeling": labeling,
92
+ "Ontologies": ontologies
93
+ }
94
+
95
+
96
+ # st.sidebar.title("Navigation")
97
+ # selection1 = st.sidebar.button("Projects")
98
+ # if selection1:
99
+ # projects()
100
+ # selection2 = st.sidebar.button("Datasets")
101
+ # if selection2:
102
+ # datasets()
103
+ # selection3 = st.sidebar.button("Labeling")
104
+ # if selection3:
105
+ # labeling()
106
+ # selection4 = st.sidebar.button("Ontologies")
107
+ # if selection4:
108
+ # ontologies()
109
+
110
+ selected_page = st.sidebar.selectbox("Select a page", pages.keys())
111
+ pages[selected_page]()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit
2
+ pandas