Skip to content
Snippets Groups Projects
Commit ba6341ab authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[backend] Multiple small fixes to typos

parent bfe71ee6
No related branches found
No related tags found
1 merge request!194Scheduler
...@@ -129,4 +129,4 @@ class Command(BaseCommand): ...@@ -129,4 +129,4 @@ class Command(BaseCommand):
with open(arguments['qconfig'], 'rb') as f: with open(arguments['qconfig'], 'rb') as f:
config = simplejson.load(f) config = simplejson.load(f)
setup_environment(config or DEFAULT_CONFIGURATION) setup_backend(config or DEFAULT_CONFIGURATION)
...@@ -28,10 +28,11 @@ ...@@ -28,10 +28,11 @@
'''Utilities for summarizing scheduler state''' '''Utilities for summarizing scheduler state'''
from django.conf import settings import os
import psutil import psutil
from django.conf import settings
from .models import Job, JobSplit from .models import Job, JobSplit
from ..experiments.models import Experiment from ..experiments.models import Experiment
...@@ -60,19 +61,19 @@ def jobs(): ...@@ -60,19 +61,19 @@ def jobs():
return dict( return dict(
total=JobSplit.objects.count(), total=JobSplit.objects.count(),
running=JobSplit.objects.filter(state=Job.PROCESSING).count(), running=JobSplit.objects.filter(status=Job.PROCESSING).count(),
queued=JobSplit.objects.filter(state=Job.QUEUED).count(), queued=JobSplit.objects.filter(status=Job.QUEUED).count(),
cancelled=JobSplit.objects.filter(state=Job.CANCELLED).count(), cancelled=JobSplit.objects.filter(status=Job.CANCELLED).count(),
skipped=JobSplit.objects.filter(state=Job.SKIPPED).count(), skipped=JobSplit.objects.filter(status=Job.SKIPPED).count(),
completed=JobSplit.objects.filter(state=Job.COMPLETED).count(), completed=JobSplit.objects.filter(status=Job.COMPLETED).count(),
failed=JobSplit.objects.filter(state=Job.FAILED).count(), failed=JobSplit.objects.filter(status=Job.FAILED).count(),
) )
def experiments(): def experiments():
return dict( return dict(
running=Experiment.objects.filter(state=Experiment.RUNNING).count(), running=Experiment.objects.filter(status=Experiment.RUNNING).count(),
scheduled=Experiment.objects.filter(state=Experiment.SCHEDULED).count(), scheduled=Experiment.objects.filter(status=Experiment.SCHEDULED).count(),
ls=Experiment.objects.filter(state__in=(Experiment.RUNNING, Experiment.SCHEDULED)).all(), ls=Experiment.objects.filter(status__in=(Experiment.RUNNING, Experiment.SCHEDULED)).all(),
) )
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<div class="alert alert-success" role="alert" style="text-align: center;"> <div class="alert alert-success" role="alert" style="text-align: center;">
<i class="fa fa-clock-o fa-2x vertical-center"></i> Updated: {% now "H:i O, jS F Y" %} <i class="fa fa-clock-o fa-2x vertical-center"></i> Updated: {% now "H:i O, jS F Y" %}
<div class="pull-right action-buttons"> <div class="pull-right action-buttons">
<a id="cancel-experiments-button" class="btn btn-default btn-delete" data-toggle="tooltip" data-placement="bottom" title="Cancel all running experiments"><i class="fa fa-times"></i> Cancel Experiments</a> <a id="cancel-experiments-button" class="btn btn-default btn-delete" data-toggle="tooltip" data-placement="bottom" title="Cancel all running experiments" href="{% url 'backend:cancel-experiments' %}"><i class="fa fa-times"></i> Cancel Experiments</a>
</div> </div>
</div> </div>
</div> </div>
...@@ -51,9 +51,9 @@ ...@@ -51,9 +51,9 @@
<ul id="object-tabs" class="nav nav-tabs nav-justified" role="tablist"> <ul id="object-tabs" class="nav nav-tabs nav-justified" role="tablist">
<li role="presentation" class="active"><a id="status-tab" href="#status" role="tab" data-toggle="tab" aria-controls="status">Status <span class="badge">{{ jobs.running }}</a></li> <li role="presentation" class="active"><a id="status-tab" href="#status" role="tab" data-toggle="tab" aria-controls="status">Status <span class="badge">{{ jobs.running }}</a></li>
<li role="presentation"><a href="#experiments" role="tab" data-toggle="tab" aria-controls="experiments">Experiments <span class="badge">{{ data.scheduler.experiments.list|length }}</span></a></li> <li role="presentation"><a href="#experiments" role="tab" data-toggle="tab" aria-controls="experiments">Experiments <span class="badge">{{ experiments.ls|length }}</span></a></li>
<li role="presentation"><a href="#workers" role="tab" data-toggle="tab" aria-controls="workers">Workers <span class="badge">{{ data.workers|length }}</span></a></li> <li role="presentation"><a href="#workers" role="tab" data-toggle="tab" aria-controls="workers">Workers <span class="badge">{{ workers|length }}</span></a></li>
<li role="presentation"><a href="#queues" role="tab" data-toggle="tab" aria-controls="queues">Queues <span class="badge">{{ data.scheduler.queues|length }}</span></a></li> <li role="presentation"><a href="#queues" role="tab" data-toggle="tab" aria-controls="queues">Queues <span class="badge">{{ queues|length }}</span></a></li>
</ul> </ul>
<!-- Tab contents --> <!-- Tab contents -->
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<h3>Experiments</h3> <h3>Experiments</h3>
<ul class="list-group"> <ul class="list-group">
<li class="list-group-item">Running <span class="badge">{{ experiments.running }}</span></li> <li class="list-group-item">Running <span class="badge">{{ experiments.running }}</span></li>
<li class="list-group-item">Scheduled <span class="badge">{{ experiments.completed }}</span></li> <li class="list-group-item">Scheduled <span class="badge">{{ experiments.scheduled }}</span></li>
</ul> </ul>
</div> </div>
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
<!-- Experiments tab --> <!-- Experiments tab -->
<div role="tabpanel" class="tab-pane" id="experiments"> <div role="tabpanel" class="tab-pane" id="experiments">
{% if experiments.list %} {% if experiments.ls %}
<div class="scrollable table-responsive"> <div class="scrollable table-responsive">
<table class="table table-hover table-condensed"> <table class="table table-hover table-condensed">
<thead> <thead>
...@@ -110,8 +110,7 @@ ...@@ -110,8 +110,7 @@
<tbody> <tbody>
{% for obj in experiments.ls %} {% for obj in experiments.ls %}
<tr> <tr>
<td><a href="{{ obj.get_absolute_url }}">{{ obj.fullname }}</a></td> <td><a href="{{ obj.get_admin_change_url }}">{{ obj.fullname }}</a></td>
{% endwith %}
<td>{{ obj.blocks.count }}</td> <td>{{ obj.blocks.count }}</td>
<td>{{ obj|count_job_splits }}</td> <td>{{ obj|count_job_splits }}</td>
<td>{{ obj|count_job_splits:"P" }}</td> <td>{{ obj|count_job_splits:"P" }}</td>
...@@ -154,7 +153,7 @@ ...@@ -154,7 +153,7 @@
{% endif %} {% endif %}
</a> </a>
</td> </td>
<td><a title="Click to admin" data-toggle="tooltip" data-placement="top" href="{% url 'admin:backend_worker_change' obj.id %}">{{ obj.name }}</a></td> <td><a title="Click to admin" data-toggle="tooltip" data-placement="top" href="{{ obj.get_admin_change_url }}">{{ obj.name }}</a></td>
<td>{{ obj.available_cores }} / {{ obj.cores }}</td> <td>{{ obj.available_cores }} / {{ obj.cores }}</td>
<td>{% widthratio obj.memory 1024 1 %}</td> <td>{% widthratio obj.memory 1024 1 %}</td>
<td>{{ obj.info }}</td> <td>{{ obj.info }}</td>
...@@ -187,7 +186,7 @@ ...@@ -187,7 +186,7 @@
<tbody> <tbody>
{% for obj in queues %} {% for obj in queues %}
<tr> <tr>
<td><a title="Click to admin" data-toggle="tooltip" data-placement="top" href="{% url 'admin:backend_queue_change' obj.id %}">{{ obj.name }}</a></td> <td><a title="Click to admin" data-toggle="tooltip" data-placement="top" href="{{ obj.get_admin_change_url }}">{{ obj.name }}</a></td>
<td>{{ obj.memory_limit }}</td> <td>{{ obj.memory_limit }}</td>
<td>{{ obj.number_of_slots }}</td> <td>{{ obj.number_of_slots }}</td>
<td>{{ obj.cores_per_slot }}</td> <td>{{ obj.cores_per_slot }}</td>
...@@ -212,13 +211,6 @@ ...@@ -212,13 +211,6 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$.ajaxSetup({
beforeSend: function(xhr, settings) {
var csrftoken = $.cookie('csrftoken');
xhr.setRequestHeader('X-CSRFToken', csrftoken);
}
});
manage_tabs('ul#object-tabs'); manage_tabs('ul#object-tabs');
var data = {{ cache_chart_data|safe }}; var data = {{ cache_chart_data|safe }};
...@@ -242,30 +234,6 @@ $(document).ready(function() { ...@@ -242,30 +234,6 @@ $(document).ready(function() {
display_cache_chart(); display_cache_chart();
}); });
function reload_on_success(data) {
}
$('a#cancel-experiments-button').click(function() {
$this = $(this);
$this.disable();
$this.find('i').addClass('fa-spin');
var d = $.ajax({
type: 'POST',
url: '{% url 'api_backend:backend-api-cancel-all-experiments' %}',
});
d.done(function(data) {
location.reload();
});
d.fail(function(data, status_text) {
process_error(data, status_text);
$this.find('i').removeClass('fa-spin');
$this.enable();
});
});
}); });
</script> </script>
{% endblock %} {% endblock %}
...@@ -84,9 +84,9 @@ def visible_queues(context, object): ...@@ -84,9 +84,9 @@ def visible_queues(context, object):
@register.filter @register.filter
def count_job_splits(xp, state=None): def count_job_splits(xp, status=None):
"""Returns job splits for an experiment in a certain state""" """Returns job splits for an experiment in a certain state"""
return xp.job_splits(state=state).count() return xp.job_splits(status=status).count()
#-------------------------------------------------- #--------------------------------------------------
......
...@@ -160,7 +160,7 @@ def setup_backend(d): ...@@ -160,7 +160,7 @@ def setup_backend(d):
# 1. We get a list of all current queue/environment combinations # 1. We get a list of all current queue/environment combinations
q_envs = set([(q.name, str(e)) \ q_envs = set([(q.name, str(e)) \
for q in Queue.objects.all() for e in q.environments]) for q in Queue.objects.all() for e in q.environments.all()])
# 2. We get a list of new queue/environment combinations # 2. We get a list of new queue/environment combinations
config_q_envs = set([(qname, envkey) \ config_q_envs = set([(qname, envkey) \
...@@ -296,7 +296,7 @@ def setup_backend(d): ...@@ -296,7 +296,7 @@ def setup_backend(d):
queue.save() queue.save()
# 10.2 Update the queue-slot allocation # 10.2 Update the queue-slot allocation
queue.slots.delete() queue.slots.all().delete()
for hostname, par in attrs['slots'].items(): for hostname, par in attrs['slots'].items():
worker = Worker.objects.get(name=hostname) worker = Worker.objects.get(name=hostname)
priority = par.get('priority', 0) priority = par.get('priority', 0)
...@@ -320,7 +320,7 @@ def setup_backend(d): ...@@ -320,7 +320,7 @@ def setup_backend(d):
delete_qnames = current_qnames.difference(config_qnames) delete_qnames = current_qnames.difference(config_qnames)
for name in delete_qnames: for name in delete_qnames:
q = Queue.objects.select_for_update().get(name=name) q = Queue.objects.select_for_update().get(name=name)
logger.info("Deleting `%s'...", queue) logger.info("Deleting `%s'...", q)
q.delete() # slots are deleted on cascade q.delete() # slots are deleted on cascade
# 12. Delete environments w/o associated queues # 12. Delete environments w/o associated queues
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment