Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
anjus1313 committed Aug 7, 2024
1 parent 91a1c32 commit ebd2def
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions app_doctr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import copy
import json
import os

import pandas as pd
import requests
import streamlit as st
from requests.auth import HTTPBasicAuth
Expand Down Expand Up @@ -43,11 +43,6 @@
PAGE_REVIEWED_INDICATOR = "✓"

# Wrapper functions
@st.cache_data(show_spinner=False)
def get_results_wrapper(tally_sheet):
"""A wrapper function for caching the get_results function."""
return ocr_functions.get_results(tally_sheet)

@st.cache_resource
def create_ocr():
"""
Expand Down Expand Up @@ -396,9 +391,7 @@ def authenticate():
if 'page_nums' in st.session_state:
del st.session_state['page_nums']
if 'pages_confirmed' in st.session_state:
del st.session_state['pages_confirmed']
if 'execute_once' in st.session_state:
del st.session_state['execute_once']
del st.session_state['pages_confirmed']
st.rerun()

# Sidebar for header data
Expand Down Expand Up @@ -489,9 +482,7 @@ def authenticate():
if 'data_payload' not in st.session_state:
st.session_state.data_payload = None
if 'pages_confirmed' not in st.session_state:
st.session_state['pages_confirmed'] = False
if 'execute_once' not in st.session_state:
st.session_state['execute_once'] = True
st.session_state['pages_confirmed'] = False

# Displaying the editable information
# Used for multipage selection functionality
Expand All @@ -508,6 +499,7 @@ def authenticate():
# Uploading the tables, adding columns for each name
for i, (df, page_num) in enumerate(zip(st.session_state.table_dfs, st.session_state.page_nums)):
if page_num != page_selected:
table_dfs[i] = pd.DataFrame(df)
continue
int_page_num = int(page_num.replace(PAGE_REVIEWED_INDICATOR, "").strip())
st.write(f"Table {i + 1}")
Expand Down Expand Up @@ -558,8 +550,6 @@ def authenticate():
save_st_table(table_dfs)
st.rerun()

st.write(st.session_state.table_dfs)
st.write(table_dfs)
# Generate and display key-value pairs button
if st.button("Generate key value pairs", type="primary", disabled=not st.session_state.pages_confirmed):
try:
Expand Down

0 comments on commit ebd2def

Please sign in to comment.