From edee1f74665202fb59eeaa46725ca5ce7909919b Mon Sep 17 00:00:00 2001 From: Diego Russo Date: Wed, 10 Jan 2024 17:31:43 +0000 Subject: [PATCH 1/2] 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. --- codespeed/models.py | 9 ---- .../templates/codespeed/changes_data.html | 8 ++-- .../templates/codespeed/changes_table.html | 4 +- codespeed/templates/codespeed/timeline.html | 4 +- codespeed/urls.py | 34 +++++++------- codespeed/views.py | 23 +++++----- deploy-requirements.txt | 4 +- requirements.txt | 6 +-- .../templates/feeds/latest_description.html | 12 ++--- sample_project/urls.py | 6 +-- setup.py | 2 +- speed_python/settings.py | 44 ++++++++++++------- .../templates/feeds/latest_description.html | 12 ++--- speed_python/templates/home.html | 1 - speed_python/urls.py | 11 +++-- 15 files changed, 91 insertions(+), 89 deletions(-) diff --git a/codespeed/models.py b/codespeed/models.py index e24926b5..143c70b7 100644 --- a/codespeed/models.py +++ b/codespeed/models.py @@ -9,14 +9,12 @@ from django.urls import reverse from django.conf import settings from django.db import models -from django.utils.encoding import python_2_unicode_compatible from .commits.github import GITHUB_URL_RE logger = logging.getLogger(__name__) -@python_2_unicode_compatible class Project(models.Model): NO_LOGS = 'N' GIT = 'G' @@ -107,7 +105,6 @@ def is_less_important_than(self, val, color): return False -@python_2_unicode_compatible class Branch(models.Model): name = models.CharField(max_length=32) project = models.ForeignKey( @@ -124,7 +121,6 @@ class Meta: verbose_name_plural = "branches" -@python_2_unicode_compatible class Revision(models.Model): # git and mercurial's SHA-1 length is 40 commitid = models.CharField(max_length=42) @@ -167,7 +163,6 @@ def clean(self): raise ValidationError("Invalid SVN commit id %s" % self.commitid) -@python_2_unicode_compatible class Executable(models.Model): name = models.CharField(max_length=30) description = models.CharField(max_length=200, blank=True) @@ -181,7 +176,6 @@ def __str__(self): return self.name -@python_2_unicode_compatible class Benchmark(models.Model): B_TYPES = ( ('C', 'Cross-project'), @@ -216,7 +210,6 @@ def clean(self): "'default_on_comparison' first.") -@python_2_unicode_compatible class Environment(models.Model): name = models.CharField(unique=True, max_length=100) cpu = models.CharField(max_length=100, blank=True) @@ -228,7 +221,6 @@ def __str__(self): return self.name -@python_2_unicode_compatible class Result(models.Model): value = models.FloatField() std_dev = models.FloatField(blank=True, null=True) @@ -253,7 +245,6 @@ class Meta: unique_together = ("revision", "executable", "benchmark", "environment") -@python_2_unicode_compatible class Report(models.Model): revision = models.ForeignKey( Revision, on_delete=models.CASCADE, related_name="reports") diff --git a/codespeed/templates/codespeed/changes_data.html b/codespeed/templates/codespeed/changes_data.html index c8900b72..590d520b 100644 --- a/codespeed/templates/codespeed/changes_data.html +++ b/codespeed/templates/codespeed/changes_data.html @@ -17,13 +17,13 @@ {% if rev.get_browsing_url %}{{ rev.commitid }}{% else %}{{ rev.commitid }}{% endif %} Date{{ rev.date }} - {% ifnotequal rev.branch.project.repo_type "N" %} + {% if rev.branch.project.repo_type != "N" %} Repo{{ rev.branch.project.repo_path }} - {% endifnotequal %} + {% endif %} -{% ifnotequal exe.project.repo_type 'N' %} +{% if exe.project.repo_type != 'N' %} @@ -40,5 +40,5 @@ el.load("logs/", "revisionid=" + el.data("commitid"));
-{% endifnotequal %} +{% endif %} diff --git a/codespeed/templates/codespeed/changes_table.html b/codespeed/templates/codespeed/changes_table.html index 95687e15..c9916af5 100644 --- a/codespeed/templates/codespeed/changes_table.html +++ b/codespeed/templates/codespeed/changes_table.html @@ -26,7 +26,7 @@ {% endif%}{% if units.has_stddev %}{{ units.totals.min }} {% endif%}{% if units.hasmax %}{{ units.totals.max }} {% endif%}{{ units.totals.change|percentage }} - {% ifnotequal units.totals.trend "-" %}{{ units.totals.trend|floatformat:2 }}%{% else %}{{ units.totals.trend }}{% endifnotequal %} + {% if units.totals.trend != "-" %}{{ units.totals.trend|floatformat:2 }}%{% else %}{{ units.totals.trend }}{% endif %} @@ -38,7 +38,7 @@ {% endif%}{% if units.hasmin %}{{ row.val_min|floatformat:units.precission }} {% endif%}{% if units.hasmax %}{{ row.val_max|floatformat:units.precission }} {% endif%}{{ row.change|percentage }} - {% ifequal row.trend "-" %}-{% else %}{{ row.trend|floatformat:2 }}%{% endifequal %} + {% if row.trend == "-" %}-{% else %}{{ row.trend|floatformat:2 }}%{% endif %} {% endfor %} {% endfor %} diff --git a/codespeed/templates/codespeed/timeline.html b/codespeed/templates/codespeed/timeline.html index ce6e4ebb..cc6326cd 100644 --- a/codespeed/templates/codespeed/timeline.html +++ b/codespeed/templates/codespeed/timeline.html @@ -54,7 +54,7 @@