Skip to content

Commit c874795

Browse files
authored
Merge pull request #517 from NVIDIA/am/style-report
Apply style to scenario report
2 parents 4bf12d7 + ff7b0e0 commit c874795

File tree

4 files changed

+117
-61
lines changed

4 files changed

+117
-61
lines changed

src/cloudai/_core/reporter.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,22 @@ class SlurmReportItem:
6565

6666
@classmethod
6767
def get_metadata(cls, run_dir: Path) -> Optional[SlurmSystemMetadata]:
68-
if (run_dir / "metadata").exists():
69-
node_files = list(run_dir.glob("metadata/node-*.toml"))
70-
if node_files:
71-
node_file = node_files[0]
72-
with node_file.open() as f:
73-
try:
74-
return SlurmSystemMetadata.model_validate(toml.load(f))
75-
except Exception as e:
76-
logging.debug(f"Error validating metadata for {node_file}: {e}")
68+
if not (run_dir / "metadata").exists():
69+
logging.debug(f"No metadata folder found in {run_dir}")
70+
return None
71+
72+
node_files = list(run_dir.glob("metadata/node-*.toml"))
73+
if not node_files:
74+
logging.debug(f"No node files found in {run_dir}/metadata")
75+
return None
76+
77+
node_file = node_files[0]
78+
with node_file.open() as f:
79+
try:
80+
return SlurmSystemMetadata.model_validate(toml.load(f))
81+
except Exception as e:
82+
logging.debug(f"Error validating metadata for {node_file}: {e}")
83+
7784
return None
7885

7986
@classmethod
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>{{ name }}</title>
5+
<style>
6+
body {
7+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
8+
line-height: 1.6;
9+
max-width: 1200px;
10+
margin: 0;
11+
padding: 2rem;
12+
color: #333;
13+
}
14+
h1 {
15+
color: #2c3e50;
16+
border-bottom: 2px solid #eee;
17+
padding-bottom: 0.5rem;
18+
margin-bottom: 2rem;
19+
}
20+
h2 {
21+
color: #2c3e50;
22+
margin-top: 2rem;
23+
margin-bottom: 1rem;
24+
}
25+
table {
26+
width: 100%;
27+
border-collapse: collapse;
28+
margin-top: 1rem;
29+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
30+
}
31+
th, td {
32+
padding: 12px 15px;
33+
text-align: left;
34+
border-bottom: 1px solid #eee;
35+
}
36+
th {
37+
background-color: #f8f9fa;
38+
font-weight: 600;
39+
}
40+
tr:hover {
41+
background-color: #f8f9fa;
42+
}
43+
a {
44+
color: #3498db;
45+
text-decoration: none;
46+
}
47+
a:hover {
48+
text-decoration: underline;
49+
}
50+
</style>
51+
{% block extra_head %}{% endblock %}
52+
</head>
53+
<body>
54+
<h1>{{ name }}</h1>
55+
{% block content %}{% endblock %}
56+
</body>
57+
</html>
Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
<html>
2-
<head>
3-
<title>{{ name }}</title>
4-
</head>
5-
<body>
6-
<h1>{{ name }}</h1>
7-
</body>
8-
<table>
9-
<tr>
10-
<th>Test</th>
11-
<th>Description</th>
12-
<th>Results</th>
13-
</tr>
14-
{% for item in report_items %}
15-
<tr>
16-
<td>{{ item.name }}</td>
17-
<td>{{ item.description }}</td>
18-
{% if item.logs_path %}
19-
<td><a href="{{ item.logs_path }}">logs</a></td>
20-
{% else %}
1+
{% extends "base-report.jinja2" %}
2+
3+
{% block content %}
4+
<table>
5+
<tr>
6+
<th>Test</th>
7+
<th>Description</th>
8+
<th>Results</th>
9+
</tr>
10+
{% for item in report_items %}
11+
<tr>
12+
<td>{{ item.name }}</td>
13+
<td>{{ item.description }}</td>
14+
{% if item.logs_path %}
15+
<td><a href="{{ item.logs_path }}">logs</a></td>
16+
{% else %}
2117
<td>no logs</td>
22-
{% endif %}
23-
</tr>
24-
{% endfor %}
25-
</table>
26-
</html>
18+
{% endif %}
19+
</tr>
20+
{% endfor %}
21+
</table>
22+
{% endblock %}
Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
1-
<html>
2-
<head>
3-
<title>{{ name }}</title>
4-
</head>
5-
<body>
6-
<h1>{{ name }}</h1>
7-
</body>
8-
<table>
9-
<tr>
10-
<th>Test</th>
11-
<th>Description</th>
12-
<th>Results</th>
13-
<th>Nodes</th>
14-
</tr>
15-
{% for item in report_items %}
16-
<tr>
17-
<td>{{ item.name }}</td>
18-
<td>{{ item.description }}</td>
19-
{% if item.logs_path %}
20-
<td><a href="{{ item.logs_path }}">logs</a></td>
21-
{% else %}
1+
{% extends "base-report.jinja2" %}
2+
3+
{% block content %}
4+
<table>
5+
<tr>
6+
<th>Test</th>
7+
<th>Description</th>
8+
<th>Results</th>
9+
<th>Nodes</th>
10+
</tr>
11+
{% for item in report_items %}
12+
<tr>
13+
<td>{{ item.name }}</td>
14+
<td>{{ item.description }}</td>
15+
{% if item.logs_path %}
16+
<td><a href="{{ item.logs_path }}">logs</a></td>
17+
{% else %}
2218
<td>no logs</td>
23-
{% endif %}
24-
<td>{{ item.nodes }}</td>
25-
</tr>
26-
{% endfor %}
27-
</table>
28-
</html>
19+
{% endif %}
20+
<td>{{ item.nodes }}</td>
21+
</tr>
22+
{% endfor %}
23+
</table>
24+
{% endblock %}

0 commit comments

Comments
 (0)