Spaces:
Running
Running
files
Browse files
app.py
CHANGED
@@ -70,14 +70,18 @@ def create_ui():
|
|
70 |
with gr.Group():
|
71 |
# Validation results
|
72 |
validation_results = gr.HTML(visible=False)
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
81 |
|
82 |
# Define CSS for the validation UI
|
83 |
gr.HTML("""
|
@@ -198,19 +202,9 @@ def create_ui():
|
|
198 |
|
199 |
def on_file_upload(file):
|
200 |
if file is None:
|
201 |
-
return
|
202 |
-
"""<div class="progress-status">Ready for upload</div>""",
|
203 |
-
gr.update(visible=False),
|
204 |
-
gr.update(visible=False),
|
205 |
-
None
|
206 |
-
]
|
207 |
|
208 |
-
return
|
209 |
-
"""<div class="progress-status">β
File uploaded successfully</div>""",
|
210 |
-
gr.update(visible=False),
|
211 |
-
gr.update(visible=False),
|
212 |
-
None
|
213 |
-
]
|
214 |
|
215 |
def fetch_from_url(url):
|
216 |
if not url:
|
@@ -287,45 +281,30 @@ def create_ui():
|
|
287 |
|
288 |
def on_validate(file):
|
289 |
if file is None:
|
290 |
-
return [
|
291 |
-
gr.update(visible=False),
|
292 |
-
gr.update(visible=False),
|
293 |
-
None
|
294 |
-
]
|
295 |
|
296 |
# Process the file and get results
|
297 |
results, report = process_file(file)
|
298 |
|
299 |
-
#
|
300 |
-
|
|
|
|
|
|
|
301 |
|
302 |
return [
|
303 |
build_results_html(results),
|
304 |
-
gr.update(visible=
|
305 |
-
|
306 |
]
|
307 |
|
308 |
# Connect UI events to functions
|
309 |
tabs.select(on_tab_change, None, [active_tab, upload_progress, validation_results])
|
310 |
-
file_input.change(
|
311 |
-
on_file_upload,
|
312 |
-
inputs=file_input,
|
313 |
-
outputs=[upload_progress, validation_results, report_group, report_text]
|
314 |
-
)
|
315 |
validate_btn.click(
|
316 |
on_validate,
|
317 |
inputs=file_input,
|
318 |
-
outputs=[validation_results,
|
319 |
-
)
|
320 |
-
copy_btn.click(
|
321 |
-
on_copy_click,
|
322 |
-
inputs=report_text,
|
323 |
-
outputs=report_text # This triggers the copy
|
324 |
-
)
|
325 |
-
download_btn.click(
|
326 |
-
on_download_click,
|
327 |
-
inputs=[report_text, file_input],
|
328 |
-
outputs=gr.File()
|
329 |
)
|
330 |
fetch_btn.click(fetch_from_url, inputs=url_input, outputs=[upload_progress, validation_results])
|
331 |
|
|
|
70 |
with gr.Group():
|
71 |
# Validation results
|
72 |
validation_results = gr.HTML(visible=False)
|
73 |
+
with gr.Row():
|
74 |
+
report_text = gr.Textbox(
|
75 |
+
label="Detailed Report",
|
76 |
+
visible=False,
|
77 |
+
show_copy_button=True,
|
78 |
+
lines=10
|
79 |
+
)
|
80 |
+
report_md = gr.File(
|
81 |
+
label="Download Report",
|
82 |
+
visible=False,
|
83 |
+
file_types=[".md"]
|
84 |
+
)
|
85 |
|
86 |
# Define CSS for the validation UI
|
87 |
gr.HTML("""
|
|
|
202 |
|
203 |
def on_file_upload(file):
|
204 |
if file is None:
|
205 |
+
return """<div class="progress-status">Ready for upload</div>""", gr.update(visible=False)
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
+
return """<div class="progress-status">β
File uploaded successfully</div>""", gr.update(visible=False)
|
|
|
|
|
|
|
|
|
|
|
208 |
|
209 |
def fetch_from_url(url):
|
210 |
if not url:
|
|
|
281 |
|
282 |
def on_validate(file):
|
283 |
if file is None:
|
284 |
+
return [gr.update(visible=False)] * 3
|
|
|
|
|
|
|
|
|
285 |
|
286 |
# Process the file and get results
|
287 |
results, report = process_file(file)
|
288 |
|
289 |
+
# Save report to file
|
290 |
+
if report:
|
291 |
+
report_path = "validation_report.md"
|
292 |
+
with open(report_path, "w") as f:
|
293 |
+
f.write(report)
|
294 |
|
295 |
return [
|
296 |
build_results_html(results),
|
297 |
+
gr.update(visible=True, value=report) if report else gr.update(visible=False),
|
298 |
+
gr.update(visible=True, value="validation_report.md") if report else gr.update(visible=False)
|
299 |
]
|
300 |
|
301 |
# Connect UI events to functions
|
302 |
tabs.select(on_tab_change, None, [active_tab, upload_progress, validation_results])
|
303 |
+
file_input.change(on_file_upload, inputs=file_input, outputs=[upload_progress, validation_results])
|
|
|
|
|
|
|
|
|
304 |
validate_btn.click(
|
305 |
on_validate,
|
306 |
inputs=file_input,
|
307 |
+
outputs=[validation_results, report_text, report_md]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
)
|
309 |
fetch_btn.click(fetch_from_url, inputs=url_input, outputs=[upload_progress, validation_results])
|
310 |
|