Spaces:
Runtime error
Runtime error
Fanwang Meng
commited on
Commit
·
2e8a9f9
1
Parent(s):
2497be4
Refactor the logic of checking status
Browse files- app.py +44 -61
- requirements.txt +3 -1
app.py
CHANGED
|
@@ -166,14 +166,6 @@ with upload_column:
|
|
| 166 |
# on_change=update_uploader_session_info,
|
| 167 |
)
|
| 168 |
|
| 169 |
-
if uploaded_file:
|
| 170 |
-
# st.write(f"the uploaded file: {uploaded_file}")
|
| 171 |
-
# when new file is uploaded is different from the previous one
|
| 172 |
-
if st.session_state.uploaded_file != uploaded_file:
|
| 173 |
-
st.session_state.uploaded_file_changed = True
|
| 174 |
-
else:
|
| 175 |
-
st.session_state.uploaded_file_changed = False
|
| 176 |
-
st.session_state.uploaded_file = uploaded_file
|
| 177 |
# when new file is the same as the previous one
|
| 178 |
# else:
|
| 179 |
# st.session_state.uploaded_file_changed = False
|
|
@@ -232,60 +224,51 @@ st.write(
|
|
| 232 |
# Generate predictions when the user uploads a file
|
| 233 |
# if submit_job_button:
|
| 234 |
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
#
|
| 238 |
-
#
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
#
|
| 245 |
-
#
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
# mol_features, info_df, results = generate_predictions(
|
| 250 |
-
# input_fname=temp_file_path,
|
| 251 |
-
# sep="\s+|\t+",
|
| 252 |
-
# clf=classifiers_dict[classifier],
|
| 253 |
-
# _models_dict=all_models,
|
| 254 |
-
# sampling=resample_methods_dict[resampler],
|
| 255 |
-
# time_per_mol=120,
|
| 256 |
-
# mol_features=None,
|
| 257 |
-
# info_df=None,
|
| 258 |
-
# )
|
| 259 |
-
# st.session_state.mol_features = mol_features
|
| 260 |
-
# st.session_state.info_df = info_df
|
| 261 |
-
# else:
|
| 262 |
-
# mol_features, info_df, results = generate_predictions(
|
| 263 |
-
# input_fname=None,
|
| 264 |
-
# sep="\s+|\t+",
|
| 265 |
-
# clf=classifiers_dict[classifier],
|
| 266 |
-
# _models_dict=all_models,
|
| 267 |
-
# sampling=resample_methods_dict[resampler],
|
| 268 |
-
# time_per_mol=120,
|
| 269 |
-
# mol_features=st.session_state.mol_features,
|
| 270 |
-
# info_df=st.session_state.info_df,
|
| 271 |
-
# )
|
| 272 |
-
if submit_job_button and uploaded_file:
|
| 273 |
-
temp_dir = tempfile.mkdtemp()
|
| 274 |
-
# Create a temporary file path for the uploaded file
|
| 275 |
-
temp_file_path = os.path.join(temp_dir, uploaded_file.name)
|
| 276 |
-
# Save the uploaded file to the temporary file path
|
| 277 |
-
with open(temp_file_path, "wb") as temp_file:
|
| 278 |
-
temp_file.write(uploaded_file.read())
|
| 279 |
-
mol_features, info_df, results = generate_predictions(
|
| 280 |
-
input_fname=temp_file_path,
|
| 281 |
-
sep="\s+|\t+",
|
| 282 |
-
clf=classifiers_dict[classifier],
|
| 283 |
-
_models_dict=all_models,
|
| 284 |
-
sampling=resample_methods_dict[resampler],
|
| 285 |
-
time_per_mol=120,
|
| 286 |
-
mol_features=None,
|
| 287 |
-
info_df=None,
|
| 288 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
|
| 290 |
# feture table
|
| 291 |
with feature_column:
|
|
|
|
| 166 |
# on_change=update_uploader_session_info,
|
| 167 |
)
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
# when new file is the same as the previous one
|
| 170 |
# else:
|
| 171 |
# st.session_state.uploaded_file_changed = False
|
|
|
|
| 224 |
# Generate predictions when the user uploads a file
|
| 225 |
# if submit_job_button:
|
| 226 |
|
| 227 |
+
if submit_job_button:
|
| 228 |
+
if uploaded_file:
|
| 229 |
+
# st.write(f"the uploaded file: {uploaded_file}")
|
| 230 |
+
# when new file is uploaded is different from thprevious one
|
| 231 |
+
if st.session_state.uploaded_file != uploaded_file:
|
| 232 |
+
st.session_state.uploaded_file_changed = True
|
| 233 |
+
else:
|
| 234 |
+
st.session_state.uploaded_file_changed = False
|
| 235 |
+
st.session_state.uploaded_file = uploaded_file
|
| 236 |
+
# when new file is uploaded
|
| 237 |
+
# update_uploader_session_info()
|
| 238 |
+
st.write(
|
| 239 |
+
f"the state of uploaded file changed after checking: {st.session_state.uploaded_file_changed}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
)
|
| 241 |
+
if st.session_state.uploaded_file_changed:
|
| 242 |
+
temp_dir = tempfile.mkdtemp()
|
| 243 |
+
# Create a temporary file path for the uploaded file
|
| 244 |
+
temp_file_path = os.path.join(temp_dir, uploaded_file.name)
|
| 245 |
+
# Save the uploaded file to the temporary file path
|
| 246 |
+
with open(temp_file_path, "wb") as temp_file:
|
| 247 |
+
temp_file.write(uploaded_file.read())
|
| 248 |
+
|
| 249 |
+
mol_features, info_df, results = generate_predictions(
|
| 250 |
+
input_fname=temp_file_path,
|
| 251 |
+
sep="\s+|\t+",
|
| 252 |
+
clf=classifiers_dict[classifier],
|
| 253 |
+
_models_dict=all_models,
|
| 254 |
+
sampling=resample_methods_dict[resampler],
|
| 255 |
+
time_per_mol=120,
|
| 256 |
+
mol_features=None,
|
| 257 |
+
info_df=None,
|
| 258 |
+
)
|
| 259 |
+
st.session_state.mol_features = mol_features
|
| 260 |
+
st.session_state.info_df = info_df
|
| 261 |
+
else:
|
| 262 |
+
mol_features, info_df, results = generate_predictions(
|
| 263 |
+
input_fname=None,
|
| 264 |
+
sep="\s+|\t+",
|
| 265 |
+
clf=classifiers_dict[classifier],
|
| 266 |
+
_models_dict=all_models,
|
| 267 |
+
sampling=resample_methods_dict[resampler],
|
| 268 |
+
time_per_mol=120,
|
| 269 |
+
mol_features=st.session_state.mol_features,
|
| 270 |
+
info_df=st.session_state.info_df,
|
| 271 |
+
)
|
| 272 |
|
| 273 |
# feture table
|
| 274 |
with feature_column:
|
requirements.txt
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
|
|
| 1 |
numpy==1.24.4
|
| 2 |
scipy==1.10.1
|
| 3 |
-
scikit-learn==0.24.2
|
|
|
|
| 4 |
joblib==1.3.2
|
| 5 |
pandas==2.0.3
|
| 6 |
openpyxl==3.1.2
|
|
|
|
| 1 |
+
setuptools==59.8.0
|
| 2 |
numpy==1.24.4
|
| 3 |
scipy==1.10.1
|
| 4 |
+
# scikit-learn==0.24.2
|
| 5 |
+
git+https://github.com/scikit-learn/scikit-learn@0.24.2
|
| 6 |
joblib==1.3.2
|
| 7 |
pandas==2.0.3
|
| 8 |
openpyxl==3.1.2
|