Fanwang Meng commited on
Commit
27f70b5
1 Parent(s): 3d6fbe8

Add temp patch

Browse files
Files changed (1) hide show
  1. app.py +47 -31
app.py CHANGED
@@ -238,37 +238,53 @@ if "job_button" in st.session_state:
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:
 
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
+ temp_dir = tempfile.mkdtemp()
273
+ # Create a temporary file path for the uploaded file
274
+ temp_file_path = os.path.join(temp_dir, uploaded_file.name)
275
+ # Save the uploaded file to the temporary file path
276
+ with open(temp_file_path, "wb") as temp_file:
277
+ temp_file.write(uploaded_file.read())
278
+ mol_features, info_df, results = generate_predictions(
279
+ input_fname=temp_file_path,
280
+ sep="\s+|\t+",
281
+ clf=classifiers_dict[classifier],
282
+ _models_dict=all_models,
283
+ sampling=resample_methods_dict[resampler],
284
+ time_per_mol=120,
285
+ mol_features=None,
286
+ info_df=None,
287
+ )
288
 
289
  # feture table
290
  with feature_column: