fix redefining outer-scope issues
@@ -123,6 +123,8 @@ st.sidebar.markdown(
)
advanced_mode = st.sidebar.checkbox("Run in Advanced Mode")
+
+def get_gamma_options():
if advanced_mode:
st.sidebar.markdown(
@@ -130,7 +132,7 @@ if advanced_mode:
# Gamma parameters
"""
)
- gamma_options = {
+ result = {
**DEFAULT_GAMMA_OPTIONS,
**{
"dose_percent_threshold": st.sidebar.number_input(
@@ -150,7 +152,12 @@ if advanced_mode:
},
}
else:
- gamma_options = DEFAULT_GAMMA_OPTIONS
+ result = DEFAULT_GAMMA_OPTIONS
+
+ return result
+
+
+gamma_options = get_gamma_options()
st.sidebar.markdown(
@@ -160,7 +167,7 @@ st.sidebar.markdown(
)
-def get_most_recent_file_and_print(linac_id, filepaths): # pylint: redefined-outer-name
+def get_most_recent_file_and_print(linac_id, filepaths):
most_recent = datetime.fromtimestamp(
os.path.getmtime(max(filepaths, key=os.path.getmtime))
)
@@ -174,17 +181,18 @@ def get_most_recent_file_and_print(linac_id, filepaths): # pylint: redefined-ou
st.sidebar.markdown(f"{linac_id}: `{human_readable}`")
-def icom_status(linac_id, icom_directory): # pylint: redefined-outer-name
+def icom_status(linac_id, icom_directory):
filepaths = pathlib.Path(icom_directory).glob("*.txt")
get_most_recent_file_and_print(linac_id, filepaths)
-def trf_status(linac_id, backup_directory): # pylint: redefined-outer-name
+def trf_status(linac_id, backup_directory):
directory = pathlib.Path(backup_directory).joinpath(linac_id)
filepaths = directory.glob("*.zip")
get_most_recent_file_and_print(linac_id, filepaths)
+def show_status_indicators():
if st.sidebar.button("Check status of iCOM and backups"):
st.sidebar.markdown(
"""
@@ -204,12 +212,14 @@ if st.sidebar.button("Check status of iCOM and backups"):
for linac_id in LINAC_IDS:
trf_status(linac_id, LINAC_INDEXED_BACKUPS_DIRECTORY)
-
"""
## Selection of data to compare
"""
+show_status_indicators()
+
+
@st.cache
def delivery_from_icom(icom_stream):
return pymedphys.Delivery.from_icom(icom_stream)
