Spaces:
Running
Running
Add preflight popup validation for missing HF repo/token before crawl start
Browse files
app.py
CHANGED
|
@@ -607,6 +607,17 @@ def validate_hf_requirements(enable_hf_upload: bool, hf_repo_id: str, hf_token:
|
|
| 607 |
raise ValueError("HF token is required when upload is enabled.")
|
| 608 |
|
| 609 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 610 |
def build_crawler_config(
|
| 611 |
*,
|
| 612 |
seed_urls_input: Any,
|
|
@@ -1123,8 +1134,18 @@ def build_ui() -> gr.Blocks:
|
|
| 1123 |
]
|
| 1124 |
outputs = [status_md, qvp_md, logs_box, token_widget_html]
|
| 1125 |
|
| 1126 |
-
start_button.click(
|
| 1127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1128 |
stop_button.click(stop_crawl, inputs=[], outputs=outputs)
|
| 1129 |
refresh_button.click(poll_dashboard, inputs=[], outputs=outputs)
|
| 1130 |
|
|
|
|
| 607 |
raise ValueError("HF token is required when upload is enabled.")
|
| 608 |
|
| 609 |
|
| 610 |
+
def preflight_validate_start(
|
| 611 |
+
enable_hf_upload: bool,
|
| 612 |
+
hf_repo_id: str,
|
| 613 |
+
hf_token: str,
|
| 614 |
+
) -> None:
|
| 615 |
+
if not bool(enable_hf_upload):
|
| 616 |
+
return
|
| 617 |
+
if not hf_repo_id.strip() or not hf_token.strip():
|
| 618 |
+
raise gr.Error("HF upload is enabled. Enter both HF Repo ID and HF Token first.")
|
| 619 |
+
|
| 620 |
+
|
| 621 |
def build_crawler_config(
|
| 622 |
*,
|
| 623 |
seed_urls_input: Any,
|
|
|
|
| 1134 |
]
|
| 1135 |
outputs = [status_md, qvp_md, logs_box, token_widget_html]
|
| 1136 |
|
| 1137 |
+
start_button.click(
|
| 1138 |
+
preflight_validate_start,
|
| 1139 |
+
inputs=[enable_hf_upload, hf_repo_id, hf_token],
|
| 1140 |
+
outputs=[],
|
| 1141 |
+
queue=False,
|
| 1142 |
+
).then(start_crawl_standard, inputs=start_inputs, outputs=outputs)
|
| 1143 |
+
super_button.click(
|
| 1144 |
+
preflight_validate_start,
|
| 1145 |
+
inputs=[enable_hf_upload, hf_repo_id, hf_token],
|
| 1146 |
+
outputs=[],
|
| 1147 |
+
queue=False,
|
| 1148 |
+
).then(start_crawl_super, inputs=start_inputs, outputs=outputs)
|
| 1149 |
stop_button.click(stop_crawl, inputs=[], outputs=outputs)
|
| 1150 |
refresh_button.click(poll_dashboard, inputs=[], outputs=outputs)
|
| 1151 |
|