Skip to content

Commit c6ee821

Browse files
committed
Enh(viewer): make it easier to directly see results
1 parent 238b034 commit c6ee821

7 files changed

Lines changed: 139 additions & 93 deletions

File tree

codeclash/viewer/app.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,27 @@ def unescape_content(value):
692692
return value.replace("\\n", "\n")
693693

694694

695+
def get_folder_name(path):
696+
"""Extract the folder name from a path"""
697+
if not path:
698+
return ""
699+
from pathlib import Path
700+
701+
return Path(path).name
702+
703+
704+
def get_parent_folder(path):
705+
"""Extract the parent folder name from a path"""
706+
if not path:
707+
return ""
708+
from pathlib import Path
709+
710+
parent = Path(path).parent
711+
if str(parent) == "." or str(parent) == "/":
712+
return ""
713+
return parent.name
714+
715+
695716
def get_navigation_info(selected_folder: str) -> dict[str, str | None]:
696717
"""Get previous and next game folders for navigation"""
697718
# Get all game folders
@@ -755,6 +776,8 @@ def render_game_viewer(folder_path: Path, selected_folder: str) -> str:
755776
# Register the custom filters
756777
app.jinja_env.filters["nl2br"] = nl2br
757778
app.jinja_env.filters["unescape_content"] = unescape_content
779+
app.jinja_env.filters["get_folder_name"] = get_folder_name
780+
app.jinja_env.filters["get_parent_folder"] = get_parent_folder
758781

759782

760783
@app.route("/")

