|
@@ -79,7 +79,7 @@ def f_project_is_exist(data):
|
|
|
gr.Warning(message='项目名称已被使用', duration=5)
|
|
|
|
|
|
|
|
|
-def f_get_save_path(data, file_name: str, sub_dir="", name_prefix=""):
|
|
|
+def _get_save_path(data, file_name: str, sub_dir="", name_prefix=""):
|
|
|
base_dir = _get_base_dir(data)
|
|
|
save_path = os.path.join(base_dir, sub_dir)
|
|
|
os.makedirs(save_path, exist_ok=True)
|
|
@@ -96,7 +96,7 @@ def f_data_upload(data):
|
|
|
if not _check_save_dir(data):
|
|
|
return
|
|
|
file_data = engine.get(data, "file_data")
|
|
|
- data_path = f_get_save_path(data, file_data.name, DATA_SUB_DIR, UPLOAD_DATA_PREFIX)
|
|
|
+ data_path = _get_save_path(data, file_data.name, DATA_SUB_DIR, UPLOAD_DATA_PREFIX)
|
|
|
shutil.copy(file_data.name, data_path)
|
|
|
df = _get_upload_data(data)
|
|
|
distribution = DataExplore.distribution(df)
|
|
@@ -105,6 +105,14 @@ def f_data_upload(data):
|
|
|
choices=columns), gr.update(choices=columns)
|
|
|
|
|
|
|
|
|
+def f_download_report(data):
|
|
|
+ file_path = _get_save_path(data, "模型报告.docx")
|
|
|
+ if os.path.exists(file_path):
|
|
|
+ return gr.update(value=file_path)
|
|
|
+ else:
|
|
|
+ raise FileNotFoundError(f"{file_path} not found.")
|
|
|
+
|
|
|
+
|
|
|
def f_verify_param(data):
|
|
|
y_column = engine.get(data, "y_column")
|
|
|
if y_column is None:
|
|
@@ -152,4 +160,4 @@ def f_train(data, progress=gr.Progress(track_tqdm=True)):
|
|
|
auc_df = metric_value_dict["模型结果"].table
|
|
|
|
|
|
return gr.update(value="训练完成"), gr.update(value=auc_df, visible=True), \
|
|
|
- gr.update(value=_get_auc_ks_images(data), visible=True)
|
|
|
+ gr.update(value=_get_auc_ks_images(data), visible=True), gr.update(visible=True)
|