Skip to content

Commit 3bdd4f2

Browse files
committed
basic display of ensemble information
Signed-off-by: Lance-Drane <Lance-Drane@users.noreply.github.com>
1 parent 1170c6b commit 3bdd4f2

2 files changed

Lines changed: 70 additions & 34 deletions

File tree

ipsportal/run.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
import logging
2+
from csv import DictReader
3+
14
from flask import Blueprint, render_template
25
from urllib3.util import parse_url
36

47
from ipsportal.db import get_data_information, get_run, get_runid
58

9+
logger = logging.getLogger(__name__)
10+
611
bp = Blueprint('index', __name__)
712

813

@@ -21,11 +26,25 @@ def run(runid: int) -> tuple[str, int]:
2126
run['parent_runid'] = get_runid(str(run.get('parent_portal_runid')))
2227
else:
2328
run['parent_runid'] = None
24-
data_info, jupyter_urls, ensemble_information = get_data_information(runid)
29+
data_info, jupyter_urls, ensemble_information_meta = get_data_information(runid)
2530
if jupyter_urls:
2631
resolved_jupyter_urls = [[jupyter_url, parse_url(jupyter_url).host] for jupyter_url in jupyter_urls]
2732
else:
2833
resolved_jupyter_urls = None
34+
ensemble_information = []
35+
if ensemble_information_meta:
36+
for listing in ensemble_information_meta:
37+
try:
38+
with open(listing['path']) as fd:
39+
data = list(DictReader(fd))
40+
ensemble_information.append(
41+
{
42+
'data': data,
43+
'ensemble_id': listing['ensemble_id'],
44+
}
45+
)
46+
except Exception:
47+
logger.exception('potentially invalid listing: %s', listing)
2948
return render_template(
3049
'events.html',
3150
run=run,

ipsportal/templates/events.html

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,6 @@ <h4>{% block title %}Run - {{ run.runid }}{% endblock %}</h4>
136136
</ol>
137137
</details>
138138

139-
{% if ensemble_information %}
140-
<details>
141-
<summary>Ensemble information</summary>
142-
<ul>
143-
{% for info in ensemble_information %}
144-
<li>
145-
{{info['name']}}
146-
</li>
147-
{% endfor %}
148-
</ul>
149-
</details>
150-
{% endif %}
151-
152139
<details>
153140
<summary>Data File bulk download script</summary>
154141
<p>This is a basic Python script you can run to quickly download all data files. Note that the files will be written to the script's execution directory.</p>
@@ -181,22 +168,25 @@ <h4>{% block title %}Run - {{ run.runid }}{% endblock %}</h4>
181168
<div class="nav nav-tabs" id="nav-tab" role="tablist">
182169
<button class="nav-link active" id="nav-events-tab" data-bs-toggle="tab" data-bs-target="#nav-events" type="button" role="tab" aria-controls="nav-events" aria-selected="true">Events</button>
183170
<button class="nav-link" id="nav-children-tab" data-bs-toggle="tab" data-bs-target="#nav-children" type="button" role="tab" aria-controls="nav-children" aria-selected="false">Child runs</button>
171+
{% if ensemble_information %}
172+
<button class="nav-link" id="nav-ensembles-tab" data-bs-toggle="tab" data-bs-target="#nav-ensembles" type="button" role="tab" aria-controls="nav-ensembles" aria-selected="false">Ensemble Runs</button>
173+
{% endif %}
184174
</div>
185175
</nav>
186176

187177
<div class="tab-content" id="nav-tabContent">
188178
<div class="tab-pane fade show active" id="nav-events" role="tabpanel" aria-labelledby="nav-events-tab">
189179
<table id="event-table" class="table table-striped table-secondary table-bordered" style="width:100%" runid={{ run.runid }}>
190180
<thead>
191-
<tr>
192-
<th>Time</th>
193-
<th>Seq Num</th>
194-
<th>Event Type</th>
195-
<th>Code</th>
196-
<th>Walltime</th>
197-
<th>Physics Time</th>
198-
<th>Comment</th>
199-
</tr>
181+
<tr>
182+
<th>Time</th>
183+
<th>Seq Num</th>
184+
<th>Event Type</th>
185+
<th>Code</th>
186+
<th>Walltime</th>
187+
<th>Physics Time</th>
188+
<th>Comment</th>
189+
</tr>
200190
</thead>
201191
<tbody>
202192
</tbody>
@@ -205,22 +195,49 @@ <h4>{% block title %}Run - {{ run.runid }}{% endblock %}</h4>
205195
<div class="tab-pane fade" id="nav-children" role="tabpanel" aria-labelledby="nav-children-tab">
206196
<table id="child-runs-table" class="table table-striped table-bordered" style="width:100%" runid={{ run.runid }}>
207197
<thead>
208-
<tr>
209-
<th>RunID</th>
210-
<th>Status</th>
211-
<th>Comment</th>
212-
<th>Sim Name</th>
213-
<th>Host</th>
214-
<th>User</th>
215-
<th>Start Time</th>
216-
<th>Stop Time</th>
217-
<th>Walltime</th>
218-
</tr>
198+
<tr>
199+
<th>RunID</th>
200+
<th>Status</th>
201+
<th>Comment</th>
202+
<th>Sim Name</th>
203+
<th>Host</th>
204+
<th>User</th>
205+
<th>Start Time</th>
206+
<th>Stop Time</th>
207+
<th>Walltime</th>
208+
</tr>
219209
</thead>
220210
<tbody>
221211
</tbody>
222212
</table>
223213
</div>
214+
{% if ensemble_information %}
215+
<div class="tab-pane fade" id="nav-ensembles" role="tabpanel" aria-labelledby="nav-ensembles-tab">
216+
<table id="ensemble-table" class="table table-striped table-bordered" style="width:100%" runid={{ run.runid }}>
217+
<thead>
218+
<tr>
219+
<th>Sim Name</th>
220+
<th>Run</th>
221+
<th>Instance Analysis URL</th>
222+
</tr>
223+
</thead>
224+
{% for ensemble in ensemble_information %}
225+
<tbody id="ensemble-{{ensemble['ensemble_id']}}">
226+
<tr>
227+
<th scope="rowgroup" colspan="3">{{ensemble['ensemble_id']}}</th>
228+
</tr>
229+
{% for row in ensemble['data'] %}
230+
<tr>
231+
<td>{{row['sim_name']}}</td>
232+
<td><a href="{{row['run_url']}}">{{row['portal_runid']}}</a></td>
233+
<td><a href="{{row['instance_analysis_url']}}">View run on Jupyter</a></td>
234+
</tr>
235+
{% endfor %}
236+
</tbody>
237+
{% endfor %}
238+
</table>
239+
</div>
240+
{% endif %}
224241
</div>
225242

226243
{% endblock %}

0 commit comments

Comments
 (0)