codeclash/viewer/static/css/style.css

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,17 +1162,27 @@ summary:focus {
11621162
/* Storage Section */
11631163
.storage-section {
11641164
margin-bottom: 2rem;
1165+
}
1166+
1167+
.storage-container {
11651168
padding: 1rem;
1166-
background: var(--bg-secondary);
1167-
border-radius: 8px;
1168-
border: 1px solid var(--border-color);
11691169
}
11701170

1171-
.storage-container h3 {
1172-
margin: 0 0 1rem 0;
1171+
.storage-path-summary {
1172+
background: var(--code-bg);
1173+
padding: 0.25rem 0.5rem;
1174+
border-radius: 4px;
1175+
border: 1px solid var(--border-color);
1176+
font-family: "Courier New", monospace;
1177+
font-size: 0.9rem;
11731178
color: #ffffff;
1174-
font-size: 1.1rem;
1175-
font-weight: 600;
1179+
font-weight: 500;
1180+
margin-left: 0.5rem;
1181+
}
1182+
1183+
/* Readme spacing when in setup section */
1184+
.readme-in-setup {
1185+
margin: 1.5rem 0;
11761186
}
11771187

11781188
.storage-item {

codeclash/viewer/templates/includes/overview.html

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
<section class="overview-section">
33
<h2><i class="bi bi-bar-chart"></i> Overview</h2>
44

5-
<!-- Scores Per Round Chart -->
6-
{% if sim_wins_data and sim_wins_data.players and sim_wins_data.rounds %}
7-
<div class="chart-container">
8-
<canvas id="overview-scores-chart" width="800" height="400"></canvas>
9-
</div>
10-
<script type="application/json" id="overview-scores-data">{{ sim_wins_data | tojson }}</script>
11-
{% endif %}
12-
135
<div class="overview-summary">
146
<table class="table table-striped table-hover results-table">
157
<thead>
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
<!-- Readme Section -->
2-
<section class="readme-section">
3-
<h2><i class="bi bi-journal-text"></i> Readme</h2>
4-
<div class="readme-container">
5-
{% if not is_static %}
6-
<textarea id="readme-textarea" class="form-control readme-textarea" placeholder="Add notes about this experiment..."></textarea>
7-
<div class="readme-status" id="readme-status">Loading...</div>
8-
{% else %}
9-
<textarea id="readme-textarea" class="form-control readme-textarea" placeholder="Readme editing not available in static mode" disabled></textarea>
10-
<div class="readme-status" id="readme-status">Static Mode - Editing Disabled</div>
11-
{% endif %}
12-
</div>
13-
</section>
2+
<div class="readme-container readme-in-setup">
3+
{% if not is_static %}
4+
<textarea id="readme-textarea" class="form-control readme-textarea" placeholder="Enter readme content here"></textarea>
5+
<div class="readme-status" id="readme-status">Loading...</div>
6+
{% else %}
7+
<textarea id="readme-textarea" class="form-control readme-textarea" placeholder="Readme editing not available in static mode" disabled></textarea>
8+
<div class="readme-status" id="readme-status">Static Mode - Editing Disabled</div>
9+
{% endif %}
10+
</div>

codeclash/viewer/templates/includes/setup.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ <h2><i class="bi bi-gear"></i> Setup</h2>
2323
{% endif %}
2424
</div>
2525

26+
<!-- Readme Section -->
27+
{% include 'includes/readme.html' %}
28+
2629
<!-- Metadata Foldout -->
2730
<details class="foldout">
2831
<summary>
Lines changed: 87 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,98 @@
11
<!-- Storage Section -->
22
<section class="storage-section">
3-
<div class="storage-container">
4-
<h3><i class="bi bi-hdd"></i> Storage</h3>
3+
<!-- Storage Foldout -->
4+
<details class="foldout">
5+
<summary>
6+
<i class="bi bi-hdd"></i> Storage:
7+
<code class="storage-path-summary">
8+
{% set folder_name = selected_folder_path | get_folder_name %}
9+
{% set parent_folder = selected_folder_path | get_parent_folder %}
10+
{% if parent_folder %}
11+
{{ parent_folder }}/{{ folder_name }}
12+
{% else %}
13+
{{ folder_name }}
14+
{% endif %}
15+
</code>
16+
</summary>
517

6-
<!-- Current Folder Path -->
7-
<div class="storage-item">
8-
<div class="storage-label">
9-
<i class="bi bi-folder"></i> Current Folder:
18+
<div class="storage-container">
19+
<!-- Current Folder Path -->
20+
<div class="storage-item">
21+
<div class="storage-label">
22+
<i class="bi bi-folder"></i> Current Folder:
23+
</div>
24+
<div class="storage-content">
25+
<code class="folder-path">{{ selected_folder_path }}</code>
26+
<button class="btn btn-outline-primary btn-sm copy-path-btn" data-path="{{ selected_folder_path }}" title="Copy folder path">
27+
<i class="bi bi-clipboard"></i> Copy path
28+
</button>
29+
{% if not is_static %}
30+
<button class="btn btn-outline-warning btn-sm move-rename-btn" onclick="showMoveDialog('{{ selected_folder_path }}')" title="Move/rename this experiment">
31+
<i class="bi bi-folder-symlink"></i> Move/Rename
32+
</button>
33+
<button class="btn btn-outline-danger btn-sm delete-experiment-btn" data-folder-path="{{ selected_folder_path }}" title="Delete this experiment">
34+
<i class="bi bi-trash"></i> Delete
35+
</button>
36+
{% else %}
37+
<button class="btn btn-outline-secondary btn-sm" disabled title="Not available in static mode">
38+
<i class="bi bi-folder-symlink"></i> Move/Rename
39+
</button>
40+
<button class="btn btn-outline-secondary btn-sm" disabled title="Not available in static mode">
41+
<i class="bi bi-trash"></i> Delete
42+
</button>
43+
{% endif %}
44+
</div>
1045
</div>
11-
<div class="storage-content">
12-
<code class="folder-path">{{ selected_folder_path }}</code>
13-
<button class="btn btn-outline-primary btn-sm copy-path-btn" data-path="{{ selected_folder_path }}" title="Copy folder path">
14-
<i class="bi bi-clipboard"></i> Copy path
15-
</button>
16-
{% if not is_static %}
17-
<button class="btn btn-outline-warning btn-sm move-rename-btn" onclick="showMoveDialog('{{ selected_folder_path }}')" title="Move/rename this experiment">
18-
<i class="bi bi-folder-symlink"></i> Move/Rename
19-
</button>
20-
<button class="btn btn-outline-danger btn-sm delete-experiment-btn" data-folder-path="{{ selected_folder_path }}" title="Delete this experiment">
21-
<i class="bi bi-trash"></i> Delete
22-
</button>
23-
{% else %}
24-
<button class="btn btn-outline-secondary btn-sm" disabled title="Not available in static mode">
25-
<i class="bi bi-folder-symlink"></i> Move/Rename
26-
</button>
27-
<button class="btn btn-outline-secondary btn-sm" disabled title="Not available in static mode">
28-
<i class="bi bi-trash"></i> Delete
29-
</button>
30-
{% endif %}
31-
</div>
32-
</div>
3346

34-
<!-- AWS User Provided Command -->
35-
{% if metadata and metadata.results and metadata.results.aws and metadata.results.aws.AWS_USER_PROVIDED_COMMAND %}
36-
<div class="storage-item">
37-
<div class="storage-label">
38-
<i class="bi bi-cloud"></i> AWS Command:
47+
<!-- AWS User Provided Command -->
48+
{% if metadata and metadata.results and metadata.results.aws and metadata.results.aws.AWS_USER_PROVIDED_COMMAND %}
49+
<div class="storage-item">
50+
<div class="storage-label">
51+
<i class="bi bi-cloud"></i> AWS Command:
52+
</div>
53+
<div class="storage-content">
54+
<code class="folder-path">aws/run_job.py -- {{ metadata.results.aws.AWS_USER_PROVIDED_COMMAND }}</code>
55+
<button class="btn btn-outline-primary btn-sm copy-aws-command-btn" title="Copy AWS command">
56+
<i class="bi bi-clipboard"></i> Copy command
57+
</button>
58+
</div>
3959
</div>
40-
<div class="storage-content">
41-
<code class="folder-path">aws/run_job.py -- {{ metadata.results.aws.AWS_USER_PROVIDED_COMMAND }}</code>
42-
<button class="btn btn-outline-primary btn-sm copy-aws-command-btn" title="Copy AWS command">
43-
<i class="bi bi-clipboard"></i> Copy command
44-
</button>
45-
</div>
46-
</div>
47-
{% endif %}
60+
{% endif %}
4861

49-
<!-- External Links -->
50-
<div class="storage-item">
51-
<div class="storage-label">
52-
<i class="bi bi-link-45deg"></i> External Links:
53-
</div>
54-
<div class="storage-content">
55-
<!-- S3 Bucket Link -->
56-
{% set s3_path = selected_folder.replace('\\', '/') if selected_folder else '' %}
57-
<a href="https://039984708918-4ppzlrng.us-east-1.console.aws.amazon.com/s3/buckets/codeclash?region=us-east-1&bucketType=general&prefix=logs%2F{{ s3_path | urlencode }}%2F&showversions=false"
58-
target="_blank"
59-
class="btn btn-outline-info btn-sm"
60-
title="View in S3 Bucket">
61-
<i class="bi bi-bucket"></i> S3
62-
</a>
62+
<!-- External Links -->
63+
<div class="storage-item">
64+
<div class="storage-label">
65+
<i class="bi bi-link-45deg"></i> External Links:
66+
</div>
67+
<div class="storage-content">
68+
<!-- S3 Bucket Link -->
69+
{% set s3_path = selected_folder.replace('\\', '/') if selected_folder else '' %}
70+
<a href="https://039984708918-4ppzlrng.us-east-1.console.aws.amazon.com/s3/buckets/codeclash?region=us-east-1&bucketType=general&prefix=logs%2F{{ s3_path | urlencode }}%2F&showversions=false"
71+
target="_blank"
72+
class="btn btn-outline-info btn-sm"
73+
title="View in S3 Bucket">
74+
<i class="bi bi-bucket"></i> S3
75+
</a>
6376

64-
<!-- AWS Job Link (only if AWS metadata exists) -->
65-
{% if metadata.results.aws and metadata.results.aws.AWS_BATCH_JOB_ID %}
66-
<a href="https://039984708918-4ppzlrng.us-east-1.console.aws.amazon.com/batch/home?region=us-east-1#jobs/ec2/detail/{{ metadata.results.aws.AWS_BATCH_JOB_ID }}"
67-
target="_blank"
68-
class="btn btn-outline-success btn-sm"
69-
title="View AWS Batch Job">
70-
<i class="bi bi-gear-wide-connected"></i> AWS Job
71-
</a>
72-
{% endif %}
77+
<!-- AWS Job Link (only if AWS metadata exists) -->
78+
{% if metadata.results.aws and metadata.results.aws.AWS_BATCH_JOB_ID %}
79+
<a href="https://039984708918-4ppzlrng.us-east-1.console.aws.amazon.com/batch/home?region=us-east-1#jobs/ec2/detail/{{ metadata.results.aws.AWS_BATCH_JOB_ID }}"
80+
target="_blank"
81+
class="btn btn-outline-success btn-sm"
82+
title="View AWS Batch Job">
83+
<i class="bi bi-gear-wide-connected"></i> AWS Job
84+
</a>
85+
{% endif %}
86+
</div>
7387
</div>
7488
</div>
75-
</div>
89+
</details>
90+
91+
<!-- Scores Per Round Chart -->
92+
{% if sim_wins_data and sim_wins_data.players and sim_wins_data.rounds %}
93+
<div class="chart-container">
94+
<canvas id="overview-scores-chart" width="800" height="400"></canvas>
95+
</div>
96+
<script type="application/json" id="overview-scores-data">{{ sim_wins_data | tojson }}</script>
97+
{% endif %}
7698
</section>

codeclash/viewer/templates/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
<main class="container-fluid main-content">
2020
{% include 'includes/storage.html' %}
21-
{% include 'includes/readme.html' %}
2221
{% include 'includes/setup.html' %}
2322
{% include 'includes/overview.html' %}
2423
{% include 'includes/analysis.html' %}

0 commit comments

Comments
 (0)