Skip to content

Commit 11e77f9

Browse files
committed
Constants at the top of the file for my sanity
1 parent d4d273a commit 11e77f9

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

app_llm.py

+26-28
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,32 @@
1212
from msfocr.doctr import ocr_functions as doctr_ocr_functions
1313
from msfocr.llm import ocr_functions
1414

15-
# Wrapper functions
1615

16+
# Hardcoded period types and formatting, probably won't update but can get them through API
17+
PERIOD_TYPES = {
18+
"Daily": "{year}{month}{day}",
19+
"Weekly": "{year}W{week}",
20+
"WeeklyWednesday": "{year}WedW{week}",
21+
"WeeklyThursday": "{year}ThuW{week}",
22+
"WeeklySaturday": "{year}SatW{week}",
23+
"WeeklySunday": "{year}SunW{week}",
24+
"BiWeekly": "{year}Bi{week}",
25+
"Monthly": "{year}{month}",
26+
"BiMonthly": "{year}{month}B",
27+
"Quarterly": "{year}{quarter_number}",
28+
"SixMonthly": "{year}{semiyear_number}",
29+
"SixMonthlyApril": "{year}April{semiyear_number}",
30+
"SixMonthlyNovember": "{year}Nov{semiyear_number}",
31+
"Yearly": "{year}",
32+
"FinancialApril": "{year}April",
33+
"FinancialJuly": "{year}July",
34+
"FinancialOct": "{year}Oct",
35+
"FinancialNov": "{year}Nov",
36+
}
37+
38+
PAGE_REVIEWED_INDICATOR = "✓"
39+
40+
# Wrapper functions
1741
@st.cache_data(show_spinner=False)
1842
def get_results_wrapper(tally_sheet):
1943
"""A wrapper function for caching the get_results function."""
@@ -243,36 +267,12 @@ def evaluate_cells(table_dfs):
243267
return table_dfs
244268

245269

246-
247-
PAGE_REVIEWED_INDICATOR = "✓"
248-
249270
# Initializing session state variables that only need to be set on startup
250271
if "initialised" not in st.session_state:
251272
st.session_state['initialised'] = True
252273
st.session_state['upload_key'] = 1000
253274
st.session_state['password_correct'] = False
254275

255-
# Hardcoded period types and formatting, probably won't update but can get them through API
256-
PERIOD_TYPES = {
257-
"Daily": "{year}{month}{day}",
258-
"Weekly": "{year}W{week}",
259-
"WeeklyWednesday": "{year}WedW{week}",
260-
"WeeklyThursday": "{year}ThuW{week}",
261-
"WeeklySaturday": "{year}SatW{week}",
262-
"WeeklySunday": "{year}SunW{week}",
263-
"BiWeekly": "{year}Bi{week}",
264-
"Monthly": "{year}{month}",
265-
"BiMonthly": "{year}{month}B",
266-
"Quarterly": "{year}{quarter_number}",
267-
"SixMonthly": "{year}{semiyear_number}",
268-
"SixMonthlyApril": "{year}April{semiyear_number}",
269-
"SixMonthlyNovember": "{year}Nov{semiyear_number}",
270-
"Yearly": "{year}",
271-
"FinancialApril": "{year}April",
272-
"FinancialJuly": "{year}July",
273-
"FinancialOct": "{year}Oct",
274-
"FinancialNov": "{year}Nov",
275-
}
276276

277277
# *****Page display*****
278278

@@ -283,8 +283,6 @@ def evaluate_cells(table_dfs):
283283
server_url = os.environ["DHIS2_SERVER_URL"]
284284
dhis2.configure_DHIS2_server(server_url = server_url)
285285

286-
API_URL = f'{dhis2.DHIS2_SERVER_URL}/api/33/me'
287-
288286
# Initialize session state variables
289287
if 'authenticated' not in st.session_state:
290288
st.session_state['authenticated'] = False
@@ -298,7 +296,7 @@ def evaluate_cells(table_dfs):
298296
placeholder = st.empty()
299297

300298
def authenticate():
301-
response = requests.get(API_URL, auth=HTTPBasicAuth(st.session_state['username'], st.session_state['password']))
299+
response = requests.get(f'{dhis2.DHIS2_SERVER_URL}/api/33/me', auth=HTTPBasicAuth(st.session_state['username'], st.session_state['password']))
302300
if response.status_code == 200:
303301
st.session_state['authenticated'] = True
304302
st.session_state['auth_failed'] = False

0 commit comments

Comments
 (0)