Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
proper UI blocking behavior
Browse files
app.py
CHANGED
|
@@ -35,14 +35,15 @@ def progress_update(update_text, percent_complete):
|
|
| 35 |
st.progress(percent_complete / 100)
|
| 36 |
|
| 37 |
|
| 38 |
-
def
|
|
|
|
|
|
|
| 39 |
|
|
|
|
|
|
|
| 40 |
# initialize transcript DataFrame
|
| 41 |
transcripts = pd.DataFrame(columns=[tiger.ID_COL, tiger.SEQ_COL])
|
| 42 |
|
| 43 |
-
# initialize results
|
| 44 |
-
st.session_state.on_target = st.session_state.off_target = None
|
| 45 |
-
|
| 46 |
# manual entry
|
| 47 |
if st.session_state.entry_method == ENTRY_METHODS['manual']:
|
| 48 |
transcripts = pd.DataFrame({
|
|
@@ -95,8 +96,8 @@ if __name__ == '__main__':
|
|
| 95 |
st.session_state.disable_off_target_checkbox = True
|
| 96 |
if 'entry_method' not in st.session_state:
|
| 97 |
st.session_state.entry_method = ENTRY_METHODS['manual']
|
| 98 |
-
if '
|
| 99 |
-
st.session_state.
|
| 100 |
if 'on_target' not in st.session_state:
|
| 101 |
st.session_state.on_target = None
|
| 102 |
if 'off_target' not in st.session_state:
|
|
@@ -114,13 +115,14 @@ if __name__ == '__main__':
|
|
| 114 |
label='What do you want to predict?',
|
| 115 |
options=tuple(tiger.RUN_MODES.values()),
|
| 116 |
key='mode',
|
| 117 |
-
on_change=mode_change_callback
|
|
|
|
| 118 |
)
|
| 119 |
with col2:
|
| 120 |
st.checkbox(
|
| 121 |
label='Find off-target effects (slow)',
|
| 122 |
key='check_off_targets',
|
| 123 |
-
disabled=st.session_state.disable_off_target_checkbox
|
| 124 |
)
|
| 125 |
|
| 126 |
# transcript entry
|
|
@@ -129,22 +131,25 @@ if __name__ == '__main__':
|
|
| 129 |
label='How would you like to provide transcripts of interest?',
|
| 130 |
options=ENTRY_METHODS.values(),
|
| 131 |
key='entry_method',
|
|
|
|
| 132 |
)
|
| 133 |
if st.session_state.entry_method == ENTRY_METHODS['manual']:
|
| 134 |
st.text_input(
|
| 135 |
label='Enter a target transcript:',
|
| 136 |
key='manual_entry',
|
| 137 |
placeholder='Upper or lower case',
|
|
|
|
| 138 |
)
|
| 139 |
elif st.session_state.entry_method == ENTRY_METHODS['fasta']:
|
| 140 |
st.file_uploader(
|
| 141 |
label='Upload a fasta file:',
|
| 142 |
key='fasta_entry',
|
|
|
|
| 143 |
)
|
| 144 |
|
| 145 |
# runtime
|
| 146 |
with RUNTIME:
|
| 147 |
-
st.button(label='Get predictions!', on_click=
|
| 148 |
progress = st.empty()
|
| 149 |
|
| 150 |
# results
|
|
@@ -171,4 +176,10 @@ if __name__ == '__main__':
|
|
| 171 |
mime='text/csv'
|
| 172 |
)
|
| 173 |
else:
|
| 174 |
-
st.write('We did not find any off-target effects!')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
st.progress(percent_complete / 100)
|
| 36 |
|
| 37 |
|
| 38 |
+
def start_running():
|
| 39 |
+
st.session_state.running = True
|
| 40 |
+
st.session_state.on_target = st.session_state.off_target = None
|
| 41 |
|
| 42 |
+
|
| 43 |
+
def run():
|
| 44 |
# initialize transcript DataFrame
|
| 45 |
transcripts = pd.DataFrame(columns=[tiger.ID_COL, tiger.SEQ_COL])
|
| 46 |
|
|
|
|
|
|
|
|
|
|
| 47 |
# manual entry
|
| 48 |
if st.session_state.entry_method == ENTRY_METHODS['manual']:
|
| 49 |
transcripts = pd.DataFrame({
|
|
|
|
| 96 |
st.session_state.disable_off_target_checkbox = True
|
| 97 |
if 'entry_method' not in st.session_state:
|
| 98 |
st.session_state.entry_method = ENTRY_METHODS['manual']
|
| 99 |
+
if 'running' not in st.session_state:
|
| 100 |
+
st.session_state.running = False
|
| 101 |
if 'on_target' not in st.session_state:
|
| 102 |
st.session_state.on_target = None
|
| 103 |
if 'off_target' not in st.session_state:
|
|
|
|
| 115 |
label='What do you want to predict?',
|
| 116 |
options=tuple(tiger.RUN_MODES.values()),
|
| 117 |
key='mode',
|
| 118 |
+
on_change=mode_change_callback,
|
| 119 |
+
disabled=st.session_state.running,
|
| 120 |
)
|
| 121 |
with col2:
|
| 122 |
st.checkbox(
|
| 123 |
label='Find off-target effects (slow)',
|
| 124 |
key='check_off_targets',
|
| 125 |
+
disabled=st.session_state.disable_off_target_checkbox or st.session_state.running
|
| 126 |
)
|
| 127 |
|
| 128 |
# transcript entry
|
|
|
|
| 131 |
label='How would you like to provide transcripts of interest?',
|
| 132 |
options=ENTRY_METHODS.values(),
|
| 133 |
key='entry_method',
|
| 134 |
+
disabled=st.session_state.running
|
| 135 |
)
|
| 136 |
if st.session_state.entry_method == ENTRY_METHODS['manual']:
|
| 137 |
st.text_input(
|
| 138 |
label='Enter a target transcript:',
|
| 139 |
key='manual_entry',
|
| 140 |
placeholder='Upper or lower case',
|
| 141 |
+
disabled=st.session_state.running
|
| 142 |
)
|
| 143 |
elif st.session_state.entry_method == ENTRY_METHODS['fasta']:
|
| 144 |
st.file_uploader(
|
| 145 |
label='Upload a fasta file:',
|
| 146 |
key='fasta_entry',
|
| 147 |
+
disabled=st.session_state.running
|
| 148 |
)
|
| 149 |
|
| 150 |
# runtime
|
| 151 |
with RUNTIME:
|
| 152 |
+
st.button(label='Get predictions!', on_click=start_running, disabled=st.session_state.running)
|
| 153 |
progress = st.empty()
|
| 154 |
|
| 155 |
# results
|
|
|
|
| 176 |
mime='text/csv'
|
| 177 |
)
|
| 178 |
else:
|
| 179 |
+
st.write('We did not find any off-target effects!')
|
| 180 |
+
|
| 181 |
+
# run model
|
| 182 |
+
if st.session_state.running:
|
| 183 |
+
run()
|
| 184 |
+
st.session_state.running = False
|
| 185 |
+
st.experimental_rerun()
|