Remove visual table artifacts
Browse files
derived/Source/scripts/__pycache__/generate_visual_table.cpython-311.pyc
DELETED
|
Binary file (7.05 kB)
|
|
|
derived/Source/scripts/generate_visual_table.py
DELETED
|
@@ -1,145 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
|
| 3 |
-
from __future__ import annotations
|
| 4 |
-
|
| 5 |
-
import csv
|
| 6 |
-
import html
|
| 7 |
-
import json
|
| 8 |
-
import os
|
| 9 |
-
from pathlib import Path
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
REPO_ROOT = Path("/workspace/SchemID")
|
| 13 |
-
SOURCE_ROOT = REPO_ROOT / "derived" / "Source"
|
| 14 |
-
ROWS_PATH = SOURCE_ROOT / "metadata" / "rows.jsonl"
|
| 15 |
-
VIS_ROOT = SOURCE_ROOT / "visuals"
|
| 16 |
-
CSV_PATH = VIS_ROOT / "four_column_table.csv"
|
| 17 |
-
HTML_PATH = VIS_ROOT / "four_column_table.html"
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
def rel_to_visuals(path: Path) -> str:
|
| 21 |
-
return os.path.relpath(path, VIS_ROOT)
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
def image_rel(path_str: str) -> str:
|
| 25 |
-
path = Path(path_str)
|
| 26 |
-
return rel_to_visuals(path)
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
def main() -> None:
|
| 30 |
-
VIS_ROOT.mkdir(parents=True, exist_ok=True)
|
| 31 |
-
|
| 32 |
-
rows: list[dict[str, str]] = []
|
| 33 |
-
with ROWS_PATH.open() as handle:
|
| 34 |
-
for line in handle:
|
| 35 |
-
raw = json.loads(line)
|
| 36 |
-
source_payload = json.loads(raw["Source"])
|
| 37 |
-
original_path = Path(raw["Circuit generated image"])
|
| 38 |
-
no_text_path = Path(raw["Circuit Generated image with no text"])
|
| 39 |
-
eps_path = SOURCE_ROOT / source_payload["eps_path"]
|
| 40 |
-
row = {
|
| 41 |
-
"Circuit Generation Code": raw["Circuit Generation Code"],
|
| 42 |
-
"Circuit generated image": image_rel(str(original_path)),
|
| 43 |
-
"Circuit Generated image with no text": image_rel(str(no_text_path)),
|
| 44 |
-
"Source": json.dumps(source_payload, sort_keys=True),
|
| 45 |
-
"Code File": rel_to_visuals(eps_path),
|
| 46 |
-
}
|
| 47 |
-
rows.append(row)
|
| 48 |
-
|
| 49 |
-
with CSV_PATH.open("w", newline="") as handle:
|
| 50 |
-
writer = csv.DictWriter(
|
| 51 |
-
handle,
|
| 52 |
-
fieldnames=[
|
| 53 |
-
"Circuit Generation Code",
|
| 54 |
-
"Circuit generated image",
|
| 55 |
-
"Circuit Generated image with no text",
|
| 56 |
-
"Source",
|
| 57 |
-
"Code File",
|
| 58 |
-
],
|
| 59 |
-
)
|
| 60 |
-
writer.writeheader()
|
| 61 |
-
writer.writerows(rows)
|
| 62 |
-
|
| 63 |
-
parts = [
|
| 64 |
-
"<!doctype html>",
|
| 65 |
-
"<html lang='en'>",
|
| 66 |
-
"<head>",
|
| 67 |
-
"<meta charset='utf-8'>",
|
| 68 |
-
"<meta name='viewport' content='width=device-width, initial-scale=1'>",
|
| 69 |
-
"<title>SchemID 4-Column Circuit Table</title>",
|
| 70 |
-
"<style>",
|
| 71 |
-
"body { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 0; background: #f5f5f5; color: #111; }",
|
| 72 |
-
".wrap { padding: 16px; }",
|
| 73 |
-
"h1 { margin: 0 0 8px; font-size: 24px; }",
|
| 74 |
-
"p { margin: 0 0 12px; }",
|
| 75 |
-
"a { color: #0b57d0; }",
|
| 76 |
-
".meta { margin-bottom: 16px; }",
|
| 77 |
-
"table { border-collapse: collapse; width: 100%; background: #fff; table-layout: fixed; }",
|
| 78 |
-
"thead th { position: sticky; top: 0; background: #ececec; z-index: 1; }",
|
| 79 |
-
"th, td { border: 1px solid #ccc; padding: 8px; vertical-align: top; }",
|
| 80 |
-
"th:nth-child(1), td:nth-child(1) { width: 38%; }",
|
| 81 |
-
"th:nth-child(2), td:nth-child(2) { width: 18%; }",
|
| 82 |
-
"th:nth-child(3), td:nth-child(3) { width: 18%; }",
|
| 83 |
-
"th:nth-child(4), td:nth-child(4) { width: 26%; }",
|
| 84 |
-
"pre { margin: 0; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; }",
|
| 85 |
-
".imgbox { background: #fff; min-height: 120px; display: flex; align-items: center; justify-content: center; }",
|
| 86 |
-
"img { max-width: 100%; height: auto; border: 1px solid #ddd; background: #fff; }",
|
| 87 |
-
".source { max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word; }",
|
| 88 |
-
".small { font-size: 12px; color: #555; margin-top: 6px; }",
|
| 89 |
-
"</style>",
|
| 90 |
-
"</head>",
|
| 91 |
-
"<body>",
|
| 92 |
-
"<div class='wrap'>",
|
| 93 |
-
"<h1>SchemID 4-Column Circuit Table</h1>",
|
| 94 |
-
f"<p class='meta'>Rows: {len(rows)}. CSV companion: <a href='four_column_table.csv'>four_column_table.csv</a>.</p>",
|
| 95 |
-
"<table>",
|
| 96 |
-
"<thead><tr><th>Circuit Generation Code</th><th>Circuit generated image</th><th>Circuit Generated image with no text</th><th>Source</th></tr></thead>",
|
| 97 |
-
"<tbody>",
|
| 98 |
-
]
|
| 99 |
-
|
| 100 |
-
for row in rows:
|
| 101 |
-
code_text = html.escape(row["Circuit Generation Code"])
|
| 102 |
-
source_text = html.escape(row["Source"])
|
| 103 |
-
code_file = html.escape(row["Code File"])
|
| 104 |
-
original_rel = html.escape(row["Circuit generated image"])
|
| 105 |
-
no_text_rel = html.escape(row["Circuit Generated image with no text"])
|
| 106 |
-
parts.extend(
|
| 107 |
-
[
|
| 108 |
-
"<tr>",
|
| 109 |
-
(
|
| 110 |
-
"<td>"
|
| 111 |
-
f"<pre>{code_text}</pre>"
|
| 112 |
-
f"<div class='small'>File: <a href='{code_file}'>{code_file}</a></div>"
|
| 113 |
-
"</td>"
|
| 114 |
-
),
|
| 115 |
-
(
|
| 116 |
-
"<td>"
|
| 117 |
-
f"<div class='imgbox'><a href='{original_rel}'><img loading='lazy' src='{original_rel}' alt='original circuit'></a></div>"
|
| 118 |
-
f"<div class='small'><a href='{original_rel}'>{original_rel}</a></div>"
|
| 119 |
-
"</td>"
|
| 120 |
-
),
|
| 121 |
-
(
|
| 122 |
-
"<td>"
|
| 123 |
-
f"<div class='imgbox'><a href='{no_text_rel}'><img loading='lazy' src='{no_text_rel}' alt='no-text circuit'></a></div>"
|
| 124 |
-
f"<div class='small'><a href='{no_text_rel}'>{no_text_rel}</a></div>"
|
| 125 |
-
"</td>"
|
| 126 |
-
),
|
| 127 |
-
f"<td><div class='source'>{source_text}</div></td>",
|
| 128 |
-
"</tr>",
|
| 129 |
-
]
|
| 130 |
-
)
|
| 131 |
-
|
| 132 |
-
parts.extend(
|
| 133 |
-
[
|
| 134 |
-
"</tbody>",
|
| 135 |
-
"</table>",
|
| 136 |
-
"</div>",
|
| 137 |
-
"</body>",
|
| 138 |
-
"</html>",
|
| 139 |
-
]
|
| 140 |
-
)
|
| 141 |
-
HTML_PATH.write_text("\n".join(parts))
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
if __name__ == "__main__":
|
| 145 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
derived/Source/visuals/four_column_table.csv
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:2844412f9a7c39bd5532d1068922cb0177990a3735a706f349992812c769d36a
|
| 3 |
-
size 22668056
|
|
|
|
|
|
|
|
|
|
|
|
derived/Source/visuals/four_column_table.html
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:ffc81c8d3c9341e41b2b727b2b8db2998b671e314f95014078615b643fac7196
|
| 3 |
-
size 24648297
|
|
|
|
|
|
|
|
|
|
|
|