aboutsummaryrefslogtreecommitdiff
path: root/lnt/server
diff options
context:
space:
mode:
authorChris Matthews <cmatthews5@apple.com>2018-12-14 00:28:09 +0000
committerChris Matthews <cmatthews5@apple.com>2018-12-14 00:28:09 +0000
commita4d613d980e4fc6ed9c8058a54559e533a08c2f5 (patch)
tree97f5bce3b821982dde147746fc6aebf1e5a3f667 /lnt/server
parentfab23d34db5f7ce625633a16bafcb85c1fcc4f11 (diff)
Type annotations for regression code
This code is pretty complex. Having types is very helpful. git-svn-id: https://llvm.org/svn/llvm-project/lnt/trunk@349100 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lnt/server')
-rw-r--r--lnt/server/db/fieldchange.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/lnt/server/db/fieldchange.py b/lnt/server/db/fieldchange.py
index 58fdcb0..d7786f1 100644
--- a/lnt/server/db/fieldchange.py
+++ b/lnt/server/db/fieldchange.py
@@ -1,7 +1,10 @@
import difflib
import sqlalchemy.sql
from sqlalchemy.orm import joinedload
+from sqlalchemy.orm.session import Session
from sqlalchemy.orm.exc import ObjectDeletedError
+from typing import Tuple, List
+
import lnt.server.reporting.analysis
from lnt.testing.util.commands import timed
from lnt.util import logger
@@ -10,6 +13,7 @@ from lnt.server.db.regression import get_ris
from lnt.server.db.regression import rebuild_title
from sqlalchemy import or_
from lnt.server.db import rules_manager as rules
+from lnt.server.db.testsuitedb import TestSuiteDB
# How many runs backwards to use in the previous run set.
# More runs are slower (more DB access), but may provide
# more accurate results.
@@ -25,6 +29,7 @@ def post_submit_tasks(session, ts, run_id):
def delete_fieldchange(session, ts, change):
+ # type: (Session, TestSuiteDB, TestSuiteDB.FieldChange) -> List[int]
"""Delete this field change. Since it might be attahed to a regression
via regression indicators, fix those up too. If this orphans a regression
delete it as well."""
@@ -61,6 +66,7 @@ def delete_fieldchange(session, ts, change):
@timed
def regenerate_fieldchanges_for_run(session, ts, run_id):
+ # type: (Session, TestSuiteDB, int) -> None
"""Regenerate the set of FieldChange objects for the given run.
"""
# Allow for potentially a few different runs, previous_runs, next_runs
@@ -187,11 +193,12 @@ def regenerate_fieldchanges_for_run(session, ts, run_id):
session.commit()
- regressions = session.query(ts.Regression).all()[::-1]
rules.post_submission_hooks(session, ts, run_id)
def is_overlaping(fc1, fc2):
+ # type: (TestSuiteDB.FieldChange, TestSuiteDB.FieldChange) -> bool
+
""""Returns true if these two orders intersect. """
try:
r1_min = fc1.start_order
@@ -206,18 +213,19 @@ def is_overlaping(fc1, fc2):
def percent_similar(a, b):
+ # type: (str, str) -> float
"""
Percent similar: are these strings similar to each other?
:param a: first string
:param b: second string
"""
- # type: (str, str) -> float
s = difflib.SequenceMatcher(lambda x: x.isdigit(), a, b)
return s.ratio()
@timed
def identify_related_changes(session, ts, fc, active_indicators):
+ # type: (Session, TestSuiteDB, TestSuiteDB.FieldChange, List) -> Tuple[bool, List]
"""Can we find a home for this change in some existing regression? If a
match is found add a regression indicator adding this change to that
regression, otherwise create a new regression for this change.