Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- app.py +12 -11
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -14,6 +14,7 @@ Run locally:
|
|
| 14 |
python space-diagram-builder/app.py
|
| 15 |
"""
|
| 16 |
|
|
|
|
| 17 |
import sys
|
| 18 |
from pathlib import Path
|
| 19 |
|
|
@@ -237,7 +238,7 @@ def _build_diagram(modules_text, wires_text):
|
|
| 237 |
return None, (
|
| 238 |
f'<div style="padding:12px;background:#fef2f2;border:2px solid #fca5a5;'
|
| 239 |
f'border-radius:8px;color:#991b1b">'
|
| 240 |
-
f'<strong>Parse error:</strong> {e}</div>'
|
| 241 |
)
|
| 242 |
|
| 243 |
# Collect ports needed per module
|
|
@@ -277,7 +278,7 @@ def _badge(text, color="#6366f1"):
|
|
| 277 |
return (
|
| 278 |
f'<span style="display:inline-block;padding:4px 12px;border-radius:6px;'
|
| 279 |
f'background:{color};color:#fff;font-weight:600;margin:2px">'
|
| 280 |
-
f'{text}</span>'
|
| 281 |
)
|
| 282 |
|
| 283 |
|
|
@@ -291,7 +292,7 @@ def _progress_bar(value, max_val, label, color="#6366f1"):
|
|
| 291 |
return (
|
| 292 |
f'<div style="margin:4px 0">'
|
| 293 |
f'<div style="display:flex;justify-content:space-between;font-size:0.85em;margin-bottom:2px">'
|
| 294 |
-
f'<span>{label}</span><span style="font-weight:600">{value:.3f}</span></div>'
|
| 295 |
f'<div style="background:#e5e7eb;border-radius:4px;height:14px;overflow:hidden">'
|
| 296 |
f'<div style="background:{color};height:100%;width:{pct:.1f}%;border-radius:4px">'
|
| 297 |
f'</div></div></div>'
|
|
@@ -308,9 +309,9 @@ def _profile_table_html(profiles):
|
|
| 308 |
denat = "Yes" if p.has_denature_filter else "-"
|
| 309 |
rows.append(
|
| 310 |
f"<tr>"
|
| 311 |
-
f"<td style='padding:4px 8px;font-weight:600'>{name}</td>"
|
| 312 |
-
f"<td style='padding:4px 8px'>{direct}</td>"
|
| 313 |
-
f"<td style='padding:4px 8px'>{trans}</td>"
|
| 314 |
f"<td style='padding:4px 8px;text-align:center'>{p.observation_width}</td>"
|
| 315 |
f"<td style='padding:4px 8px;text-align:center'>{optic}</td>"
|
| 316 |
f"<td style='padding:4px 8px;text-align:center'>{denat}</td>"
|
|
@@ -335,7 +336,7 @@ def _full_analysis_html(diagram, detection_rate, comm_cost_ratio):
|
|
| 335 |
"""Run full analysis and return combined HTML."""
|
| 336 |
cls = classify_topology(diagram)
|
| 337 |
tb = _topology_badge(cls.topology_class)
|
| 338 |
-
hub = cls.hub_module
|
| 339 |
|
| 340 |
profiles = observation_profiles(diagram)
|
| 341 |
prof_html = _profile_table_html(profiles)
|
|
@@ -343,7 +344,7 @@ def _full_analysis_html(diagram, detection_rate, comm_cost_ratio):
|
|
| 343 |
part = epistemic_partition(diagram)
|
| 344 |
part_parts = []
|
| 345 |
for i, eq_class in enumerate(part.equivalence_classes, 1):
|
| 346 |
-
members = ", ".join(sorted(eq_class))
|
| 347 |
part_parts.append(f'<span style="margin-right:12px">Class {i}: [{members}]</span>')
|
| 348 |
|
| 349 |
eb = error_amplification_bound(diagram, detection_rate=detection_rate)
|
|
@@ -440,12 +441,12 @@ def _run_compare(
|
|
| 440 |
td_b = tool_density(diag_b)
|
| 441 |
|
| 442 |
def _row(label, val_a, val_b, fmt="{}", highlight=False):
|
| 443 |
-
a_str = fmt.format(val_a)
|
| 444 |
-
b_str = fmt.format(val_b)
|
| 445 |
style = "font-weight:600;" if highlight else ""
|
| 446 |
return (
|
| 447 |
f"<tr>"
|
| 448 |
-
f"<td style='padding:4px 10px;{style}'>{label}</td>"
|
| 449 |
f"<td style='padding:4px 10px;text-align:center;{style}'>{a_str}</td>"
|
| 450 |
f"<td style='padding:4px 10px;text-align:center;{style}'>{b_str}</td>"
|
| 451 |
f"</tr>"
|
|
|
|
| 14 |
python space-diagram-builder/app.py
|
| 15 |
"""
|
| 16 |
|
| 17 |
+
import html
|
| 18 |
import sys
|
| 19 |
from pathlib import Path
|
| 20 |
|
|
|
|
| 238 |
return None, (
|
| 239 |
f'<div style="padding:12px;background:#fef2f2;border:2px solid #fca5a5;'
|
| 240 |
f'border-radius:8px;color:#991b1b">'
|
| 241 |
+
f'<strong>Parse error:</strong> {html.escape(str(e))}</div>'
|
| 242 |
)
|
| 243 |
|
| 244 |
# Collect ports needed per module
|
|
|
|
| 278 |
return (
|
| 279 |
f'<span style="display:inline-block;padding:4px 12px;border-radius:6px;'
|
| 280 |
f'background:{color};color:#fff;font-weight:600;margin:2px">'
|
| 281 |
+
f'{html.escape(str(text))}</span>'
|
| 282 |
)
|
| 283 |
|
| 284 |
|
|
|
|
| 292 |
return (
|
| 293 |
f'<div style="margin:4px 0">'
|
| 294 |
f'<div style="display:flex;justify-content:space-between;font-size:0.85em;margin-bottom:2px">'
|
| 295 |
+
f'<span>{html.escape(str(label))}</span><span style="font-weight:600">{value:.3f}</span></div>'
|
| 296 |
f'<div style="background:#e5e7eb;border-radius:4px;height:14px;overflow:hidden">'
|
| 297 |
f'<div style="background:{color};height:100%;width:{pct:.1f}%;border-radius:4px">'
|
| 298 |
f'</div></div></div>'
|
|
|
|
| 309 |
denat = "Yes" if p.has_denature_filter else "-"
|
| 310 |
rows.append(
|
| 311 |
f"<tr>"
|
| 312 |
+
f"<td style='padding:4px 8px;font-weight:600'>{html.escape(name)}</td>"
|
| 313 |
+
f"<td style='padding:4px 8px'>{html.escape(direct)}</td>"
|
| 314 |
+
f"<td style='padding:4px 8px'>{html.escape(trans)}</td>"
|
| 315 |
f"<td style='padding:4px 8px;text-align:center'>{p.observation_width}</td>"
|
| 316 |
f"<td style='padding:4px 8px;text-align:center'>{optic}</td>"
|
| 317 |
f"<td style='padding:4px 8px;text-align:center'>{denat}</td>"
|
|
|
|
| 336 |
"""Run full analysis and return combined HTML."""
|
| 337 |
cls = classify_topology(diagram)
|
| 338 |
tb = _topology_badge(cls.topology_class)
|
| 339 |
+
hub = html.escape(cls.hub_module) if cls.hub_module else "-"
|
| 340 |
|
| 341 |
profiles = observation_profiles(diagram)
|
| 342 |
prof_html = _profile_table_html(profiles)
|
|
|
|
| 344 |
part = epistemic_partition(diagram)
|
| 345 |
part_parts = []
|
| 346 |
for i, eq_class in enumerate(part.equivalence_classes, 1):
|
| 347 |
+
members = html.escape(", ".join(sorted(eq_class)))
|
| 348 |
part_parts.append(f'<span style="margin-right:12px">Class {i}: [{members}]</span>')
|
| 349 |
|
| 350 |
eb = error_amplification_bound(diagram, detection_rate=detection_rate)
|
|
|
|
| 441 |
td_b = tool_density(diag_b)
|
| 442 |
|
| 443 |
def _row(label, val_a, val_b, fmt="{}", highlight=False):
|
| 444 |
+
a_str = html.escape(fmt.format(val_a))
|
| 445 |
+
b_str = html.escape(fmt.format(val_b))
|
| 446 |
style = "font-weight:600;" if highlight else ""
|
| 447 |
return (
|
| 448 |
f"<tr>"
|
| 449 |
+
f"<td style='padding:4px 10px;{style}'>{html.escape(str(label))}</td>"
|
| 450 |
f"<td style='padding:4px 10px;text-align:center;{style}'>{a_str}</td>"
|
| 451 |
f"<td style='padding:4px 10px;text-align:center;{style}'>{b_str}</td>"
|
| 452 |
f"</tr>"
|
requirements.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
gradio>=4.0
|
| 2 |
-
operon-ai>=0.
|
|
|
|
| 1 |
gradio>=4.0
|
| 2 |
+
operon-ai>=0.29.0
|