[LNT] r349788 - Cleanups suggested by linter
Chris Matthews via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 20 10:25:45 PST 2018
Author: cmatthews
Date: Thu Dec 20 10:25:45 2018
New Revision: 349788
URL: http://llvm.org/viewvc/llvm-project?rev=349788&view=rev
Log:
Cleanups suggested by linter
Most of this code was written long ago before good linters were around.
Remove unused code, and fix poorly formatted.
Modified:
lnt/trunk/lnt/lnttool/updatedb.py
lnt/trunk/lnt/server/db/migrations/upgrade_1_to_2.py
lnt/trunk/lnt/server/db/regression.py
lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py
lnt/trunk/lnt/server/db/v4db.py
lnt/trunk/lnt/server/reporting/dailyreport.py
lnt/trunk/lnt/server/reporting/latestrunsreport.py
lnt/trunk/lnt/server/ui/filters.py
lnt/trunk/lnt/server/ui/profile_views.py
lnt/trunk/lnt/testing/profile/perf.py
lnt/trunk/lnt/testing/profile/profilev2impl.py
lnt/trunk/lnt/testing/util/commands.py
lnt/trunk/lnt/tests/builtintest.py
lnt/trunk/lnt/tests/nt.py
lnt/trunk/lnt/tests/test_suite.py
lnt/trunk/tests/server/db/rules.py
lnt/trunk/tests/server/db/search.py
Modified: lnt/trunk/lnt/lnttool/updatedb.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/updatedb.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/lnttool/updatedb.py (original)
+++ lnt/trunk/lnt/lnttool/updatedb.py Thu Dec 20 10:25:45 2018
@@ -21,7 +21,7 @@ def action_updatedb(instance_path, datab
delete_machines, delete_runs, delete_order):
"""modify a database"""
from .common import init_logger
- from lnt.util import logger
+
import contextlib
import lnt.server.instance
import logging
@@ -36,7 +36,6 @@ def action_updatedb(instance_path, datab
with contextlib.closing(instance.get_database(database)) as db:
session = db.make_session()
ts = db.testsuite[testsuite]
- order = None
# Compute a list of all the runs to delete.
if delete_order:
runs = session.query(ts.Run).join(ts.Order) \
Modified: lnt/trunk/lnt/server/db/migrations/upgrade_1_to_2.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/migrations/upgrade_1_to_2.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/migrations/upgrade_1_to_2.py (original)
+++ lnt/trunk/lnt/server/db/migrations/upgrade_1_to_2.py Thu Dec 20 10:25:45 2018
@@ -35,7 +35,6 @@ def update_testsuite(engine, session, db
# Scan each run that has no report version and possibly recompute the
# run order.
- run_order_map = {}
logger.info("updating runs")
all_runs = session.query(Run).\
filter(sqlalchemy.not_(Run.Parameters.like(
Modified: lnt/trunk/lnt/server/db/regression.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/regression.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/regression.py (original)
+++ lnt/trunk/lnt/server/db/regression.py Thu Dec 20 10:25:45 2018
@@ -1,5 +1,5 @@
from sqlalchemy import desc, asc
-import datetime
+
import re
from collections import namedtuple
from lnt.server.reporting.analysis import RunInfo
@@ -41,7 +41,6 @@ ChangeData = namedtuple("ChangeData", ["
@timed
def new_regression(session, ts, field_changes):
"""Make a new regression and add to DB."""
- today = datetime.date.today()
MSG = "Regression of 0 benchmarks"
title = MSG
regression = ts.Regression(title, "", RegressionState.DETECTED)
@@ -87,6 +86,7 @@ def get_all_orders_for_machine(session,
.order_by(asc(ts.Order.llvm_project_revision)) \
.all()
+
@timed
def get_last_order_for_machine(session, ts, machine):
"""Get all the orders for this sa machine."""
@@ -96,6 +96,7 @@ def get_last_order_for_machine(session,
.order_by(desc(ts.Order.llvm_project_revision)) \
.first()
+
def get_ris(session, ts, regression_id):
return session.query(ts.RegressionIndicator) \
.filter(ts.RegressionIndicator.regression_id == regression_id) \
Modified: lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py (original)
+++ lnt/trunk/lnt/server/db/rules/rule_update_fixed_regressions.py Thu Dec 20 10:25:45 2018
@@ -3,7 +3,7 @@ Detcted + fixed -> Ignored
Staged or Active + fixed -> Verify
"""
from sqlalchemy.orm.session import Session
-from typing import Dict
+from typing import Dict # noqa: flake8 does not detect use in comments
from lnt.server.db.regression import RegressionState
from lnt.server.db.regression import get_cr_for_field_change, get_ris
Modified: lnt/trunk/lnt/server/db/v4db.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/v4db.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/v4db.py (original)
+++ lnt/trunk/lnt/server/db/v4db.py Thu Dec 20 10:25:45 2018
@@ -1,6 +1,5 @@
import glob
import yaml
-import sys
try:
import threading
@@ -14,9 +13,8 @@ import lnt.testing
import lnt.server.db.testsuitedb
import lnt.server.db.migrate
-from lnt.util import logger
from lnt.server.db import testsuite
-from sqlalchemy.orm import joinedload, subqueryload
+from sqlalchemy.orm import joinedload
import lnt.server.db.util
Modified: lnt/trunk/lnt/server/reporting/dailyreport.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/reporting/dailyreport.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/server/reporting/dailyreport.py (original)
+++ lnt/trunk/lnt/server/reporting/dailyreport.py Thu Dec 20 10:25:45 2018
@@ -1,4 +1,3 @@
-from collections import namedtuple
from lnt.server.reporting.analysis import REGRESSED, UNCHANGED_FAIL
from lnt.server.reporting.report import RunResult, RunResults, report_css_styles, pairs, OrderAndHistory
from lnt.util import multidict
@@ -9,6 +8,7 @@ import re
import sqlalchemy.sql
import urllib
+
class DailyReport(object):
def __init__(self, ts, year, month, day, num_prior_days_to_include=3,
day_start_offset_hours=16, for_mail=False,
Modified: lnt/trunk/lnt/server/reporting/latestrunsreport.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/reporting/latestrunsreport.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/server/reporting/latestrunsreport.py (original)
+++ lnt/trunk/lnt/server/reporting/latestrunsreport.py Thu Dec 20 10:25:45 2018
@@ -1,11 +1,8 @@
-from collections import namedtuple
from lnt.server.reporting.analysis import REGRESSED, UNCHANGED_FAIL
from lnt.server.reporting.report import RunResult, RunResults, report_css_styles
-from lnt.util import multidict
import lnt.server.reporting.analysis
import lnt.server.ui.app
-import sqlalchemy.sql
-import urllib
+
class LatestRunsReport(object):
def __init__(self, ts, run_count):
Modified: lnt/trunk/lnt/server/ui/filters.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/filters.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/filters.py (original)
+++ lnt/trunk/lnt/server/ui/filters.py Thu Dec 20 10:25:45 2018
@@ -61,6 +61,7 @@ def filter_filesize(value):
value /= 1024.0
return "%.2f%sB" % (value, 'Yi')
+
def filter_print_value(value, field_unit, field_unit_abbrev, default = '-'):
if value == None:
return default
@@ -70,6 +71,7 @@ def filter_print_value(value, field_unit
else:
return '%.3f' % value
+
def register(env):
for name, object in globals().items():
if name.startswith('filter_'):
Modified: lnt/trunk/lnt/server/ui/profile_views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/profile_views.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/profile_views.py (original)
+++ lnt/trunk/lnt/server/ui/profile_views.py Thu Dec 20 10:25:45 2018
@@ -1,17 +1,6 @@
-import datetime
-from flask import g
from flask import abort
-from flask import render_template
from flask import request
-from flask import make_response
-from flask import flash
-from flask import redirect
-from flask import current_app
from sqlalchemy.orm.exc import NoResultFound
-import flask
-import json
-import sys
-import os
from flask import render_template, current_app
import os
Modified: lnt/trunk/lnt/testing/profile/perf.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/testing/profile/perf.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/testing/profile/perf.py (original)
+++ lnt/trunk/lnt/testing/profile/perf.py Thu Dec 20 10:25:45 2018
@@ -1,7 +1,7 @@
from lnt.util import logger
from profile import ProfileImpl
from profilev1impl import ProfileV1
-import json
+
import os
import traceback
Modified: lnt/trunk/lnt/testing/profile/profilev2impl.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/testing/profile/profilev2impl.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/testing/profile/profilev2impl.py (original)
+++ lnt/trunk/lnt/testing/profile/profilev2impl.py Thu Dec 20 10:25:45 2018
@@ -264,7 +264,6 @@ class CounterNamePool(Section):
def upgrade(self, impl):
self.idx_to_name = {}
- n = 0
keys = impl.getTopLevelCounters().keys()
for f in impl.getFunctions().values():
Modified: lnt/trunk/lnt/testing/util/commands.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/testing/util/commands.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/testing/util/commands.py (original)
+++ lnt/trunk/lnt/testing/util/commands.py Thu Dec 20 10:25:45 2018
@@ -72,7 +72,6 @@ def capture_with_result(args, include_st
def capture(args, include_stderr=False):
- import subprocess
"""capture(command) - Run the given command (or argv list) in a shell and
return the standard output."""
return capture_with_result(args, include_stderr)[0]
Modified: lnt/trunk/lnt/tests/builtintest.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/tests/builtintest.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/tests/builtintest.py (original)
+++ lnt/trunk/lnt/tests/builtintest.py Thu Dec 20 10:25:45 2018
@@ -9,7 +9,6 @@ from lnt.testing.util.misc import timest
import lnt.util.ServerUtil as ServerUtil
import lnt.util.ImportData as ImportData
-import lnt.server.config as server_config
class OptsContainer(object):
Modified: lnt/trunk/lnt/tests/nt.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/tests/nt.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/tests/nt.py (original)
+++ lnt/trunk/lnt/tests/nt.py Thu Dec 20 10:25:45 2018
@@ -1103,7 +1103,7 @@ def run_test(nick_prefix, iteration, con
if config.remote:
remote_args = [config.remote_client,
"-l", config.remote_user,
- "-p", str(config.remote_port),
+ "-p", str(config.remote_port),
config.remote_host]
run_info['remote_uname'] = capture(remote_args + ["uname", "-a"],
include_stderr=True).strip()
@@ -1403,7 +1403,6 @@ def _process_reruns(config, server_reply
for b in local_results.tests:
# format: suite.test/path/and/name.type<.type>
fields = b.name.split('.')
- test_suite = fields[0]
test_type_size = -1
if fields[-1] == "status":
Modified: lnt/trunk/lnt/tests/test_suite.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/tests/test_suite.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/lnt/tests/test_suite.py (original)
+++ lnt/trunk/lnt/tests/test_suite.py Thu Dec 20 10:25:45 2018
@@ -140,18 +140,18 @@ def _lit_json_to_template(json_reports,
tests_by_suite[suite_name].append(entry)
suites = []
- for id, suite in enumerate(tests_by_suite):
+ for i, suite in enumerate(tests_by_suite):
tests = tests_by_suite[suite]
entry = {'name': suite,
- 'id': id,
+ 'id': i,
'tests': tests,
'timestamp': datetime.datetime.now().replace(microsecond=0)
.isoformat(),
'num_tests': len(tests),
'num_failures': len(
- [x for x in tests if x['code'] == 'FAIL']),
+ [test for test in tests if test['code'] == 'FAIL']),
'num_errors': len(
- [x for x in tests if x['code'] == 'NOEXE'])}
+ [test for test in tests if test['code'] == 'NOEXE'])}
suites.append(entry)
str_template = template_engine.render(suites=suites)
return str_template
@@ -663,8 +663,7 @@ class TestSuiteTest(BuiltinTest):
"CMAKE_C_FLAGS_RELEASE",
"CMAKE_C_FLAGS_RELWITHDEBINFO",
"CMAKE_C_COMPILER_TARGET",
- "CMAKE_CXX_COMPILER_TARGET",
- )]
+ "CMAKE_CXX_COMPILER_TARGET")]
cmake_vars = {}
for line in cmake_lah_output.split("\n"):
for pattern, varname in pattern2var:
Modified: lnt/trunk/tests/server/db/rules.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/db/rules.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/tests/server/db/rules.py (original)
+++ lnt/trunk/tests/server/db/rules.py Thu Dec 20 10:25:45 2018
@@ -9,17 +9,18 @@ logging.basicConfig(level=logging.DEBUG)
import lnt.server.db.rules_manager as rules
+
class RuleProcssingTests(unittest.TestCase):
"""Test the Rules facility."""
def setUp(self):
pass
-
+
def test_rule_loading(self):
"""Can we load the testhook rule?"""
found_rules = rules.load_rules()
self.assertIn('testhook', found_rules)
-
+
def test_hook_loading(self):
"""Can we load and execute the test hook?"""
hooks = rules.register_hooks()
@@ -28,5 +29,6 @@ class RuleProcssingTests(unittest.TestCa
self.assertEqual(ret, "Foo.")
self.assertIn('testhook', rules.DESCRIPTIONS)
+
if __name__ == '__main__':
unittest.main(argv=[sys.argv[0], ])
Modified: lnt/trunk/tests/server/db/search.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/db/search.py?rev=349788&r1=349787&r2=349788&view=diff
==============================================================================
--- lnt/trunk/tests/server/db/search.py (original)
+++ lnt/trunk/tests/server/db/search.py Thu Dec 20 10:25:45 2018
@@ -5,10 +5,10 @@ import lnt.util.ImportData
import lnt.server.instance
from lnt.server.db.search import search
-#logging.basicConfig(level=logging.DEBUG)
base_path = ''
+
class SearchTest(unittest.TestCase):
def setUp(self):
@@ -29,7 +29,6 @@ class SearchTest(unittest.TestCase):
('machine3', '11324'),
('supermachine', '1324'),
('supermachine', '7623')]
-
# Get the database.
self.db = config.get_database('default')
self.session = self.db.make_session()
@@ -41,7 +40,7 @@ class SearchTest(unittest.TestCase):
.replace('@@MACHINE@@', r[0]) \
.replace('@@ORDER@@', r[1])
open(f.name, 'w').write(data)
-
+
result = lnt.util.ImportData.import_and_report(
None, 'default', self.db, self.session, f.name,
format='<auto>', ts_name='nts', show_sample_count=False,
@@ -53,7 +52,7 @@ class SearchTest(unittest.TestCase):
def _mangleResults(self, rs):
return [(r.machine.name, str(r.order.llvm_project_revision))
for r in rs]
-
+
def test_specific(self):
session = self.session
ts = self.db.testsuite.get('nts')
More information about the llvm-commits
mailing list