Commit a0b5a44a authored by Rémi Duraffort's avatar Rémi Duraffort
Browse files

lava_scheduler_app : remove unused pylint annotations


Signed-off-by: default avatarRémi Duraffort <remi.duraffort@linaro.org>
parent 4cdcdde4
......@@ -48,7 +48,6 @@ from lava_scheduler_app.models import (
from linaro_django_xmlrpc.models import AuthToken
# django admin API itself isn't pylint clean, so some settings must be suppressed.
# pylint: disable=no-self-use,function-redefined
class GroupObjectPermissionInline(admin.TabularInline):
......@@ -109,9 +108,7 @@ class CoreAdmin(admin.ModelAdmin):
return self.readonly_fields
def expire_user_action(
modeladmin, request, queryset
): # pylint: disable=unused-argument
def expire_user_action(modeladmin, request, queryset):
for user in queryset.filter(is_active=True):
AuthToken.objects.filter(user=user).delete()
user.is_staff = False
......@@ -168,7 +165,7 @@ admin.site.unregister(Group)
admin.site.register(Group, CustomGroupAdmin)
def cancel_action(modeladmin, request, queryset): # pylint: disable=unused-argument
def cancel_action(modeladmin, request, queryset):
with transaction.atomic():
for testjob in queryset:
# TODO: hacky. until django 2.0+ is used and select_for_update gets
......@@ -460,9 +457,7 @@ class TestJobAdmin(admin.ModelAdmin):
ordering = ["-submit_time"]
def disable_health_check_action(
modeladmin, request, queryset
): # pylint: disable=unused-argument
def disable_health_check_action(modeladmin, request, queryset):
queryset.update(disable_health_check=False)
......
......@@ -50,10 +50,9 @@ from lava_scheduler_app.schema import (
)
# functions need to be members to be exposed in the API
# pylint: disable=no-self-use
# to make a function visible in the API, it must be a member of SchedulerAPI
# pylint: disable=no-self-use
def check_perm(perm):
......
......@@ -33,8 +33,6 @@ from lava_scheduler_app.dbutils import invalid_template, validate_job
from lava_scheduler_app.models import Device, DeviceType
from lava_scheduler_app.schema import SubmissionException
# pylint: disable=unused-argument,missing-docstring,invalid-name
@register(deploy=True)
def check_health_checks(app_configs, **kwargs):
......
......@@ -23,7 +23,6 @@ Database utility functions which use but are not actually models themselves
Used to allow models.py to be shortened and easier to follow.
"""
# pylint: disable=wrong-import-order
import contextlib
import os
......@@ -52,8 +51,6 @@ from lava_scheduler_app.schema import validate_submission, SubmissionException
from lava_results_app.dbutils import map_metadata
from lava_results_app.models import Query
# pylint: disable=too-many-branches,too-many-statements,too-many-locals
def match_vlan_interface(device, job_def):
if not isinstance(job_def, dict):
......
......@@ -18,7 +18,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with LAVA. If not, see <http://www.gnu.org/licenses/>.
# pylint: disable=too-many-lines
import contextlib
import datetime
......@@ -60,9 +59,6 @@ from lava_server.compat import add_permissions
import requests
# pylint: disable=invalid-name,no-self-use,too-many-public-methods,too-few-public-methods
# pylint: disable=too-many-branches,too-many-return-statements,too-many-instance-attributes
class JSONDataError(ValueError):
"""Error raised when JSON is syntactically valid but ill-formed."""
......@@ -1070,7 +1066,6 @@ def _get_device_type(user, name):
return device_type
# pylint: disable=too-many-arguments,too-many-locals
def _create_pipeline_job(
job_data,
user,
......@@ -1154,9 +1149,7 @@ def _create_pipeline_job(
return job
def _pipeline_protocols(
job_data, user, yaml_data=None
): # pylint: disable=too-many-locals,too-many-branches
def _pipeline_protocols(job_data, user, yaml_data=None):
"""
Handle supported pipeline protocols
Check supplied parameters and change the device selection if necessary.
......@@ -1657,7 +1650,7 @@ class TestJob(models.Model):
return reverse("lava.results.testjob", args=[self.id])
@property
def essential_role(self): # pylint: disable=too-many-return-statements
def essential_role(self):
if not self.is_multinode:
return False
data = yaml_safe_load(self.definition)
......@@ -1674,7 +1667,7 @@ class TestJob(models.Model):
return data["protocols"]["lava-multinode"]["essential"]
@property
def device_role(self): # pylint: disable=too-many-return-statements
def device_role(self):
if not self.is_multinode:
return "Error"
try:
......
......@@ -40,17 +40,13 @@ from django.utils import timezone
# No function in this file is directly accessible via urls.py - those
# functions need to go in views.py
# pylint: disable=invalid-name
class IDLinkColumn(tables.Column):
def __init__(self, verbose_name="ID", **kw):
kw["verbose_name"] = verbose_name
super().__init__(**kw)
def render(
self, record, table=None
): # pylint: disable=arguments-differ,unused-argument
def render(self, record, table=None):
return pklink(record)
......@@ -237,15 +233,13 @@ class JobTable(LavaTable):
return "Error"
return retval
def render_description(self, value): # pylint: disable=no-self-use
def render_description(self, value):
if value:
return value
else:
return ""
class Meta(
LavaTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(LavaTable.Meta):
model = TestJob
# alternatively, use 'fields' value to include specific fields.
exclude = [
......@@ -333,9 +327,7 @@ class IndexJobTable(JobTable):
'<span class="text-muted">Retired</span>'
)
class Meta(
JobTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(JobTable.Meta):
fields = (
"id",
"actions",
......@@ -419,9 +411,7 @@ class FailedJobTable(JobTable):
else:
return ""
class Meta(
JobTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(JobTable.Meta):
fields = ("id", "actions", "state", "device", "submit_time")
sequence = ("id", "actions", "state", "device", "submit_time")
exclude = ("submitter", "end_time", "priority", "description")
......@@ -450,19 +440,17 @@ class LongestJobTable(JobTable):
running = tables.Column(accessor="start_time", verbose_name="Running")
running.orderable = False
def render_running(self, record): # pylint: disable=no-self-use
def render_running(self, record):
if not record.start_time:
return ""
return str(timezone.now() - record.start_time)
def render_device(self, record): # pylint: disable=no-self-use
def render_device(self, record):
if record.actual_device:
return pklink(record.actual_device)
return ""
class Meta(
JobTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(JobTable.Meta):
fields = ("id", "actions", "state", "device")
sequence = ("id", "actions", "state", "device")
exclude = ("duration", "end_time")
......@@ -482,9 +470,7 @@ class OverviewJobsTable(JobTable):
submit_time = tables.DateColumn("Nd, g:ia")
end_time = tables.DateColumn("Nd, g:ia")
class Meta(
JobTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(JobTable.Meta):
fields = (
"id",
"actions",
......@@ -512,9 +498,7 @@ class RecentJobsTable(JobTable):
submit_time = tables.DateColumn("Nd, g:ia")
end_time = tables.DateColumn("Nd, g:ia")
class Meta(
JobTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(JobTable.Meta):
fields = (
"id",
"actions",
......@@ -538,7 +522,7 @@ class RecentJobsTable(JobTable):
class DeviceHealthTable(LavaTable):
def render_last_health_report_job(self, record): # pylint: disable=no-self-use
def render_last_health_report_job(self, record):
report = record.last_health_report_job
if report is None:
return ""
......@@ -561,9 +545,7 @@ class DeviceHealthTable(LavaTable):
)
last_health_report_job = tables.Column("last report job")
class Meta(
LavaTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(LavaTable.Meta):
sequence = [
"hostname",
"worker_host",
......@@ -576,19 +558,19 @@ class DeviceHealthTable(LavaTable):
class DeviceTypeTable(LavaTable):
def render_idle(self, record): # pylint: disable=no-self-use
def render_idle(self, record):
return record["idle"] if record["idle"] > 0 else ""
def render_offline(self, record): # pylint: disable=no-self-use
def render_offline(self, record):
return record["offline"] if record["offline"] > 0 else ""
def render_busy(self, record): # pylint: disable=no-self-use
def render_busy(self, record):
return record["busy"] if record["busy"] > 0 else ""
def render_name(self, record): # pylint: disable=no-self-use
def render_name(self, record):
return pklink(DeviceType.objects.get(name=record["device_type"]))
def render_queue(self, record): # pylint: disable=no-self-use
def render_queue(self, record):
count = TestJob.objects.filter(
Q(state=TestJob.STATE_SUBMITTED),
Q(requested_device_type=record["device_type"]),
......@@ -604,9 +586,7 @@ class DeviceTypeTable(LavaTable):
# sadly, this needs to be not orderable as it would otherwise sort by the accessor.
queue = tables.Column(accessor="idle", verbose_name="Queue", orderable=False)
class Meta(
LavaTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(LavaTable.Meta):
model = DeviceType
exclude = [
"display",
......@@ -624,7 +604,7 @@ class DeviceTypeTable(LavaTable):
class DeviceTable(LavaTable):
def render_device_type(self, record): # pylint: disable=no-self-use
def render_device_type(self, record):
return pklink(record.device_type)
def render_worker_host(self, record):
......@@ -690,9 +670,7 @@ class DeviceTable(LavaTable):
health = tables.Column(verbose_name="Health")
tags = TagsColumn()
class Meta(
LavaTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(LavaTable.Meta):
model = Device
exclude = [
"device_version",
......@@ -712,7 +690,7 @@ class DeviceTable(LavaTable):
}
class WorkerTable(LavaTable): # pylint: disable=too-few-public-methods,no-init
class WorkerTable(LavaTable):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.show_help = True
......@@ -760,9 +738,7 @@ class WorkerTable(LavaTable): # pylint: disable=too-few-public-methods,no-init
def render_last_ping(self, record):
return timesince(record.last_ping)
class Meta(
LavaTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(LavaTable.Meta):
model = Worker
sequence = ["hostname", "state", "health", "description"]
......@@ -801,9 +777,7 @@ class DeviceLogEntryTable(LogEntryTable):
class NoWorkerDeviceTable(DeviceTable):
class Meta(
LavaTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(LavaTable.Meta):
exclude = [
"worker_host",
"device_version",
......@@ -816,16 +790,14 @@ class NoWorkerDeviceTable(DeviceTable):
queries = {"device_state_query": "state", "device_health_query": "health"}
class HealthJobSummaryTable(tables.Table): # pylint: disable=too-few-public-methods
class HealthJobSummaryTable(tables.Table):
length = 10
Duration = tables.Column()
Complete = tables.Column()
Failed = tables.Column()
class Meta(
LavaTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(LavaTable.Meta):
model = None
......@@ -837,7 +809,7 @@ class QueueJobsTable(JobTable):
template_name="lava_scheduler_app/job_actions_field.html"
)
def render_requested_device_type(self, record): # pylint: disable=no-self-use
def render_requested_device_type(self, record):
return mark_safe( # nosec - internal data
'<a href="%s" title="%s device_type">%s</a>'
% (
......@@ -889,10 +861,10 @@ class QueueJobsTable(JobTable):
class PassingHealthTable(DeviceHealthTable):
def render_device_type(self, record): # pylint: disable=no-self-use
def render_device_type(self, record):
return pklink(record.device_type)
def render_last_health_report_job(self, record): # pylint: disable=no-self-use
def render_last_health_report_job(self, record):
report = record.last_health_report_job
return mark_safe( # nosec - internal data
'<a href="%s">%s</a>' % (report.get_absolute_url(), report)
......@@ -900,9 +872,7 @@ class PassingHealthTable(DeviceHealthTable):
device_type = tables.Column()
class Meta(
LavaTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(LavaTable.Meta):
exclude = ["worker_host", "last_report_time"]
sequence = ["hostname", "device_type", "health", "last_health_report_job"]
searches = {"hostname": "contains"}
......@@ -919,7 +889,7 @@ class RunningTable(LavaTable):
# deprecated: dynamic connections are TestJob without a device
def render_jobs(self, record): # pylint: disable=no-self-use
def render_jobs(self, record):
count = TestJob.objects.filter(
Q(state=TestJob.STATE_RUNNING),
Q(requested_device_type=record.name)
......@@ -927,13 +897,13 @@ class RunningTable(LavaTable):
).count()
return count if count > 0 else ""
def render_reserved(self, record): # pylint: disable=no-self-use
def render_reserved(self, record):
count = Device.objects.filter(
device_type=record.name, state=Device.STATE_RESERVED
).count()
return count if count > 0 else ""
def render_running(self, record): # pylint: disable=no-self-use
def render_running(self, record):
count = Device.objects.filter(
device_type=record.name, state=Device.STATE_RUNNING
).count()
......@@ -947,9 +917,7 @@ class RunningTable(LavaTable):
running = tables.Column(accessor="display", orderable=False, verbose_name="Running")
jobs = tables.Column(accessor="display", orderable=False, verbose_name="Jobs")
class Meta(
LavaTable.Meta
): # pylint: disable=too-few-public-methods,no-init,no-self-use
class Meta(LavaTable.Meta):
model = DeviceType
sequence = ["name", "reserved", "running", "jobs"]
exclude = [
......
......@@ -30,8 +30,6 @@ from lava_scheduler_app.schema import (
)
from lava_scheduler_app.tests.test_submission import TestCaseWithFactory
# pylint: disable=invalid-name
def device_type(name):
return os.path.join(settings.DEVICE_TYPES_PATH, name)
......@@ -60,8 +58,8 @@ class TestTransport(xmlrpc.client.Transport):
return self.parse_response(res)
class TestSchedulerAPI(TestCaseWithFactory): # pylint: disable=too-many-ancestors
def server_proxy(self, user=None, password=None): # pylint: disable=no-self-use
class TestSchedulerAPI(TestCaseWithFactory):
def server_proxy(self, user=None, password=None):
return xmlrpc.client.ServerProxy(
"http://localhost/RPC2/",
transport=TestTransport(user=user, password=password),
......
# pylint: disable=superfluous-parens,ungrouped-imports
from lava_scheduler_app.tests.test_base_templates import (
BaseTemplate,
prepare_jinja_template,
)
# pylint: disable=too-many-branches,too-many-public-methods
# pylint: disable=too-many-nested-blocks
def barebox_helper(self, board):
data = """{% extends '""" + board + """.jinja2' %}"""
......
......@@ -8,9 +8,6 @@ from django.conf import settings
from lava_common.compat import yaml_safe_load
from lava_scheduler_app.schema import validate_device, SubmissionException
# pylint: disable=too-many-branches,too-many-public-methods,too-few-public-methods
# pylint: disable=too-many-nested-blocks
def prepare_jinja_template(hostname, jinja_data, job_ctx=None, raw=True):
if not job_ctx:
......@@ -205,9 +202,7 @@ class TestBaseTemplates(BaseTemplate.BaseTemplateCases):
self.assertNotIn("115200n8", command)
self.assertNotIn("n8", command)
def test_primary_connection_power_commands_fail(
self
): # pylint: disable=invalid-name
def test_primary_connection_power_commands_fail(self):
data = """{% extends 'x86.jinja2' %}
{% set power_off_command = '/usr/bin/pduclient --command off' %}
{% set power_on_command = '/usr/bin/pduclient --command on' %}
......@@ -219,9 +214,7 @@ class TestBaseTemplates(BaseTemplate.BaseTemplateCases):
SubmissionException, validate_device, yaml_safe_load(device_dict)
)
def test_primary_connection_power_commands_empty_ssh_host(
self
): # pylint: disable=invalid-name
def test_primary_connection_power_commands_empty_ssh_host(self):
data = """{% extends 'x86.jinja2' %}
{% set power_off_command = '/usr/bin/pduclient --command off' %}
{% set power_on_command = '/usr/bin/pduclient --command on' %}
......@@ -231,7 +224,7 @@ class TestBaseTemplates(BaseTemplate.BaseTemplateCases):
device_dict = self.render_device_dictionary("staging-x86-01", data)
self.assertTrue(validate_device(yaml_safe_load(device_dict)))
def test_primary_connection_power_commands(self): # pylint: disable=invalid-name
def test_primary_connection_power_commands(self):
data = """{% extends 'x86.jinja2' %}
{% set power_off_command = '/usr/bin/pduclient --command off' %}
{% set hard_reset_command = '/usr/bin/pduclient --command reset' %}
......
......@@ -12,7 +12,6 @@ from lava_scheduler_app.tests.test_submission import TestCaseWithFactory
# TestCaseWithFactory cannot help causing too-many-ancestors, so ignore
# pylint: disable=too-many-ancestors
class YamlSshFactory(YamlFactory):
......
# pylint: disable=ungrouped-imports
import os
import yaml
import jinja2
......@@ -21,10 +19,8 @@ from lava_scheduler_app.dbutils import (
from django_testscenarios.ubertest import TestCase
from django.contrib.auth.models import User, Group, Permission
# pylint: disable=blacklisted-name,too-many-ancestors,invalid-name
# python3 needs print to be a function, so disable pylint
# pylint: disable=superfluous-parens
# pylint: disable=too-many-branches,too-many-locals,too-many-nested-blocks
class ModelFactory:
......@@ -38,10 +34,10 @@ class ModelFactory:
def getUniqueString(self, prefix="generic"):
return "%s-%d" % (prefix, self.getUniqueInteger())
def get_unique_user(self, prefix="generic"): # pylint: disable=no-self-use
def get_unique_user(self, prefix="generic"):
return "%s-%d" % (prefix, User.objects.count() + 1)
def get_unique_group(self, prefix="group"): # pylint: disable=no-self-use
def get_unique_group(self, prefix="group"):
return "%s-%d" % (prefix, Group.objects.count() + 1)
def make_user(self):
......
......@@ -7,9 +7,6 @@ from lava_scheduler_app.tests.test_base_templates import (
prepare_jinja_template,
)
# pylint: disable=too-many-branches,too-many-public-methods
# pylint: disable=too-many-nested-blocks
class TestFastbootTemplates(BaseTemplate.BaseTemplateCases):
"""
......
# pylint: disable=superfluous-parens,ungrouped-imports
from lava_scheduler_app.tests.test_base_templates import (
BaseTemplate,
prepare_jinja_template,
)
# pylint: disable=too-many-branches,too-many-public-methods
# pylint: disable=too-many-nested-blocks
class TestGrubTemplates(BaseTemplate.BaseTemplateCases):
"""
......@@ -25,7 +21,7 @@ class TestGrubTemplates(BaseTemplate.BaseTemplateCases):
system file.
"""
def test_mustang_pxe_grub_efi_template(self): # pylint: disable=invalid-name
def test_mustang_pxe_grub_efi_template(self):
data = """{% extends 'mustang-grub-efi.jinja2' %}
{% set hard_reset_command = '/usr/bin/pduclient --daemon services --hostname pdu09 --command reboot --port 05' %}
{% set power_off_command = '/usr/bin/pduclient --daemon services --hostname pdu09 --command off --port 05' %}
......
......@@ -6,9 +6,7 @@ from lava_scheduler_app.tests.test_submission import TestCaseWithFactory
class YamlMenuFactory(YamlFactory):
def make_fake_mustang_device(
self, hostname="fakemustang1"
): # pylint: disable=no-self-use
def make_fake_mustang_device(self, hostname="fakemustang1"):
assert hostname == "fakemustang1" # nosec - unit test support
def make_job_data(self, actions=None, **kw):
......@@ -21,7 +19,7 @@ class YamlMenuFactory(YamlFactory):
return data
class TestPipelineMenu(TestCaseWithFactory): # pylint: disable=too-many-ancestors
class TestPipelineMenu(TestCaseWithFactory):
"""
Test the building and override support of pipeline menus from submission YAML
"""
......
......@@ -34,8 +34,6 @@ from lava_dispatcher.tests.utils import DummyLogger
from unittest import TestCase
# pylint: disable=too-many-ancestors,too-many-public-methods,invalid-name,no-member
# set to True to see extra processing details
DEBUG = False
......@@ -417,7 +415,7 @@ class TestPipelineSubmit(TestCaseWithFactory):
validate_submission(data)
# FIXME: extend once the master validation code is exposed for unit tests
def test_compatibility(self): # pylint: disable=too-many-locals
def test_compatibility(self):
user = self.factory.make_user()
# public set in the YAML
yaml_str = self.factory.make_job_yaml()
......@@ -967,7 +965,7 @@ class TestYamlMultinode(TestCaseWithFactory):
self.assertIsNotNone(job.multinode_definition)
self.assertIn("# unit test support comment", job.multinode_definition)
def test_invalid_multinode(self): # pylint: disable=too-many-locals
def test_invalid_multinode(self):
user = self.factory.make_user()
device_type = self.factory.make_device_type()
submission = yaml_safe_load(
......@@ -1062,7 +1060,7 @@ class TestYamlMultinode(TestCaseWithFactory):
job = TestJob.objects.get(id=job.id)