Skip to content

Commit edee1f7

Browse files
committed
Update codespeed dependencies to be compatible with Python3.8
Update codespeed dependencies. Update codebase to reflect API changes of new dependencies. Also this drops support for Python 2 and it can be run with Python 3.8 Pin dependencies in requirements files.
1 parent 7a781df commit edee1f7

15 files changed

Lines changed: 91 additions & 89 deletions

File tree

codespeed/models.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
from django.urls import reverse
1010
from django.conf import settings
1111
from django.db import models
12-
from django.utils.encoding import python_2_unicode_compatible
1312

1413
from .commits.github import GITHUB_URL_RE
1514

1615
logger = logging.getLogger(__name__)
1716

1817

19-
@python_2_unicode_compatible
2018
class Project(models.Model):
2119
NO_LOGS = 'N'
2220
GIT = 'G'
@@ -107,7 +105,6 @@ def is_less_important_than(self, val, color):
107105
return False
108106

109107

110-
@python_2_unicode_compatible
111108
class Branch(models.Model):
112109
name = models.CharField(max_length=32)
113110
project = models.ForeignKey(
@@ -124,7 +121,6 @@ class Meta:
124121
verbose_name_plural = "branches"
125122

126123

127-
@python_2_unicode_compatible
128124
class Revision(models.Model):
129125
# git and mercurial's SHA-1 length is 40
130126
commitid = models.CharField(max_length=42)
@@ -167,7 +163,6 @@ def clean(self):
167163
raise ValidationError("Invalid SVN commit id %s" % self.commitid)
168164

169165

170-
@python_2_unicode_compatible
171166
class Executable(models.Model):
172167
name = models.CharField(max_length=30)
173168
description = models.CharField(max_length=200, blank=True)
@@ -181,7 +176,6 @@ def __str__(self):
181176
return self.name
182177

183178

184-
@python_2_unicode_compatible
185179
class Benchmark(models.Model):
186180
B_TYPES = (
187181
('C', 'Cross-project'),
@@ -216,7 +210,6 @@ def clean(self):
216210
"'default_on_comparison' first.")
217211

218212

219-
@python_2_unicode_compatible
220213
class Environment(models.Model):
221214
name = models.CharField(unique=True, max_length=100)
222215
cpu = models.CharField(max_length=100, blank=True)
@@ -228,7 +221,6 @@ def __str__(self):
228221
return self.name
229222

230223

231-
@python_2_unicode_compatible
232224
class Result(models.Model):
233225
value = models.FloatField()
234226
std_dev = models.FloatField(blank=True, null=True)
@@ -253,7 +245,6 @@ class Meta:
253245
unique_together = ("revision", "executable", "benchmark", "environment")
254246

255247

256-
@python_2_unicode_compatible
257248
class Report(models.Model):
258249
revision = models.ForeignKey(
259250
Revision, on_delete=models.CASCADE, related_name="reports")

codespeed/templates/codespeed/changes_data.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
<td>{% if rev.get_browsing_url %}<a href="{{ rev.get_browsing_url }}">{{ rev.commitid }}</a>{% else %}{{ rev.commitid }}{% endif %}</td>
1818
</tr>
1919
<tr class="date"><th class="infofirst">Date</td><td>{{ rev.date }}</td></tr>
20-
{% ifnotequal rev.branch.project.repo_type "N" %}
20+
{% if rev.branch.project.repo_type != "N" %}
2121
<tr class="repo-path"><th class="infofirst">Repo</th><td>{{ rev.branch.project.repo_path }}</td></tr>
22-
{% endifnotequal %}
22+
{% endif %}
2323
</tbody>
2424
</table>
2525

26-
{% ifnotequal exe.project.repo_type 'N' %}
26+
{% if exe.project.repo_type != 'N' %}
2727
<table class="revision">
2828
<col/>
2929
<col/>
@@ -40,5 +40,5 @@
4040
el.load("logs/", "revisionid=" + el.data("commitid"));
4141
</script>
4242
</table>
43-
{% endifnotequal %}
43+
{% endif %}
4444
</div>

codespeed/templates/codespeed/changes_table.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{% endif%}{% if units.has_stddev %}<td>{{ units.totals.min }}</td>
2727
{% endif%}{% if units.hasmax %}<td>{{ units.totals.max }}</td>
2828
{% endif%}<td>{{ units.totals.change|percentage }}</td>
29-
<td>{% ifnotequal units.totals.trend "-" %}{{ units.totals.trend|floatformat:2 }}%{% else %}{{ units.totals.trend }}{% endifnotequal %}</td>
29+
<td>{% if units.totals.trend != "-" %}{{ units.totals.trend|floatformat:2 }}%{% else %}{{ units.totals.trend }}{% endif %}</td>
3030
</tr>
3131
</tfoot>
3232
<tbody>
@@ -38,7 +38,7 @@
3838
{% endif%}{% if units.hasmin %}<td>{{ row.val_min|floatformat:units.precission }}</td>
3939
{% endif%}{% if units.hasmax %}<td>{{ row.val_max|floatformat:units.precission }}</td>
4040
{% endif%}<td>{{ row.change|percentage }}</td>
41-
<td>{% ifequal row.trend "-" %}-{% else %}{{ row.trend|floatformat:2 }}%{% endifequal %}</td>
41+
<td>{% if row.trend == "-" %}-{% else %}{{ row.trend|floatformat:2 }}%{% endif %}</td>
4242
</tr>{% endfor %}
4343
</tbody>
4444
</table>{% endfor %}

codespeed/templates/codespeed/timeline.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</div>
5555
<div id="benchmark" class="sidebox">
5656
<div class="boxhead"><h2>Benchmark</h2></div>
57-
<div class="boxbody">{% ifnotequal benchmarks|length 1 %}
57+
<div class="boxbody">{% if benchmarks|length != 1 %}
5858
<ul>
5959
<li>
6060
<input id="benchmarkgrid" type="radio" name="benchmark" value="grid" />
@@ -64,7 +64,7 @@
6464
<input id="b_show_none" type="radio" name="benchmark" value="show_none" />
6565
<label for="b_show_none">Display none</label>
6666
</li>
67-
</ul>{% endifnotequal %}
67+
</ul>{% endif %}
6868
<ul>{% for bench in benchmarks|dictsort:"name" %}
6969
<li title="{{ bench.description }}">
7070
<input id="benchmark_{{ bench.id }}" type="radio" name="benchmark" value="{{ bench.name }}" />

codespeed/urls.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
# -*- coding: utf-8 -*-
2-
from django.conf.urls import url
2+
from django.urls import re_path
33
from django.views.generic import TemplateView
44

55
from codespeed import views
66
from codespeed.feeds import LatestEntries, LatestSignificantEntries
77

88
urlpatterns = [
9-
url(r'^$', views.HomeView.as_view(), name='home'),
10-
url(r'^about/$',
9+
re_path(r'^$', views.HomeView.as_view(), name='home'),
10+
re_path(r'^about/$',
1111
TemplateView.as_view(template_name='about.html'), name='about'),
1212
# RSS for reports
13-
url(r'^feeds/latest/$', LatestEntries(), name='latest-results'),
14-
url(r'^feeds/latest_significant/$', LatestSignificantEntries(),
13+
re_path(r'^feeds/latest/$', LatestEntries(), name='latest-results'),
14+
re_path(r'^feeds/latest_significant/$', LatestSignificantEntries(),
1515
name='latest-significant-results'),
1616
]
1717

1818
urlpatterns += [
19-
url(r'^historical/json/$', views.gethistoricaldata, name='gethistoricaldata'),
20-
url(r'^reports/$', views.reports, name='reports'),
21-
url(r'^changes/$', views.changes, name='changes'),
22-
url(r'^changes/table/$', views.getchangestable, name='getchangestable'),
23-
url(r'^changes/logs/$', views.displaylogs, name='displaylogs'),
24-
url(r'^timeline/$', views.timeline, name='timeline'),
25-
url(r'^timeline/json/$', views.gettimelinedata, name='gettimelinedata'),
26-
url(r'^comparison/$', views.comparison, name='comparison'),
27-
url(r'^comparison/json/$', views.getcomparisondata, name='getcomparisondata'),
28-
url(r'^makeimage/$', views.makeimage, name='makeimage'),
19+
re_path(r'^historical/json/$', views.gethistoricaldata, name='gethistoricaldata'),
20+
re_path(r'^reports/$', views.reports, name='reports'),
21+
re_path(r'^changes/$', views.changes, name='changes'),
22+
re_path(r'^changes/table/$', views.getchangestable, name='getchangestable'),
23+
re_path(r'^changes/logs/$', views.displaylogs, name='displaylogs'),
24+
re_path(r'^timeline/$', views.timeline, name='timeline'),
25+
re_path(r'^timeline/json/$', views.gettimelinedata, name='gettimelinedata'),
26+
re_path(r'^comparison/$', views.comparison, name='comparison'),
27+
re_path(r'^comparison/json/$', views.getcomparisondata, name='getcomparisondata'),
28+
re_path(r'^makeimage/$', views.makeimage, name='makeimage'),
2929
]
3030

3131
urlpatterns += [
3232
# URLs for adding results
33-
url(r'^result/add/json/$', views.add_json_results, name='add-json-results'),
34-
url(r'^result/add/$', views.add_result, name='add-result'),
33+
re_path(r'^result/add/json/$', views.add_json_results, name='add-json-results'),
34+
re_path(r'^result/add/$', views.add_result, name='add-result'),
3535
]

codespeed/views.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from django.http import HttpResponse, Http404, HttpResponseBadRequest, \
1212
HttpResponseNotFound, StreamingHttpResponse
1313
from django.db.models import F
14-
from django.shortcuts import get_object_or_404, render_to_response
14+
from django.shortcuts import get_object_or_404, render
1515
from django.views.decorators.http import require_GET, require_POST
1616
from django.views.decorators.csrf import csrf_exempt
1717
from django.views.generic.base import TemplateView
@@ -33,7 +33,7 @@
3333

3434
def no_environment_error(request):
3535
admin_url = reverse('admin:codespeed_environment_changelist')
36-
return render_to_response('codespeed/nodata.html', {
36+
return render(request, 'codespeed/nodata.html', {
3737
'message': ('You need to configure at least one Environment. '
3838
'Please go to the '
3939
'<a href="%s">admin interface</a>' % admin_url)
@@ -42,7 +42,7 @@ def no_environment_error(request):
4242

4343
def no_default_project_error(request):
4444
admin_url = reverse('admin:codespeed_project_changelist')
45-
return render_to_response('codespeed/nodata.html', {
45+
return render(request, 'codespeed/nodata.html', {
4646
'message': ('You need to configure at least one one Project as '
4747
'default (checked "Track changes" field).<br />'
4848
'Please go to the '
@@ -51,13 +51,13 @@ def no_default_project_error(request):
5151

5252

5353
def no_executables_error(request):
54-
return render_to_response('codespeed/nodata.html', {
54+
return render(request, 'codespeed/nodata.html', {
5555
'message': 'There needs to be at least one executable'
5656
})
5757

5858

5959
def no_data_found(request):
60-
return render_to_response('codespeed/nodata.html', {
60+
return render(request, 'codespeed/nodata.html', {
6161
'message': 'No data found'
6262
})
6363

@@ -309,7 +309,7 @@ def comparison(request):
309309
settings.CHART_ORIENTATION == 'horizontal'):
310310
selecteddirection = True
311311

312-
return render_to_response('codespeed/comparison.html', {
312+
return render(request, 'codespeed/comparison.html', {
313313
'checkedexecutables': checkedexecutables,
314314
'checkedbenchmarks': checkedbenchmarks,
315315
'checkedenviros': checkedenviros,
@@ -623,7 +623,7 @@ def timeline(request):
623623
for proj in Project.objects.filter(track=True):
624624
executables[proj] = Executable.objects.filter(project=proj)
625625
use_median_bands = hasattr(settings, 'USE_MEDIAN_BANDS') and settings.USE_MEDIAN_BANDS
626-
return render_to_response('codespeed/timeline.html', {
626+
return render(request, 'codespeed/timeline.html', {
627627
'pagedesc': pagedesc,
628628
'checkedexecutables': checkedexecutables,
629629
'defaultbaseline': defaultbaseline,
@@ -707,7 +707,7 @@ def getchangestable(request):
707707
'<p class="errormessage">No results for this '
708708
'parameters</p>')
709709

710-
return render_to_response('codespeed/changes_data.html', {
710+
return render(request, 'codespeed/changes_data.html', {
711711
'tablelist': tablelist,
712712
'trendconfig': trendconfig,
713713
'rev': selectedrev,
@@ -813,7 +813,7 @@ def changes(request):
813813

814814
pagedesc = "Report of %s performance changes for commit %s on branch %s" % \
815815
(defaultexecutable, selectedrevision.commitid, selectedrevision.branch)
816-
return render_to_response('codespeed/changes.html', {
816+
return render(request, 'codespeed/changes.html', {
817817
'pagedesc': pagedesc,
818818
'defaultenvironment': defaultenv,
819819
'defaultexecutable': defaultexecutable,
@@ -840,7 +840,7 @@ def reports(request):
840840
colorcode__in=('red', 'green')
841841
).order_by('-revision__date')[:10]
842842

843-
return render_to_response('codespeed/reports.html', context)
843+
return render(request, 'codespeed/reports.html', context)
844844

845845

846846
@require_GET
@@ -885,7 +885,8 @@ def displaylogs(request):
885885
for log in logs:
886886
log['commit_browse_url'] = project.commit_browsing_url.format(**log)
887887

888-
return render_to_response(
888+
return render(
889+
request,
889890
'codespeed/changes_logs.html',
890891
{
891892
'error': error, 'logs': logs,

deploy-requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
-r requirements.txt
2-
psycopg2==2.9.3
3-
gunicorn==20.1.0
2+
psycopg-binary==3.1.17
3+
gunicorn==21.2.0

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Django>=1.11,<2.2
2-
isodate>=0.4.7,<0.6
3-
matplotlib>=1.4.3,<2.0
1+
django<4
2+
isodate==0.6.1
3+
matplotlib<3.8
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
{% ifequal obj.colorcode "red" %}Performance regressed: {% else %}
2-
{% ifequal obj.colorcode "green" %}Performance improved: {% else %}
3-
{% ifequal obj.colorcode "yellow" %}Trend regressed: {% else %}
1+
{% if obj.colorcode == "red" %}Performance regressed: {% else %}
2+
{% if obj.colorcode == "green" %}Performance improved: {% else %}
3+
{% if obj.colorcode == "yellow" %}Trend regressed: {% else %}
44
No significant changes.
5-
{% endifequal %}
6-
{% endifequal %}
7-
{% endifequal %}
5+
{% endif %}
6+
{% endif %}
7+
{% endif %}
88
{{ obj.summary }}

sample_project/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# -*- coding: utf-8 -*-
22

33
from django.conf import settings
4-
from django.conf.urls import include, url
4+
from django.urls import include, re_path
55
from django.contrib import admin
66

77
urlpatterns = [
8-
url(r'^admin/', admin.site.urls),
9-
url(r'^', include('codespeed.urls'))
8+
re_path(r'^admin/', admin.site.urls),
9+
re_path(r'^', include('codespeed.urls'))
1010
]
1111

1212
if settings.DEBUG:

0 commit comments

Comments
 (0)