Skip to content

Commit 2b91768

Browse files
committed
Add Manifest to website
Closes #9
1 parent 7608c7b commit 2b91768

File tree

2 files changed

+45
-13
lines changed

2 files changed

+45
-13
lines changed

.github/workflows/generate_website.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
# Forward step outputs to job outputs
2020
model_keys: ${{ steps.keys.outputs.model_keys }}
2121
adtype_keys: ${{ steps.keys.outputs.adtype_keys }}
22+
manifest: ${{ steps.keys.outputs.manifest }}
2223

2324
steps:
2425
- uses: actions/checkout@v4
@@ -98,6 +99,7 @@ jobs:
9899
- run: uv run ad.py html
99100
env:
100101
RESULTS_JSON: ${{ needs.run-models.outputs.json }}
102+
MANIFEST: ${{ needs.setup-keys.outputs.manifest }}
101103

102104
- name: Upload results
103105
uses: peaceiris/actions-gh-pages@v4

ad.py

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,23 @@ def append_to_github_output(key, value):
3737
print(f"GITHUB_OUTPUT not set")
3838
print(pair)
3939

40+
def get_manifest_dict():
41+
with open("Manifest.toml", "rb") as f:
42+
manifest_data = tomllib.load(f)
43+
package_versions = {k: v[0].get("version", None) for k, v in manifest_data["deps"].items()}
44+
return package_versions
45+
4046
def setup(_args):
47+
# Model keys
4148
models = run_and_capture([*JULIA_COMMAND, "--list-model-keys"]).splitlines()
42-
adtypes = run_and_capture([*JULIA_COMMAND, "--list-adtype-keys"]).splitlines()
4349
append_to_github_output("model_keys", models)
50+
# Adtype keys
51+
adtypes = run_and_capture([*JULIA_COMMAND, "--list-adtype-keys"]).splitlines()
4452
append_to_github_output("adtype_keys", adtypes)
45-
# TODO: Save the Manifest.toml file or at least a mapping of packages ->
46-
# versions, see #9
53+
# Manifest
54+
package_versions = get_manifest_dict()
55+
append_to_github_output("manifest", package_versions)
56+
4757

4858
def run_ad(args):
4959
model_key = args.model
@@ -91,12 +101,9 @@ def html(_args):
91101
("assume_wishart", "EnzymeForward"): ENZYME_FWD_BLAS,
92102
}
93103

94-
results = os.environ.get("RESULTS_JSON", None)
95104

96-
if results is None:
97-
print("RESULTS_JSON not set")
98-
exit(1)
99-
else:
105+
try:
106+
results = os.environ["RESULTS_JSON"]
100107
print("-------- $RESULTS_JSON --------")
101108
print(results)
102109
print("------------- END -------------")
@@ -118,6 +125,15 @@ def html(_args):
118125
# We do some processing to turn it into a dict of dicts
119126
results = json.loads(results)
120127
results = {entry["model_name"]: entry["results"] for entry in results}
128+
except KeyError as e:
129+
print("RESULTS_JSON environment variable not set")
130+
exit(1)
131+
132+
try:
133+
manifest = json.loads(os.environ["MANIFEST"])
134+
except KeyError as e:
135+
print("MANIFEST environment variable not set, reading from Manifest.toml")
136+
manifest = get_manifest_dict()
121137

122138
# You can also process this with pandas. I don't do that here because
123139
# (1) extra dependency
@@ -175,9 +191,9 @@ def html(_args):
175191
# Table header
176192
f.write('<table id="results"><thead>')
177193
f.write("<tr>")
178-
f.write("<th>Model name \\ AD type</th>")
194+
f.write('<th class="right">Model name \\ AD type</th>')
179195
for adtype in adtypes:
180-
f.write(f"<th>{adtype}</th>")
196+
f.write(f'<th class="right">{adtype}</th>')
181197
f.write("</tr></thead><tbody>")
182198
# Table body
183199
for model_name in models:
@@ -197,7 +213,14 @@ def html(_args):
197213
span = f'<a class="issue" href="{error_url}" target="_blank">(?)</a> {span}'
198214
f.write(f'<td>{span}</td>')
199215
f.write("</tr>")
200-
f.write("\n</tbody></table></main></body></html>")
216+
f.write("\n</tbody></table>")
217+
f.write("<h2>Manifest</h2><p>The tests above were run with the following package versions:</p>")
218+
f.write("<table id='manifest'><thead><tr><th>Package</th><th>Version</th>")
219+
for package, version in manifest.items():
220+
version_string = "" if version is None else f"v{version}"
221+
f.write(f"<tr><td>{package}</td><td>{version_string}</td></tr>")
222+
f.write("</table>")
223+
f.write("</main></body></html>")
201224

202225
with open("html/main.css", "w") as f:
203226
f.write(
@@ -225,19 +248,26 @@ def html(_args):
225248
max-width: 1250px;
226249
}
227250
228-
table#results {
229-
text-align: right;
251+
table {
230252
border: 1px solid black;
231253
border-collapse: collapse;
232254
}
233255
256+
table#results {
257+
text-align: right;
258+
}
259+
234260
td, th {
235261
border: 1px solid black;
236262
padding: 0px 10px;
237263
}
238264
239265
th {
240266
background-color: #ececec;
267+
text-align: left;
268+
}
269+
270+
th.right {
241271
text-align: right;
242272
}
243273

0 commit comments

Comments
 (0)