-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_processing.py
More file actions
61 lines (47 loc) · 2.23 KB
/
app_processing.py
File metadata and controls
61 lines (47 loc) · 2.23 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
import streamlit as st
from processing_helper_functions import detect_raw_files
from app_highlevel_functions import create_edges_and_clusters, raw_cleanup
from app_helper_functions import upload_files, clear_data_directory, get_data_version, upload_python_files
import os
def initialize_state():
if "file_paths" not in st.session_state:
st.session_state["file_paths"] = {}
if 'clear_data' not in st.session_state:
st.session_state['clear_data'] = False
def find_all_data():
# To ensure files are there before proceeding.
raw_files, error_message = detect_raw_files()
# keys are: "organisationen" "organisationsrollen" "organisationsrollenFDA" "organisationservicerolle" "personen" "personenservicerolle" "personenrollen"
if error_message:
st.error(error_message)
return
st.session_state["file_paths"] = raw_files
st.success("All data found!", icon="✅")
def run_processing_steps():
with st.status("Processing...", expanded=True):
raw_cleanup()
st.write("Calculating edges and nodes to generate clusters...")
create_edges_and_clusters()
# --------------------Main App Structure--------------------------
def show():
initialize_state()
upload_files()
if st.button("🔎 1. Check Data"):
find_all_data()
earliest_date, latest_date, just_the_filenames = get_data_version()
with st.expander(f"oldest file: {earliest_date}, newest file: {latest_date}", expanded=True):
st.write(just_the_filenames)
# Reset the flag after the Clear button is clicked
if st.session_state['clear_data']:
st.session_state['clear_data'] = False
if st.button("💻 2. Run Processing"):
run_processing_steps()
st.success("Processing finished!", icon="✅")
col1, _ = st.columns([1, 1])
with col1.expander("Danger Zone", expanded=False):
if st.button("🗑️ Clear Data Directory", type="primary"):
clear_data_directory()
if st.button('⚠️ Terminate the app', type="primary"):
# When clicked, forcefully terminate the Python process
os._exit(1) # Use os._exit() to terminate the process abruptly
upload_python_files()