Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Recorded Luminosity page in Shiftleader report [Closes #202] #210

Merged
merged 10 commits into from
Aug 24, 2022
7 changes: 5 additions & 2 deletions certifier/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,9 @@ def compare_with_run_registry(self):
run_registry_entries = runregistry.get_datasets(
filter={
"run_number": {"or": run_numbers},
"dataset_name": {"notlike": "%online%"},
"dataset_name": {
"and": [{"notlike": "%online%"}, {"notlike": "%commissioning%"}]
},
}
)

Expand Down Expand Up @@ -642,11 +644,12 @@ def group_run_numbers_by_fill_number(self):
.order_by("-fill_number")
.distinct()
)

fill_run_group = []
for fill in fills:
fill_run_group.append(
{
"fill_number": fill.fill_number,
"fill": fill,
"run_number": [
run["run_number"]
for run in fill.oms_runs.order_by("-run_number").values(
Expand Down
12 changes: 12 additions & 0 deletions listruns/static/listruns/css/list_table.css
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,15 @@ th:after {
font-weight: bold;
color: grey;
}
.inline-tooltip{
place-content: stretch flex-start;
-moz-box-align: center;
align-items: center;
flex-wrap: nowrap;
-moz-box-pack: start;
display: flex;
}

.i-tooltip{
display:inline;
}
10 changes: 5 additions & 5 deletions shiftleader/templates/shiftleader/day-by-day.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ <h3>Day by day notes: {{ day.name|title }}, {{ day.date|yyyymmdd_to_ddmmyyyy }}<
<p>
<ul>
<li>Fills <strong>{{ day.collisions.express.fill_numbers|join:"," }}</strong>
<ul>
<li>
<strong>[insert here]</strong> colliding bunches, peak lumi <strong>[insert here]</strong> x 10³⁴ cm²/s
</li>
</ul>
<!-- <ul>
<li>
<strong>[insert here]</strong> colliding bunches, peak lumi <strong>[insert here]</strong> x 10³⁴ cm²/s
</li>
</ul> -->
</li>
<li>Number of runs certified:
<ul>
Expand Down
39 changes: 16 additions & 23 deletions shiftleader/templates/shiftleader/lhc_fill_table.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
{% if queryset.run_numbers %}
<div style="max-width: 700px;">
<h4>{{ caption }}</h4>
<table class="table table-hover">
<thead>
<div style="max-width: 700px;">
<h4>{{ caption }}</h4>
<table class="table table-striped">
<thead>
<tr>
<th class="col-sm-3">Fill Number</th>
{% comment %}
<th>Ini Lumi (1033 cm2/s)</th>
<th>End Lumi (1033 cm2/s)</th>
<th>N Bunches</th>
<th>N Colliding Bunches</th>
<th>Peak PU</th>
{% endcomment %}
<th class="col-sm-9">Certified Runs</th>
<th class="col-sm-3" scope="col">Fill Number</th>
<th class="col-sm-9" scope="col">Certified Runs</th>
</tr>
</thead>
<tbody>
</thead>
<tbody>
{% for fill in queryset.fills %}
<tr>
<td class="col-sm-3">{{ fill.fill_number}}</td>
<td class="col-sm-9">{{ fill.run_number|join:", " }}</td>
</tr>
<tr>
<td scope="row" class="col-sm-3">{{ fill.fill.fill_number}}</td>
<td class="col-sm-9">{{ fill.run_number|join:", " }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</tbody>
</table>
</div>
{% endif %}
38 changes: 38 additions & 0 deletions shiftleader/templates/shiftleader/recorded-luminosity.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% if slreport.run_numbers %}
<div id="slr-recorded-luminosity" class="tab-pane fade">
<h3>Recorded luminosity</h3>
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Fill</th>
<th scope="col">Run Min</th>
<th scope="col">Run Max</th>
<th scope="col">Del. Lumi \(pb^{-1}\)</th>
<th scope="col">Rec. Lumi \(pb^{-1}\)</th>
<th scope="col">Eff By Lumi \(\%\)</th>
<th scope="col">Peak Lumi \(10^{33}cm^{-2}s^{-1}\)</th>
<th scope="col">Peak PU</th>
<th scope="col">Nb. Bunches</th>
</tr>
</thead>
<tbody>
{# Same logic with presentation #}
{% for fill in slreport.fills %}
{% if fill.fill.bunches_colliding %}
<tr>
<td scope="row">{{ fill.fill.fill_number }}</td>
<td>{{ fill.fill.first_run_number }}</td>
<td>{{ fill.fill.last_run_number }}</td>
<td>{{ fill.fill.delivered_lumi|floatformat:3 }}</td>
<td>{{ fill.fill.recorded_lumi|floatformat:3 }}</td>
<td>{{ fill.fill.efficiency_lumi|floatformat:2 }}</td>
<td>{{ fill.fill.peak_lumi|floatformat:3 }}</td>
<td>{{ fill.fill.peak_pileup|floatformat:3 }}</td>
<td>{{ fill.fill.bunches_colliding }}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
93 changes: 50 additions & 43 deletions shiftleader/templates/shiftleader/shift-leader-report.html
Original file line number Diff line number Diff line change
@@ -1,50 +1,57 @@
{% with 'monday tuesday wednesday thursday friday saturday sunday' as weekdays %}
{% load shiftleaderfilters %}

{% for key, val in slreport.day.items %}
<p><strong>key</strong>
{{ key }}
</p>
<p><strong>val</strong>
{{ val.items }}
for
</p>
{% endfor %}
<ul class="nav nav-tabs" xmlns="http://www.w3.org/1999/html">
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#slr-lhc-fills">LHC Fills</a></li>
{% for key, val in slreport.day.items %}
<p><strong>key</strong>
{{ key }}
</p>
<p><strong>val</strong>
{{ val.items }}
for
</p>
{% endfor %}
<ul class="nav nav-tabs" xmlns="http://www.w3.org/1999/html" role="tablist">
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#slr-recorded-luminosity">Recorded Luminosity</a></li>
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#slr-lhc-fills">LHC Fills</a></li>
<li class="dropdown nav-item">
<a class="dropdown-toggle nav-link" data-toggle="dropdown" href="#">
Day by day <span class="caret"></span>
</a>
<div class="dropdown-menu">
{% for day in slreport.day_by_day %}
<a class="dropdown-item" data-toggle="tab" href="#slr-{{ day.date|yyyymmdd }}">{{ day.name }} ({{ day.date|yyyymmdd }})</a>
{% endfor %}
</div>
</li>
<li class="nav-item"><a class="nav-link active" data-toggle="tab" href="#slr-weekly-cert">Weekly Certification</a></li>

<li class="dropdown nav-item">
<a class="dropdown-toggle nav-link" data-toggle="dropdown" href="#">
Day by day <span class="caret"></span>
</a>
<div class="dropdown-menu">
{% for day in slreport.day_by_day %}
<a class="dropdown-item" data-toggle="tab" href="#slr-{{ day.date|yyyymmdd }}">{{ day.name }} ({{ day.date|yyyymmdd }})</a>
{% endfor %}
</div>
</li>
<li class="nav-item"><a class="nav-link active" data-toggle="tab" href="#slr-weekly-cert">Weekly Certification</a></li>
<li class="dropdown nav-item">
<a class="dropdown-toggle nav-link" data-toggle="dropdown" href="#">
List of runs <span class="caret"></span>
</a>
<div class="dropdown-menu">
<a class="dropdown-item" data-toggle="tab" href="#slr-list-of-runs-all">All days</a>
{% for day in slreport.day_by_day %}
<a class="dropdown-item" data-toggle="tab" href="#slr-list-of-runs-{{ day.date|yyyymmdd }}">{{ day.name }} ({{ day.date|yyyymmdd }})</a>
{% endfor %}
</div>
</li>

<li class="dropdown nav-item">
<a class="dropdown-toggle nav-link" data-toggle="dropdown" href="#">
List of runs <span class="caret"></span>
</a>
<div class="dropdown-menu">
<a class="dropdown-item" data-toggle="tab" href="#slr-list-of-runs-all">All days</a>
{% for day in slreport.day_by_day %}
<a class="dropdown-item" data-toggle="tab" href="#slr-list-of-runs-{{ day.date|yyyymmdd }}">{{ day.name }} ({{ day.date|yyyymmdd }})</a>
{% endfor %}
</div>
</li>
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#slr-checklist">Checklist</a></li>
<li class="nav-item">
<button class="nav-link btn btn-primary"
id="shiftleader-report-presentation">
Generate presentation<i class="bi bi-easel3-fill pl-1"></i>
</button>
</li>
</ul>

<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#slr-checklist">Checklist</a></li>
</ul>

<div class="tab-content">
{% include "shiftleader/lhc-fills.html" %}
{% include "shiftleader/day-by-day.html" %}
{% include "shiftleader/weekly-cert.html" %}
{% include "shiftleader/list-of-runs.html" %}
{% include "shiftleader/checklist.html" %}
</div>
<div class="tab-content">
{% include "shiftleader/recorded-luminosity.html" %}
{% include "shiftleader/lhc-fills.html" %}
{% include "shiftleader/day-by-day.html" %}
{% include "shiftleader/weekly-cert.html" %}
{% include "shiftleader/list-of-runs.html" %}
{% include "shiftleader/checklist.html" %}
</div>
{% endwith %}
32 changes: 18 additions & 14 deletions shiftleader/templates/shiftleader/shiftleader.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,21 @@ <h2>Comparison of certified runs with Run Registry</h2>
<div class="row">
{% if trackercertification_comparison_table %}
<div class="col-sm-6">
<h3>Certification Helper:</h3>
<h3>Certification Helper</h3>
{% load render_table from django_tables2 %}
{% render_table trackercertification_comparison_table %}
</div>
{% endif %}
{% if run_registry_comparison_table %}
<div class="col-sm-6">
<h3>Run Registry:</h3>
{% load render_table from django_tables2 %}
<div class="inline-tooltip">
<h3>
Run Registry
</h3>
<i class="bi bi-info-circle-fill i-tooltip pl-1" data-toggle="tooltip"
title="Commissioning datasets have been filtered out"></i>
</div>
{% load render_table from django_tables2 %}
{% render_table run_registry_comparison_table %}
</div>
{% endif %}
Expand Down Expand Up @@ -98,21 +104,13 @@ <h3>Summary</h3>
{% load l10n %}
<h3>Shift Leader Report - Week {{ filter.qs.week_number }} <small>{{ filter.qs.days|first|as_date|localize }} - {{ filter.qs.days|last|as_date|localize }}</small></h3>
</div>

{% if slreport %}
{% include "shiftleader/shift-leader-report.html" %}
<!-- Button to generate report -->
<div class="row mb-2 mt-2">
<div class="col">
<button class="btn btn-primary"
id="shiftleader-report-presentation">
Generate presentation<i class="bi bi-easel3-fill pl-1"></i>
</button>
</div>
</div>

{% else %}
<div class="alert alert-danger" role="alert">No Shiftleader Report found.</div>
<div class="alert alert-danger" role="alert">No Shiftleader Report found.</div>
{% endif %}

{% else %}
<div class="alert alert-danger" role="alert">
No runs have been certified in the specified filter criteria.
Expand All @@ -130,6 +128,8 @@ <h3>Shift Leader Report - Week {{ filter.qs.week_number }} <small>{{ filter.qs.d
<script src="{% static "shiftleader/js/restore_selected_tabs.js" %}"></script>
<script src="{% static "shiftleader/js/filter.js" %}"></script>
<script src="{% static "shiftleader/js/runinfo_table.js" %}"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script>
{% if global_preferences.shiftleader__popup_enabled %}
const popupTimeInMilliseconds = 1000 * {{ global_preferences.shiftleader__popup_time_period }};
Expand Down Expand Up @@ -195,6 +195,10 @@ <h3>Shift Leader Report - Week {{ filter.qs.week_number }} <small>{{ filter.qs.d

};
{% endif %}

$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
});
</script>
{% endblock scripts %}
11 changes: 9 additions & 2 deletions shiftleader/tests/test_shiftleaderreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
)
from shiftleader.utilities.utilities import to_date
from shiftleader.tests.utilities.utilities import create_runs
from oms.models import OmsFill

pytestmark = pytest.mark.django_db

Expand Down Expand Up @@ -289,8 +290,14 @@ def test_fills(self):
report = ShiftLeaderReport(runs)

assert [
{"fill_number": 7049, "run_number": [321185, 321182]},
{"fill_number": 7048, "run_number": [321181, 321179, 321171]},
{
"fill": OmsFill.objects.get(fill_number=7049),
"run_number": [321185, 321182],
},
{
"fill": OmsFill.objects.get(fill_number=7048),
"run_number": [321181, 321179, 321171],
},
] == report.cosmics().express().good().fills()

def test_flag_changed(self):
Expand Down
Loading