From 09f2319941fc3505f1c0fb9526d4dfe094ece250 Mon Sep 17 00:00:00 2001 From: Olivier Giorgis Date: Thu, 9 Jan 2025 12:05:31 +0100 Subject: [PATCH] reorganize imports with isort --- tests/autoclassify/utils.py | 7 +------ tests/conftest.py | 9 ++++---- tests/e2e/test_job_ingestion.py | 1 - tests/etl/test_bugzilla.py | 3 +-- tests/etl/test_classification_loader.py | 2 +- tests/etl/test_job_loader.py | 2 +- tests/etl/test_load_artifacts.py | 2 +- tests/etl/test_perf_data_load.py | 1 - tests/log_parser/test_store_failure_lines.py | 4 ++-- tests/log_parser/test_tasks.py | 7 ++++--- .../cycle_data/test_perfherder_cycling.py | 21 ++++++++----------- .../cycle_data/test_treeherder_cycling.py | 2 +- tests/model/test_files_bugzilla_map.py | 2 +- tests/model/test_performance_tag.py | 3 +-- tests/perf/auto_perf_sheriffing/conftest.py | 8 +++---- .../test_backfill_reports/conftest.py | 2 +- .../test_backfill_report_maintainer.py | 12 +++-------- .../test_identify_retriggerables.py | 3 ++- .../test_report_backfill_outcome.py | 4 ++-- .../auto_perf_sheriffing/test_secretary.py | 5 ++--- .../auto_perf_sheriffing/test_sherlock.py | 4 ++-- .../test_common_behaviour.py | 5 ++--- .../test_criteria_tracker.py | 6 +++--- .../test_engineer_traction.py | 3 +-- tests/perfalert/test_alerts.py | 2 +- tests/push_health/test_compare.py | 3 ++- tests/push_health/test_tests.py | 2 +- tests/services/pulse/test_consumers.py | 1 + tests/services/test_taskcluster.py | 8 +++---- tests/test_dockerflow.py | 2 +- tests/test_worker/test_stats.py | 10 +++++---- tests/test_worker/test_task.py | 2 +- .../test_taskcluster_download_artifact.py | 2 +- tests/webapp/api/test_bug_creation.py | 1 - tests/webapp/api/test_groupsummary_api.py | 1 + tests/webapp/api/test_perfcompare_api.py | 7 +++---- .../api/test_performance_alertsummary_api.py | 2 +- tests/webapp/api/test_performance_data_api.py | 7 ++++--- .../changelog/migrations/0001_initial.py | 2 +- treeherder/config/settings.py | 2 +- treeherder/config/urls.py | 2 +- treeherder/etl/artifact.py | 2 +- treeherder/etl/bugzilla.py | 6 +++--- treeherder/etl/job_loader.py | 2 +- treeherder/etl/perf.py | 2 +- .../intermittents_commenter/commenter.py | 4 ++-- treeherder/log_parser/artifactbuilders.py | 2 +- treeherder/log_parser/failureline.py | 6 +++--- treeherder/log_parser/tasks.py | 5 +---- treeherder/model/data_cycling/__init__.py | 7 ++++++- treeherder/model/data_cycling/cyclers.py | 19 +++++++++-------- treeherder/model/data_cycling/max_runtime.py | 1 + .../model/data_cycling/removal_strategies.py | 3 ++- .../model/data_cycling/signature_remover.py | 3 ++- treeherder/model/error_summary.py | 2 +- .../commands/backfill_text_log_error_jobs.py | 2 +- .../commands/cache_failure_history.py | 2 +- .../model/management/commands/cycle_data.py | 2 +- .../0002_add_bugjobmap_model_manager.py | 2 +- .../0009_add_manager_to_push_and_job.py | 2 +- .../model/migrations/0020_textlogerror_job.py | 2 +- .../migrations/0021_investigatedtests.py | 2 +- .../migrations/0022_support_group_status.py | 2 +- .../0023_add_filebugzillacomponent.py | 2 +- .../migrations/0027_mozciclassification.py | 2 +- .../migrations/0031_trigram_extension.py | 2 +- treeherder/model/models.py | 5 ++--- treeherder/perf/alerts.py | 4 ++-- .../auto_perf_sheriffing/backfill_reports.py | 12 +++++------ .../perf/auto_perf_sheriffing/factories.py | 4 ++-- .../auto_perf_sheriffing/outcome_checker.py | 4 +--- .../perf/auto_perf_sheriffing/sherlock.py | 2 +- treeherder/perf/email.py | 9 ++++---- .../commands/compute_criteria_formulas.py | 8 +++---- .../commands/report_backfill_outcome.py | 4 ++-- .../0009_non_nullable_issue_tracker.py | 2 +- ..._assignment_support_for_alert_summaries.py | 2 +- .../0024_support_backfill_reports.py | 2 +- .../0033_permit_multi_data_per_job.py | 2 +- .../migrations/0037_extend_backfill_record.py | 2 +- .../0039_store_more_job_details_on_record.py | 2 +- .../0041_backfillnotificationrecord.py | 2 +- .../migrations/0044_perfdatum_bigint_fk.py | 2 +- ...estore_perf_multicommitdatum_and_schema.py | 2 +- ...0047_performancealertsummary_triage_due.py | 2 +- .../0049_performancedatumreplicate.py | 2 +- ...51_performancealertsummary_bug_due_date.py | 2 +- ...performancealertsummarytesting_and_more.py | 2 +- treeherder/perf/models.py | 8 +++---- .../perf/sheriffing_criteria/__init__.py | 16 +++++++------- .../sheriffing_criteria/bugzilla_formulas.py | 4 ++-- .../sheriffing_criteria/criteria_tracking.py | 10 ++++----- treeherder/push_health/builds.py | 3 ++- treeherder/push_health/compare.py | 4 ++-- treeherder/push_health/tests.py | 2 +- treeherder/push_health/usage.py | 2 +- treeherder/services/pulse/__init__.py | 2 +- treeherder/services/pulse/consumers.py | 2 +- treeherder/services/taskcluster.py | 2 +- treeherder/webapp/api/classification.py | 1 - treeherder/webapp/api/groups.py | 4 +--- treeherder/webapp/api/infra_compare.py | 9 ++++---- treeherder/webapp/api/infra_serializers.py | 3 +-- treeherder/webapp/api/investigated_test.py | 6 +++--- treeherder/webapp/api/note.py | 13 ++++++------ treeherder/webapp/api/perfcompare_utils.py | 7 +++---- treeherder/webapp/api/performance_data.py | 9 ++++---- .../webapp/api/performance_serializers.py | 2 +- treeherder/webapp/api/push.py | 2 +- treeherder/workers/stats.py | 14 +++++++------ 110 files changed, 225 insertions(+), 238 deletions(-) diff --git a/tests/autoclassify/utils.py b/tests/autoclassify/utils.py index 3fc5241cef7..8677ef25962 100644 --- a/tests/autoclassify/utils.py +++ b/tests/autoclassify/utils.py @@ -1,11 +1,6 @@ from mozlog.formatters.tbplformatter import TbplFormatter -from treeherder.model.models import ( - FailureLine, - JobLog, - TextLogError, - TextLogErrorMetadata, -) +from treeherder.model.models import FailureLine, JobLog, TextLogError, TextLogErrorMetadata test_line = { "action": "test_result", diff --git a/tests/conftest.py b/tests/conftest.py index ec41c6f5654..5aa6851d5bb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,21 +4,21 @@ import os import platform import time -from os.path import join, dirname +from os.path import dirname, join from unittest.mock import MagicMock -import yaml import kombu +import moz_measure_noise import pytest import responses +import yaml from _pytest.monkeypatch import MonkeyPatch from django.conf import settings from django.core.management import call_command from rest_framework.test import APIClient -import moz_measure_noise -from tests.autoclassify.utils import test_line, create_failure_lines, create_text_log_errors import treeherder.etl.bugzilla +from tests.autoclassify.utils import create_failure_lines, create_text_log_errors, test_line from treeherder.etl.jobs import store_job_data from treeherder.etl.push import store_push_data from treeherder.model import models as th_models @@ -365,6 +365,7 @@ def test_job_3(eleven_job_blobs, create_jobs): @pytest.fixture def mock_log_parser(monkeypatch): from celery import shared_task + from treeherder.log_parser import tasks @shared_task diff --git a/tests/e2e/test_job_ingestion.py b/tests/e2e/test_job_ingestion.py index 3c8264231a7..c5952066d7f 100644 --- a/tests/e2e/test_job_ingestion.py +++ b/tests/e2e/test_job_ingestion.py @@ -2,7 +2,6 @@ from tests.test_utils import add_log_response from treeherder.etl.jobs import store_job_data - from treeherder.model.error_summary import get_error_summary from treeherder.model.models import Job, JobLog, TextLogError diff --git a/tests/etl/test_bugzilla.py b/tests/etl/test_bugzilla.py index f3581f48c34..ebf7da18ec0 100644 --- a/tests/etl/test_bugzilla.py +++ b/tests/etl/test_bugzilla.py @@ -1,9 +1,8 @@ import pytest - from django.urls import reverse from treeherder.etl.bugzilla import BzApiBugProcess -from treeherder.model.models import Bugscache, BugJobMap +from treeherder.model.models import BugJobMap, Bugscache @pytest.mark.django_db(transaction=True) diff --git a/tests/etl/test_classification_loader.py b/tests/etl/test_classification_loader.py index 19376077887..b6fbdfd80f2 100644 --- a/tests/etl/test_classification_loader.py +++ b/tests/etl/test_classification_loader.py @@ -2,9 +2,9 @@ import datetime import json -from requests.models import HTTPError import pytest import responses +from requests.models import HTTPError from treeherder.etl.artifact import store_job_artifacts from treeherder.etl.classification_loader import ClassificationLoader diff --git a/tests/etl/test_job_loader.py b/tests/etl/test_job_loader.py index 89d7b4c1398..7eb9daeba12 100644 --- a/tests/etl/test_job_loader.py +++ b/tests/etl/test_job_loader.py @@ -4,11 +4,11 @@ import pytest import responses import slugid +from django.core.exceptions import ObjectDoesNotExist from treeherder.etl.job_loader import JobLoader from treeherder.etl.taskcluster_pulse.handler import handle_message from treeherder.model.models import Job, JobLog, TaskclusterMetadata -from django.core.exceptions import ObjectDoesNotExist @pytest.fixture diff --git a/tests/etl/test_load_artifacts.py b/tests/etl/test_load_artifacts.py index 2579a503ce2..ade53bb082b 100644 --- a/tests/etl/test_load_artifacts.py +++ b/tests/etl/test_load_artifacts.py @@ -1,8 +1,8 @@ import json from treeherder.etl.artifact import store_job_artifacts -from treeherder.model.models import TextLogError from treeherder.model.error_summary import get_error_summary +from treeherder.model.models import TextLogError def test_load_textlog_summary_twice(test_repository, test_job): diff --git a/tests/etl/test_perf_data_load.py b/tests/etl/test_perf_data_load.py index 512ebbd5153..6765185609b 100644 --- a/tests/etl/test_perf_data_load.py +++ b/tests/etl/test_perf_data_load.py @@ -5,7 +5,6 @@ import time import pytest - from django.core.management import call_command from django.db import IntegrityError diff --git a/tests/log_parser/test_store_failure_lines.py b/tests/log_parser/test_store_failure_lines.py index c9edadfc069..329e63bdd88 100644 --- a/tests/log_parser/test_store_failure_lines.py +++ b/tests/log_parser/test_store_failure_lines.py @@ -6,11 +6,11 @@ from requests.exceptions import HTTPError from treeherder.log_parser.failureline import ( + get_group_results, store_failure_lines, write_failure_lines, - get_group_results, ) -from treeherder.model.models import FailureLine, Group, JobLog, GroupStatus +from treeherder.model.models import FailureLine, Group, GroupStatus, JobLog from ..sampledata import SampleData diff --git a/tests/log_parser/test_tasks.py b/tests/log_parser/test_tasks.py index eefeffb11f2..0824f6f8b39 100644 --- a/tests/log_parser/test_tasks.py +++ b/tests/log_parser/test_tasks.py @@ -1,11 +1,12 @@ -import pytest from unittest.mock import patch +import pytest + from tests.test_utils import add_log_response from treeherder.etl.jobs import store_job_data from treeherder.etl.push import store_push_data -from treeherder.model.error_summary import get_error_summary, bug_suggestions_line -from treeherder.model.models import Job, TextLogError, Bugscache +from treeherder.model.error_summary import bug_suggestions_line, get_error_summary +from treeherder.model.models import Bugscache, Job, TextLogError from ..sampledata import SampleData diff --git a/tests/model/cycle_data/test_perfherder_cycling.py b/tests/model/cycle_data/test_perfherder_cycling.py index 5201ccb9b3d..73d33b946c1 100644 --- a/tests/model/cycle_data/test_perfherder_cycling.py +++ b/tests/model/cycle_data/test_perfherder_cycling.py @@ -1,31 +1,28 @@ import math from datetime import datetime, timedelta -from unittest.mock import MagicMock -from unittest.mock import patch +from unittest.mock import MagicMock, patch import pytest from django.core.management import call_command -from django.db import connection, IntegrityError +from django.db import IntegrityError, connection -from treeherder.model.data_cycling import MaxRuntime -from treeherder.model.data_cycling import PerfherderCycler -from treeherder.model.data_cycling import PublicSignatureRemover +from treeherder.model.data_cycling import MaxRuntime, PerfherderCycler, PublicSignatureRemover from treeherder.model.data_cycling.removal_strategies import ( - MainRemovalStrategy, - TryDataRemoval, IrrelevantDataRemoval, + MainRemovalStrategy, StalledDataRemoval, + TryDataRemoval, ) from treeherder.model.models import Push from treeherder.perf.exceptions import MaxRuntimeExceededError from treeherder.perf.models import ( + BackfillReport, + MultiCommitDatum, + PerformanceAlert, + PerformanceAlertSummary, PerformanceDatum, PerformanceDatumReplicate, PerformanceSignature, - PerformanceAlertSummary, - PerformanceAlert, - MultiCommitDatum, - BackfillReport, ) diff --git a/tests/model/cycle_data/test_treeherder_cycling.py b/tests/model/cycle_data/test_treeherder_cycling.py index 8fc38ff01d4..9703e72d0cc 100644 --- a/tests/model/cycle_data/test_treeherder_cycling.py +++ b/tests/model/cycle_data/test_treeherder_cycling.py @@ -6,7 +6,7 @@ from tests import test_utils from tests.autoclassify.utils import create_failure_lines, test_line -from treeherder.model.models import Job, FailureLine, JobLog, JobType, Machine, JobGroup +from treeherder.model.models import FailureLine, Job, JobGroup, JobLog, JobType, Machine from treeherder.perf.models import PerformanceDatum diff --git a/tests/model/test_files_bugzilla_map.py b/tests/model/test_files_bugzilla_map.py index 732133e5323..544d3c3a476 100644 --- a/tests/model/test_files_bugzilla_map.py +++ b/tests/model/test_files_bugzilla_map.py @@ -1,7 +1,7 @@ import pytest -from treeherder.model.models import BugzillaComponent, FilesBugzillaMap, Repository from treeherder.etl.files_bugzilla_map import FilesBugzillaMapProcess +from treeherder.model.models import BugzillaComponent, FilesBugzillaMap, Repository EXPECTED_PROJECTS = [ "mozilla-central", diff --git a/tests/model/test_performance_tag.py b/tests/model/test_performance_tag.py index 511eb0683e3..05043706d3f 100644 --- a/tests/model/test_performance_tag.py +++ b/tests/model/test_performance_tag.py @@ -1,9 +1,8 @@ import pytest +from django.db.utils import IntegrityError from treeherder.perf.models import PerformanceTag -from django.db.utils import IntegrityError - def test_performance_tags_cannot_have_duplicate_names(transactional_db): PerformanceTag.objects.create(name="harness") diff --git a/tests/perf/auto_perf_sheriffing/conftest.py b/tests/perf/auto_perf_sheriffing/conftest.py index ef8e4ceb828..c77e5af5d64 100644 --- a/tests/perf/auto_perf_sheriffing/conftest.py +++ b/tests/perf/auto_perf_sheriffing/conftest.py @@ -7,15 +7,15 @@ import taskcluster from freezegun import freeze_time -from tests.conftest import SampleDataJSONLoader, create_perf_signature, create_perf_alert -from treeherder.model.models import MachinePlatform, Job, JobGroup, JobType +from tests.conftest import SampleDataJSONLoader, create_perf_alert, create_perf_signature +from treeherder.model.models import Job, JobGroup, JobType, MachinePlatform from treeherder.perf.auto_perf_sheriffing.secretary import Secretary from treeherder.perf.models import ( - BackfillReport, BackfillRecord, + BackfillReport, + PerformanceAlert, PerformanceSettings, PerformanceSignature, - PerformanceAlert, ) # For testing Sherlock diff --git a/tests/perf/auto_perf_sheriffing/test_backfill_reports/conftest.py b/tests/perf/auto_perf_sheriffing/test_backfill_reports/conftest.py index 5e93cb453ae..2cb0056ec6c 100644 --- a/tests/perf/auto_perf_sheriffing/test_backfill_reports/conftest.py +++ b/tests/perf/auto_perf_sheriffing/test_backfill_reports/conftest.py @@ -7,7 +7,7 @@ import pytest from tests.conftest import create_perf_alert -from treeherder.model.models import Job, Option, OptionCollection, MachinePlatform +from treeherder.model.models import Job, MachinePlatform, Option, OptionCollection from treeherder.perf.auto_perf_sheriffing.backfill_reports import AlertsPicker from treeherder.perf.models import PerformanceAlert, PerformanceDatum, PerformanceSignature diff --git a/tests/perf/auto_perf_sheriffing/test_backfill_reports/test_backfill_report_maintainer.py b/tests/perf/auto_perf_sheriffing/test_backfill_reports/test_backfill_report_maintainer.py index 682e23d07a4..ca10d636b4b 100644 --- a/tests/perf/auto_perf_sheriffing/test_backfill_reports/test_backfill_report_maintainer.py +++ b/tests/perf/auto_perf_sheriffing/test_backfill_reports/test_backfill_report_maintainer.py @@ -1,14 +1,8 @@ -import random import datetime +import random -from treeherder.perf.auto_perf_sheriffing.backfill_reports import ( - BackfillReportMaintainer, -) -from treeherder.perf.models import ( - BackfillRecord, - BackfillReport, - PerformanceAlert, -) +from treeherder.perf.auto_perf_sheriffing.backfill_reports import BackfillReportMaintainer +from treeherder.perf.models import BackfillRecord, BackfillReport, PerformanceAlert EPOCH = datetime.datetime.utcfromtimestamp(0) diff --git a/tests/perf/auto_perf_sheriffing/test_backfill_reports/test_identify_retriggerables.py b/tests/perf/auto_perf_sheriffing/test_backfill_reports/test_identify_retriggerables.py index dbdaea8e494..69d9531515a 100644 --- a/tests/perf/auto_perf_sheriffing/test_backfill_reports/test_identify_retriggerables.py +++ b/tests/perf/auto_perf_sheriffing/test_backfill_reports/test_identify_retriggerables.py @@ -4,9 +4,10 @@ import pytest -from .conftest import NON_RETRIGGERABLE_JOB_ID, ONE_DAY_INTERVAL from treeherder.perf.auto_perf_sheriffing.backfill_reports import IdentifyAlertRetriggerables +from .conftest import NON_RETRIGGERABLE_JOB_ID, ONE_DAY_INTERVAL + # Unit tests def test_identify_retriggerables_as_unit(): diff --git a/tests/perf/auto_perf_sheriffing/test_report_backfill_outcome.py b/tests/perf/auto_perf_sheriffing/test_report_backfill_outcome.py index b6de40cc3c8..ff73d7f7103 100644 --- a/tests/perf/auto_perf_sheriffing/test_report_backfill_outcome.py +++ b/tests/perf/auto_perf_sheriffing/test_report_backfill_outcome.py @@ -1,12 +1,12 @@ from datetime import datetime, timedelta import pytest -from tests import settings as test_settings from django.core.management import call_command +from tests import settings as test_settings from treeherder.perf.auto_perf_sheriffing.sherlock import Sherlock -from treeherder.perf.models import BackfillNotificationRecord from treeherder.perf.exceptions import MaxRuntimeExceededError +from treeherder.perf.models import BackfillNotificationRecord EPOCH = datetime.utcfromtimestamp(0) diff --git a/tests/perf/auto_perf_sheriffing/test_secretary.py b/tests/perf/auto_perf_sheriffing/test_secretary.py index 06b8f0cd075..e55a94fc6d4 100644 --- a/tests/perf/auto_perf_sheriffing/test_secretary.py +++ b/tests/perf/auto_perf_sheriffing/test_secretary.py @@ -3,14 +3,13 @@ import pytest import simplejson as json - from django.db.models import Q from treeherder.config.settings import IS_WINDOWS -from treeherder.perf.auto_perf_sheriffing.secretary import Secretary from treeherder.model.models import Job, Push -from treeherder.perf.models import BackfillRecord, BackfillReport, PerformanceSettings from treeherder.perf.auto_perf_sheriffing.outcome_checker import OutcomeChecker, OutcomeStatus +from treeherder.perf.auto_perf_sheriffing.secretary import Secretary +from treeherder.perf.models import BackfillRecord, BackfillReport, PerformanceSettings # we're testing against this (automatically provided by fixtures) JOB_TYPE_ID = 1 diff --git a/tests/perf/auto_perf_sheriffing/test_sherlock.py b/tests/perf/auto_perf_sheriffing/test_sherlock.py index eba0233f686..f41712fbee2 100644 --- a/tests/perf/auto_perf_sheriffing/test_sherlock.py +++ b/tests/perf/auto_perf_sheriffing/test_sherlock.py @@ -1,11 +1,11 @@ from datetime import datetime, timedelta -import simplejson as json from json import JSONDecodeError import pytest +import simplejson as json from django.db import models -from tests import settings as test_settings +from tests import settings as test_settings from tests.perf.auto_perf_sheriffing.conftest import prepare_record_with_search_str from treeherder.model.models import Job, Push from treeherder.perf.auto_perf_sheriffing.sherlock import Sherlock diff --git a/tests/perf/auto_sheriffing_criteria/test_common_behaviour.py b/tests/perf/auto_sheriffing_criteria/test_common_behaviour.py index 65520dbfd58..774a01b0180 100644 --- a/tests/perf/auto_sheriffing_criteria/test_common_behaviour.py +++ b/tests/perf/auto_sheriffing_criteria/test_common_behaviour.py @@ -1,20 +1,19 @@ +from collections.abc import Callable from datetime import datetime, timedelta import pytest from django.conf import settings -from collections.abc import Callable from tests.perf.auto_sheriffing_criteria.conftest import CASSETTES_RECORDING_DATE from treeherder.config.settings import BZ_DATETIME_FORMAT from treeherder.perf.exceptions import NoFiledBugsError from treeherder.perf.sheriffing_criteria import ( + BugzillaFormula, EngineerTractionFormula, FixRatioFormula, - BugzillaFormula, TotalAlertsFormula, ) - pytestmark = [pytest.mark.freeze_time(CASSETTES_RECORDING_DATE, tick=True)] diff --git a/tests/perf/auto_sheriffing_criteria/test_criteria_tracker.py b/tests/perf/auto_sheriffing_criteria/test_criteria_tracker.py index e9cf5d27dcb..2371ea81b8b 100644 --- a/tests/perf/auto_sheriffing_criteria/test_criteria_tracker.py +++ b/tests/perf/auto_sheriffing_criteria/test_criteria_tracker.py @@ -4,21 +4,21 @@ from dataclasses import replace from datetime import timedelta from itertools import chain -from unittest.mock import MagicMock -from dateutil.parser import parse as dateutil_parse from multiprocessing.pool import AsyncResult +from unittest.mock import MagicMock import pytest +from dateutil.parser import parse as dateutil_parse from freezegun import freeze_time from tests.perf.auto_sheriffing_criteria.conftest import CASSETTES_RECORDING_DATE from treeherder.perf.exceptions import NoFiledBugsError from treeherder.perf.sheriffing_criteria import ( + CriteriaRecord, CriteriaTracker, EngineerTractionFormula, FixRatioFormula, RecordComputer, - CriteriaRecord, TotalAlertsFormula, ) from treeherder.perf.sheriffing_criteria.criteria_tracking import ResultsChecker diff --git a/tests/perf/auto_sheriffing_criteria/test_engineer_traction.py b/tests/perf/auto_sheriffing_criteria/test_engineer_traction.py index dde39207d04..d916e5f161a 100644 --- a/tests/perf/auto_sheriffing_criteria/test_engineer_traction.py +++ b/tests/perf/auto_sheriffing_criteria/test_engineer_traction.py @@ -1,12 +1,11 @@ -import pytest from datetime import datetime, timedelta +import pytest from tests.perf.auto_sheriffing_criteria.conftest import CASSETTES_RECORDING_DATE from treeherder.config.settings import BZ_DATETIME_FORMAT from treeherder.perf.sheriffing_criteria import EngineerTractionFormula - pytestmark = [pytest.mark.freeze_time(CASSETTES_RECORDING_DATE, tick=True)] diff --git a/tests/perfalert/test_alerts.py b/tests/perfalert/test_alerts.py index 1618de35d7e..92d3ece0ccc 100644 --- a/tests/perfalert/test_alerts.py +++ b/tests/perfalert/test_alerts.py @@ -11,7 +11,7 @@ PerformanceDatum, PerformanceSignature, ) -from treeherder.perf.utils import calculate_time_to, TRIAGE_DAYS, BUG_DAYS +from treeherder.perf.utils import BUG_DAYS, TRIAGE_DAYS, calculate_time_to def _verify_alert( diff --git a/tests/push_health/test_compare.py b/tests/push_health/test_compare.py index e114237ad84..036bca0d4c6 100644 --- a/tests/push_health/test_compare.py +++ b/tests/push_health/test_compare.py @@ -1,5 +1,6 @@ -import pytest import datetime + +import pytest import responses from treeherder.model.models import Push diff --git a/tests/push_health/test_tests.py b/tests/push_health/test_tests.py index 64a2769f2b1..d2c953c1a23 100644 --- a/tests/push_health/test_tests.py +++ b/tests/push_health/test_tests.py @@ -1,7 +1,7 @@ import pytest from treeherder.model.models import FailureLine, Job, Repository -from treeherder.push_health.tests import get_test_failures, get_test_failure_jobs, has_job, has_line +from treeherder.push_health.tests import get_test_failure_jobs, get_test_failures, has_job, has_line @pytest.mark.parametrize(("find_it",), [(True,), (False,)]) diff --git a/tests/services/pulse/test_consumers.py b/tests/services/pulse/test_consumers.py index cdef467bc74..33f368a4c88 100644 --- a/tests/services/pulse/test_consumers.py +++ b/tests/services/pulse/test_consumers.py @@ -1,4 +1,5 @@ from unittest.mock import MagicMock + import pytest from django.conf import settings diff --git a/tests/services/test_taskcluster.py b/tests/services/test_taskcluster.py index 3b55fe455ce..a40b0d8e562 100644 --- a/tests/services/test_taskcluster.py +++ b/tests/services/test_taskcluster.py @@ -2,12 +2,12 @@ from tests.conftest import SampleDataJSONLoader from treeherder.services.taskcluster import ( - TaskclusterModelImpl, - taskcluster_model_factory, - notify_client_factory, - NotifyNullObject, NotifyAdapter, + NotifyNullObject, + TaskclusterModelImpl, TaskclusterModelNullObject, + notify_client_factory, + taskcluster_model_factory, ) load_json_fixture = SampleDataJSONLoader("sherlock") diff --git a/tests/test_dockerflow.py b/tests/test_dockerflow.py index 497fe3a9a45..25668195036 100644 --- a/tests/test_dockerflow.py +++ b/tests/test_dockerflow.py @@ -1,6 +1,6 @@ import json -import pytest +import pytest from django.conf import settings diff --git a/tests/test_worker/test_stats.py b/tests/test_worker/test_stats.py index 2ff9bff986d..cfb675751f7 100644 --- a/tests/test_worker/test_stats.py +++ b/tests/test_worker/test_stats.py @@ -1,9 +1,11 @@ +from datetime import timedelta +from unittest.mock import MagicMock, call, patch + import pytest -from unittest.mock import patch, MagicMock, call -from treeherder.workers.stats import publish_stats -from treeherder.model.models import Push, Job from django.utils import timezone -from datetime import timedelta + +from treeherder.model.models import Job, Push +from treeherder.workers.stats import publish_stats @pytest.mark.django_db diff --git a/tests/test_worker/test_task.py b/tests/test_worker/test_task.py index 783bd54d859..301cf9c2f5d 100644 --- a/tests/test_worker/test_task.py +++ b/tests/test_worker/test_task.py @@ -2,8 +2,8 @@ from threading import local import pytest -from django.db.utils import OperationalError from celery.exceptions import Retry +from django.db.utils import OperationalError from treeherder.workers.task import retryable_task diff --git a/tests/utils/test_taskcluster_download_artifact.py b/tests/utils/test_taskcluster_download_artifact.py index 86af0eb8433..53915ff3e7f 100644 --- a/tests/utils/test_taskcluster_download_artifact.py +++ b/tests/utils/test_taskcluster_download_artifact.py @@ -1,6 +1,6 @@ -from requests.models import Response import pytest import responses +from requests.models import Response from treeherder.utils.taskcluster import download_artifact diff --git a/tests/webapp/api/test_bug_creation.py b/tests/webapp/api/test_bug_creation.py index 72e9dee63b6..f01ac994306 100644 --- a/tests/webapp/api/test_bug_creation.py +++ b/tests/webapp/api/test_bug_creation.py @@ -2,7 +2,6 @@ from treeherder.model.models import BugzillaComponent, FilesBugzillaMap - # @pytest.mark.parametrize( # ('offset', 'count', 'expected_num'), # [(None, None, 10), (None, 5, 5), (5, None, 6), (0, 5, 5), (10, 10, 1)], diff --git a/tests/webapp/api/test_groupsummary_api.py b/tests/webapp/api/test_groupsummary_api.py index a04b9a16811..beb700b4713 100644 --- a/tests/webapp/api/test_groupsummary_api.py +++ b/tests/webapp/api/test_groupsummary_api.py @@ -1,4 +1,5 @@ import datetime + from django.urls import reverse diff --git a/tests/webapp/api/test_perfcompare_api.py b/tests/webapp/api/test_perfcompare_api.py index 6ac6f001e63..45c116e4aca 100644 --- a/tests/webapp/api/test_perfcompare_api.py +++ b/tests/webapp/api/test_perfcompare_api.py @@ -1,12 +1,11 @@ import datetime +from unittest import skip + from django.urls import reverse from treeherder.model.models import Job +from treeherder.perf.models import PerformanceDatum from treeherder.webapp.api import perfcompare_utils -from treeherder.perf.models import ( - PerformanceDatum, -) -from unittest import skip NOW = datetime.datetime.now() ONE_DAY_AGO = NOW - datetime.timedelta(days=1) diff --git a/tests/webapp/api/test_performance_alertsummary_api.py b/tests/webapp/api/test_performance_alertsummary_api.py index 1dd29dfebb3..bc80cf84330 100644 --- a/tests/webapp/api/test_performance_alertsummary_api.py +++ b/tests/webapp/api/test_performance_alertsummary_api.py @@ -6,7 +6,7 @@ from tests.conftest import create_perf_alert from treeherder.model.models import Push -from treeherder.perf.models import PerformanceAlertSummary, PerformanceAlert +from treeherder.perf.models import PerformanceAlert, PerformanceAlertSummary @pytest.fixture diff --git a/tests/webapp/api/test_performance_data_api.py b/tests/webapp/api/test_performance_data_api.py index 0b36924324f..d88aaa65a48 100644 --- a/tests/webapp/api/test_performance_data_api.py +++ b/tests/webapp/api/test_performance_data_api.py @@ -1,18 +1,19 @@ import copy -import pytest import datetime -from django.urls import reverse from collections import defaultdict +import pytest +from django.urls import reverse + from tests.conftest import create_perf_alert from treeherder.model.models import MachinePlatform, Push -from treeherder.webapp.api.performance_data import PerformanceSummary from treeherder.perf.models import ( PerformanceAlert, PerformanceDatum, PerformanceFramework, PerformanceSignature, ) +from treeherder.webapp.api.performance_data import PerformanceSummary NOW = datetime.datetime.now() ONE_DAY_AGO = NOW - datetime.timedelta(days=1) diff --git a/treeherder/changelog/migrations/0001_initial.py b/treeherder/changelog/migrations/0001_initial.py index bb05ce004ac..7ab4ee76ef5 100644 --- a/treeherder/changelog/migrations/0001_initial.py +++ b/treeherder/changelog/migrations/0001_initial.py @@ -1,7 +1,7 @@ # Generated by Django 3.0.3 on 2020-03-13 17:43 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/config/settings.py b/treeherder/config/settings.py index 6a4c22648ac..ba77832685f 100644 --- a/treeherder/config/settings.py +++ b/treeherder/config/settings.py @@ -5,12 +5,12 @@ from os.path import abspath, dirname, join import environ +from celery.schedules import crontab from furl import furl from kombu import Exchange, Queue from treeherder.config.utils import connection_should_use_tls from treeherder.middleware import add_headers_function -from celery.schedules import crontab # TODO: Switch to pathlib once using Python 3. SRC_DIR = dirname(dirname(dirname(abspath(__file__)))) diff --git a/treeherder/config/urls.py b/treeherder/config/urls.py index 440de282ff9..08d5404706e 100644 --- a/treeherder/config/urls.py +++ b/treeherder/config/urls.py @@ -1,8 +1,8 @@ from django.conf import settings from django.urls import include, re_path +from django.views.generic.base import TemplateView from treeherder.webapp.api import urls as api_urls -from django.views.generic.base import TemplateView urlpatterns = [] # The order is important for the debug toolbar; it needs to be first diff --git a/treeherder/etl/artifact.py b/treeherder/etl/artifact.py index 2d0b46a7a38..e45af68e4f9 100644 --- a/treeherder/etl/artifact.py +++ b/treeherder/etl/artifact.py @@ -2,10 +2,10 @@ import simplejson as json from django.db.utils import IntegrityError -from treeherder.model import error_summary from treeherder.etl.perf import store_performance_artifact from treeherder.etl.text import astral_filter +from treeherder.model import error_summary from treeherder.model.models import Job, TextLogError logger = logging.getLogger(__name__) diff --git a/treeherder/etl/bugzilla.py b/treeherder/etl/bugzilla.py index ffad02055f8..38074b9e912 100644 --- a/treeherder/etl/bugzilla.py +++ b/treeherder/etl/bugzilla.py @@ -1,12 +1,12 @@ import logging -import requests +from datetime import datetime, timedelta import dateutil.parser -from datetime import datetime, timedelta +import requests from django.conf import settings from django.db.models import Count, Max -from treeherder.model.models import Bugscache, BugJobMap +from treeherder.model.models import BugJobMap, Bugscache from treeherder.utils.github import fetch_json from treeherder.utils.http import make_request diff --git a/treeherder/etl/job_loader.py b/treeherder/etl/job_loader.py index b3111a929da..b45f1e2a058 100644 --- a/treeherder/etl/job_loader.py +++ b/treeherder/etl/job_loader.py @@ -5,11 +5,11 @@ import newrelic.agent import slugid -from treeherder.etl.taskcluster_pulse.handler import ignore_task from treeherder.etl.common import to_timestamp from treeherder.etl.exceptions import MissingPushError from treeherder.etl.jobs import store_job_data from treeherder.etl.schema import get_json_schema +from treeherder.etl.taskcluster_pulse.handler import ignore_task from treeherder.model.models import Push, Repository from treeherder.utils.taskcluster import get_task_definition diff --git a/treeherder/etl/perf.py b/treeherder/etl/perf.py index 3e751c2e294..d4d2cb529de 100644 --- a/treeherder/etl/perf.py +++ b/treeherder/etl/perf.py @@ -4,8 +4,8 @@ from hashlib import sha1 import simplejson as json - from django.conf import settings + from treeherder.log_parser.utils import validate_perf_data from treeherder.model.models import Job, OptionCollection, Repository from treeherder.perf.models import ( diff --git a/treeherder/intermittents_commenter/commenter.py b/treeherder/intermittents_commenter/commenter.py index a094b637897..96b554e3ee5 100644 --- a/treeherder/intermittents_commenter/commenter.py +++ b/treeherder/intermittents_commenter/commenter.py @@ -3,16 +3,16 @@ import time from collections import Counter from datetime import date, datetime, timedelta -import yaml import requests +import yaml from django.conf import settings from django.db.models import Count from jinja2 import Template from requests.exceptions import RequestException from treeherder.intermittents_commenter.constants import COMPONENTS, WHITEBOARD_NEEDSWORK_OWNER -from treeherder.model.models import BugJobMap, Push, OptionCollection +from treeherder.model.models import BugJobMap, OptionCollection, Push logger = logging.getLogger(__name__) diff --git a/treeherder/log_parser/artifactbuilders.py b/treeherder/log_parser/artifactbuilders.py index 82415663fa1..c333cbbc127 100644 --- a/treeherder/log_parser/artifactbuilders.py +++ b/treeherder/log_parser/artifactbuilders.py @@ -1,6 +1,6 @@ import logging -from .parsers import PerformanceParser, ErrorParser +from .parsers import ErrorParser, PerformanceParser logger = logging.getLogger(__name__) diff --git a/treeherder/log_parser/failureline.py b/treeherder/log_parser/failureline.py index 6b72df9a891..60388d7d279 100644 --- a/treeherder/log_parser/failureline.py +++ b/treeherder/log_parser/failureline.py @@ -1,16 +1,16 @@ -from collections import defaultdict import json import logging +from collections import defaultdict from itertools import islice import newrelic.agent from django.conf import settings from django.db import transaction -from django.db.utils import IntegrityError, OperationalError, DataError +from django.db.utils import DataError, IntegrityError, OperationalError from requests.exceptions import HTTPError from treeherder.etl.text import astral_filter -from treeherder.model.models import FailureLine, Group, JobLog, GroupStatus +from treeherder.model.models import FailureLine, Group, GroupStatus, JobLog from treeherder.utils.http import fetch_text logger = logging.getLogger(__name__) diff --git a/treeherder/log_parser/tasks.py b/treeherder/log_parser/tasks.py index 388db82b7b4..edcea360504 100644 --- a/treeherder/log_parser/tasks.py +++ b/treeherder/log_parser/tasks.py @@ -6,10 +6,7 @@ from requests.exceptions import HTTPError from treeherder.etl.artifact import serialize_artifact_json_blobs, store_job_artifacts -from treeherder.log_parser.artifactbuildercollection import ( - ArtifactBuilderCollection, - LogSizeError, -) +from treeherder.log_parser.artifactbuildercollection import ArtifactBuilderCollection, LogSizeError from treeherder.model.models import Job, JobLog from treeherder.workers.task import retryable_task diff --git a/treeherder/model/data_cycling/__init__.py b/treeherder/model/data_cycling/__init__.py index a3b4f4c55c3..63a99bdaf8e 100644 --- a/treeherder/model/data_cycling/__init__.py +++ b/treeherder/model/data_cycling/__init__.py @@ -1,3 +1,8 @@ -from .cyclers import TreeherderCycler, PerfherderCycler, TREEHERDER, PERFHERDER # noqa +from .cyclers import ( + PERFHERDER, # noqa + TREEHERDER, # noqa + PerfherderCycler, # noqa + TreeherderCycler, # noqa +) from .max_runtime import MaxRuntime # noqa from .signature_remover import PublicSignatureRemover # noqa diff --git a/treeherder/model/data_cycling/cyclers.py b/treeherder/model/data_cycling/cyclers.py index 24c66ffaee2..5b6865fa283 100644 --- a/treeherder/model/data_cycling/cyclers.py +++ b/treeherder/model/data_cycling/cyclers.py @@ -1,6 +1,6 @@ import logging from abc import ABC, abstractmethod -from datetime import timedelta, datetime +from datetime import datetime, timedelta from django.db import OperationalError, connection from django.db.backends.utils import CursorWrapper @@ -8,23 +8,24 @@ from treeherder.model.data_cycling.removal_strategies import RemovalStrategy from treeherder.model.models import ( + BuildPlatform, + Group, + GroupStatus, Job, - JobType, JobGroup, + JobType, Machine, - Group, - GroupStatus, - BuildPlatform, MachinePlatform, ) -from treeherder.perf.exceptions import NoDataCyclingAtAllError, MaxRuntimeExceededError +from treeherder.perf.exceptions import MaxRuntimeExceededError, NoDataCyclingAtAllError from treeherder.perf.models import ( - PerformanceSignature, - PerformanceAlertSummary, - PerformanceAlert, BackfillReport, + PerformanceAlert, + PerformanceAlertSummary, + PerformanceSignature, ) from treeherder.services import taskcluster + from .max_runtime import MaxRuntime from .signature_remover import PublicSignatureRemover from .utils import has_valid_explicit_days diff --git a/treeherder/model/data_cycling/max_runtime.py b/treeherder/model/data_cycling/max_runtime.py index 4eb19f155f6..c04209ef5e1 100644 --- a/treeherder/model/data_cycling/max_runtime.py +++ b/treeherder/model/data_cycling/max_runtime.py @@ -1,4 +1,5 @@ from datetime import datetime, timedelta + from treeherder.perf.exceptions import MaxRuntimeExceededError diff --git a/treeherder/model/data_cycling/removal_strategies.py b/treeherder/model/data_cycling/removal_strategies.py index 1e38fc44c2d..f1f15574d90 100644 --- a/treeherder/model/data_cycling/removal_strategies.py +++ b/treeherder/model/data_cycling/removal_strategies.py @@ -2,13 +2,14 @@ import logging from abc import ABC, abstractmethod -from datetime import timedelta, datetime +from datetime import datetime, timedelta from itertools import cycle from django.db.backends.utils import CursorWrapper from treeherder.model.models import Repository from treeherder.perf.models import PerformanceDatum, PerformanceSignature + from .utils import has_valid_explicit_days logger = logging.getLogger(__name__) diff --git a/treeherder/model/data_cycling/signature_remover.py b/treeherder/model/data_cycling/signature_remover.py index 46ca24e3e41..9d74834c978 100644 --- a/treeherder/model/data_cycling/signature_remover.py +++ b/treeherder/model/data_cycling/signature_remover.py @@ -7,8 +7,9 @@ from taskcluster.exceptions import TaskclusterRestFailure from treeherder.perf.models import PerformanceSignature -from .max_runtime import MaxRuntime + from ...perf.email import DeletionNotificationWriter, EmailWriter +from .max_runtime import MaxRuntime logger = logging.getLogger(__name__) diff --git a/treeherder/model/error_summary.py b/treeherder/model/error_summary.py index f346ddd2162..6cfdc22355e 100644 --- a/treeherder/model/error_summary.py +++ b/treeherder/model/error_summary.py @@ -1,8 +1,8 @@ import datetime import logging import re -import newrelic.agent +import newrelic.agent from django.core.cache import cache from treeherder.model.models import Bugscache, TextLogError diff --git a/treeherder/model/management/commands/backfill_text_log_error_jobs.py b/treeherder/model/management/commands/backfill_text_log_error_jobs.py index 0fe42587758..9eaf6338127 100644 --- a/treeherder/model/management/commands/backfill_text_log_error_jobs.py +++ b/treeherder/model/management/commands/backfill_text_log_error_jobs.py @@ -1,10 +1,10 @@ import logging + from django.core.management.base import BaseCommand from treeherder.model.models import TextLogError from treeherder.utils.queryset import chunked_qs - logger = logging.getLogger(__name__) diff --git a/treeherder/model/management/commands/cache_failure_history.py b/treeherder/model/management/commands/cache_failure_history.py index 429c2f3f0e8..770832741be 100644 --- a/treeherder/model/management/commands/cache_failure_history.py +++ b/treeherder/model/management/commands/cache_failure_history.py @@ -4,10 +4,10 @@ from treeherder.model.models import OptionCollection from treeherder.push_health.tests import ( + CACHE_KEY_ROOT, fixed_by_commit_history_days, get_history, intermittent_history_days, - CACHE_KEY_ROOT, ) from treeherder.webapp.api.utils import REPO_GROUPS diff --git a/treeherder/model/management/commands/cycle_data.py b/treeherder/model/management/commands/cycle_data.py index c55cdf22508..0d06103892d 100644 --- a/treeherder/model/management/commands/cycle_data.py +++ b/treeherder/model/management/commands/cycle_data.py @@ -2,7 +2,7 @@ from django.core.management.base import BaseCommand -from treeherder.model.data_cycling import TreeherderCycler, PerfherderCycler, TREEHERDER, PERFHERDER +from treeherder.model.data_cycling import PERFHERDER, TREEHERDER, PerfherderCycler, TreeherderCycler logging.basicConfig(format="%(levelname)s:%(message)s") diff --git a/treeherder/model/migrations/0002_add_bugjobmap_model_manager.py b/treeherder/model/migrations/0002_add_bugjobmap_model_manager.py index 66da6c03dad..3fa886d2c75 100644 --- a/treeherder/model/migrations/0002_add_bugjobmap_model_manager.py +++ b/treeherder/model/migrations/0002_add_bugjobmap_model_manager.py @@ -1,6 +1,6 @@ # Generated by Django 1.11.12 on 2018-04-30 16:50 -from django.db import migrations import django.db.models.manager +from django.db import migrations class Migration(migrations.Migration): diff --git a/treeherder/model/migrations/0009_add_manager_to_push_and_job.py b/treeherder/model/migrations/0009_add_manager_to_push_and_job.py index 06fff69d146..dceb3163d4c 100644 --- a/treeherder/model/migrations/0009_add_manager_to_push_and_job.py +++ b/treeherder/model/migrations/0009_add_manager_to_push_and_job.py @@ -1,6 +1,6 @@ # Generated by Django 1.11.15 on 2018-09-18 18:21 -from django.db import migrations import django.db.models.manager +from django.db import migrations class Migration(migrations.Migration): diff --git a/treeherder/model/migrations/0020_textlogerror_job.py b/treeherder/model/migrations/0020_textlogerror_job.py index 33582074698..bbffbbb36e9 100644 --- a/treeherder/model/migrations/0020_textlogerror_job.py +++ b/treeherder/model/migrations/0020_textlogerror_job.py @@ -1,7 +1,7 @@ # Generated by Django 3.0.5 on 2020-05-27 21:24 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/model/migrations/0021_investigatedtests.py b/treeherder/model/migrations/0021_investigatedtests.py index b754cbf12c0..dab1bf01c72 100644 --- a/treeherder/model/migrations/0021_investigatedtests.py +++ b/treeherder/model/migrations/0021_investigatedtests.py @@ -1,7 +1,7 @@ # Generated by Django 3.0.8 on 2020-09-29 17:42 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/model/migrations/0022_support_group_status.py b/treeherder/model/migrations/0022_support_group_status.py index ef9c132e771..ce723790143 100644 --- a/treeherder/model/migrations/0022_support_group_status.py +++ b/treeherder/model/migrations/0022_support_group_status.py @@ -1,7 +1,7 @@ # Generated by Django 3.0.8 on 2020-10-12 18:09 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/model/migrations/0023_add_filebugzillacomponent.py b/treeherder/model/migrations/0023_add_filebugzillacomponent.py index 23a51a00b4a..3c691e827a7 100644 --- a/treeherder/model/migrations/0023_add_filebugzillacomponent.py +++ b/treeherder/model/migrations/0023_add_filebugzillacomponent.py @@ -1,7 +1,7 @@ # Generated by Django 3.1.8 on 2021-05-23 15:43 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/model/migrations/0027_mozciclassification.py b/treeherder/model/migrations/0027_mozciclassification.py index e84d0861f04..20a4a217b75 100644 --- a/treeherder/model/migrations/0027_mozciclassification.py +++ b/treeherder/model/migrations/0027_mozciclassification.py @@ -1,9 +1,9 @@ # Generated by Django 3.1.13 on 2021-12-22 12:27 import django.core.validators -from django.db import migrations, models import django.db.models.deletion import django.utils.timezone +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/model/migrations/0031_trigram_extension.py b/treeherder/model/migrations/0031_trigram_extension.py index 896165dcbeb..06c41db19e3 100644 --- a/treeherder/model/migrations/0031_trigram_extension.py +++ b/treeherder/model/migrations/0031_trigram_extension.py @@ -1,7 +1,7 @@ # Generated by Django 4.1.13 on 2024-03-25 16:15 -from django.db import migrations from django.contrib.postgres.operations import TrigramExtension +from django.db import migrations class Migration(migrations.Migration): diff --git a/treeherder/model/models.py b/treeherder/model/models.py index 49bc0a347a1..c46ec44bb2c 100644 --- a/treeherder/model/models.py +++ b/treeherder/model/models.py @@ -2,20 +2,19 @@ import itertools import logging import time -from hashlib import sha1 - import warnings +from hashlib import sha1 warnings.filterwarnings("ignore", category=DeprecationWarning, module="newrelic") import newrelic.agent from django.contrib.auth.models import User +from django.contrib.postgres.search import TrigramSimilarity from django.core.cache import cache from django.core.exceptions import ObjectDoesNotExist from django.core.validators import MinLengthValidator from django.db import models, transaction from django.db.models import Count, Max, Min, Q, Subquery -from django.contrib.postgres.search import TrigramSimilarity from django.db.utils import ProgrammingError from django.forms import model_to_dict from django.utils import timezone diff --git a/treeherder/perf/alerts.py b/treeherder/perf/alerts.py index 7c01b5d5704..c35d80137df 100644 --- a/treeherder/perf/alerts.py +++ b/treeherder/perf/alerts.py @@ -1,13 +1,13 @@ import logging -import numpy as np import time from collections import namedtuple from datetime import datetime +import moz_measure_noise import newrelic.agent +import numpy as np from django.conf import settings from django.db import transaction -import moz_measure_noise from treeherder.perf.models import ( PerformanceAlert, diff --git a/treeherder/perf/auto_perf_sheriffing/backfill_reports.py b/treeherder/perf/auto_perf_sheriffing/backfill_reports.py index 2887c250456..10bdbbcf619 100644 --- a/treeherder/perf/auto_perf_sheriffing/backfill_reports.py +++ b/treeherder/perf/auto_perf_sheriffing/backfill_reports.py @@ -1,17 +1,17 @@ import logging -from datetime import timedelta, datetime -from itertools import zip_longest, groupby +from datetime import datetime, timedelta +from itertools import groupby, zip_longest import simplejson as json -from django.db.models import QuerySet, Q, F +from django.db.models import F, Q, QuerySet from treeherder.perf.exceptions import MissingRecordsError from treeherder.perf.models import ( - PerformanceAlert, - PerformanceDatum, + BackfillRecord, BackfillReport, + PerformanceAlert, PerformanceAlertSummary, - BackfillRecord, + PerformanceDatum, ) from treeherder.utils import default_serializer diff --git a/treeherder/perf/auto_perf_sheriffing/factories.py b/treeherder/perf/auto_perf_sheriffing/factories.py index 561b55fb219..d6797f1aa71 100644 --- a/treeherder/perf/auto_perf_sheriffing/factories.py +++ b/treeherder/perf/auto_perf_sheriffing/factories.py @@ -1,13 +1,13 @@ from datetime import timedelta from treeherder.perf.auto_perf_sheriffing.backfill_reports import ( - BackfillReportMaintainer, AlertsPicker, + BackfillReportMaintainer, IdentifyAlertRetriggerables, ) from treeherder.perf.auto_perf_sheriffing.backfill_tool import BackfillTool -from treeherder.perf.auto_perf_sheriffing.sherlock import Sherlock from treeherder.perf.auto_perf_sheriffing.secretary import Secretary +from treeherder.perf.auto_perf_sheriffing.sherlock import Sherlock from treeherder.services.taskcluster import taskcluster_model_factory diff --git a/treeherder/perf/auto_perf_sheriffing/outcome_checker.py b/treeherder/perf/auto_perf_sheriffing/outcome_checker.py index 92a63e90203..632be3f5615 100644 --- a/treeherder/perf/auto_perf_sheriffing/outcome_checker.py +++ b/treeherder/perf/auto_perf_sheriffing/outcome_checker.py @@ -1,8 +1,6 @@ from enum import Enum -from treeherder.perf.models import ( - BackfillRecord, -) +from treeherder.perf.models import BackfillRecord class OutcomeStatus(Enum): diff --git a/treeherder/perf/auto_perf_sheriffing/sherlock.py b/treeherder/perf/auto_perf_sheriffing/sherlock.py index 2ea0bac8c2e..f3d4a9f112b 100644 --- a/treeherder/perf/auto_perf_sheriffing/sherlock.py +++ b/treeherder/perf/auto_perf_sheriffing/sherlock.py @@ -11,7 +11,7 @@ from treeherder.perf.auto_perf_sheriffing.backfill_tool import BackfillTool from treeherder.perf.auto_perf_sheriffing.secretary import Secretary from treeherder.perf.exceptions import CannotBackfillError, MaxRuntimeExceededError -from treeherder.perf.models import BackfillRecord, BackfillReport, BackfillNotificationRecord +from treeherder.perf.models import BackfillNotificationRecord, BackfillRecord, BackfillReport logger = logging.getLogger(__name__) diff --git a/treeherder/perf/email.py b/treeherder/perf/email.py index 3229be568be..275088336c6 100644 --- a/treeherder/perf/email.py +++ b/treeherder/perf/email.py @@ -7,16 +7,17 @@ """ import logging import re -from dataclasses import dataclass, asdict -from abc import ABC, abstractmethod import urllib.parse +from abc import ABC, abstractmethod +from dataclasses import asdict, dataclass from django.conf import settings + from treeherder.perf.models import ( BackfillRecord, - PerformanceSignature, - PerformanceAlertSummary, PerformanceAlert, + PerformanceAlertSummary, + PerformanceSignature, ) logger = logging.getLogger(__name__) diff --git a/treeherder/perf/management/commands/compute_criteria_formulas.py b/treeherder/perf/management/commands/compute_criteria_formulas.py index 5abdce99437..6a01152b878 100644 --- a/treeherder/perf/management/commands/compute_criteria_formulas.py +++ b/treeherder/perf/management/commands/compute_criteria_formulas.py @@ -1,17 +1,17 @@ import time from datetime import timedelta +from django.core.management.base import BaseCommand +from mo_times import Duration from treeherder.config import settings from treeherder.perf.sheriffing_criteria import ( + CriteriaTracker, EngineerTractionFormula, FixRatioFormula, - CriteriaTracker, TotalAlertsFormula, + criteria_tracking, ) -from treeherder.perf.sheriffing_criteria import criteria_tracking -from mo_times import Duration -from django.core.management.base import BaseCommand def pretty_enumerated(formulas: list[str]) -> str: diff --git a/treeherder/perf/management/commands/report_backfill_outcome.py b/treeherder/perf/management/commands/report_backfill_outcome.py index a22c12c8323..14eca22d692 100644 --- a/treeherder/perf/management/commands/report_backfill_outcome.py +++ b/treeherder/perf/management/commands/report_backfill_outcome.py @@ -1,9 +1,9 @@ import logging -from django.core.management.base import BaseCommand +from django.core.management.base import BaseCommand -from treeherder.perf.models import BackfillNotificationRecord from treeherder.perf.email import BackfillNotificationWriter +from treeherder.perf.models import BackfillNotificationRecord from treeherder.services.taskcluster import notify_client_factory SUCCESS_STATUS = 200 diff --git a/treeherder/perf/migrations/0009_non_nullable_issue_tracker.py b/treeherder/perf/migrations/0009_non_nullable_issue_tracker.py index f87344b66e8..ee464f47305 100644 --- a/treeherder/perf/migrations/0009_non_nullable_issue_tracker.py +++ b/treeherder/perf/migrations/0009_non_nullable_issue_tracker.py @@ -1,6 +1,6 @@ # Generated by Django 1.11.13 on 2018-05-23 08:07 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/perf/migrations/0017_assignment_support_for_alert_summaries.py b/treeherder/perf/migrations/0017_assignment_support_for_alert_summaries.py index 6df5937f5c3..e4faad70014 100644 --- a/treeherder/perf/migrations/0017_assignment_support_for_alert_summaries.py +++ b/treeherder/perf/migrations/0017_assignment_support_for_alert_summaries.py @@ -1,8 +1,8 @@ # Generated by Django 2.2.4 on 2019-08-13 13:55 +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/treeherder/perf/migrations/0024_support_backfill_reports.py b/treeherder/perf/migrations/0024_support_backfill_reports.py index 3b410feffb2..3e15f5552dd 100644 --- a/treeherder/perf/migrations/0024_support_backfill_reports.py +++ b/treeherder/perf/migrations/0024_support_backfill_reports.py @@ -1,7 +1,7 @@ # Generated by Django 2.2.6 on 2019-11-14 08:51 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/perf/migrations/0033_permit_multi_data_per_job.py b/treeherder/perf/migrations/0033_permit_multi_data_per_job.py index 4c0a5cf5e37..785012d8dd7 100644 --- a/treeherder/perf/migrations/0033_permit_multi_data_per_job.py +++ b/treeherder/perf/migrations/0033_permit_multi_data_per_job.py @@ -1,7 +1,7 @@ # Generated by Django 3.0.8 on 2020-08-26 08:00 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/perf/migrations/0037_extend_backfill_record.py b/treeherder/perf/migrations/0037_extend_backfill_record.py index 4d0cfe08ed4..2285cfd8610 100644 --- a/treeherder/perf/migrations/0037_extend_backfill_record.py +++ b/treeherder/perf/migrations/0037_extend_backfill_record.py @@ -1,7 +1,7 @@ # Generated by Django 3.1.4 on 2021-02-02 14:05 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/perf/migrations/0039_store_more_job_details_on_record.py b/treeherder/perf/migrations/0039_store_more_job_details_on_record.py index e5661363dc8..5a5236a0513 100644 --- a/treeherder/perf/migrations/0039_store_more_job_details_on_record.py +++ b/treeherder/perf/migrations/0039_store_more_job_details_on_record.py @@ -1,7 +1,7 @@ # Generated by Django 3.1.6 on 2021-04-09 13:31 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/perf/migrations/0041_backfillnotificationrecord.py b/treeherder/perf/migrations/0041_backfillnotificationrecord.py index 1c495a49b91..243ffa19c46 100644 --- a/treeherder/perf/migrations/0041_backfillnotificationrecord.py +++ b/treeherder/perf/migrations/0041_backfillnotificationrecord.py @@ -1,7 +1,7 @@ # Generated by Django 3.1.12 on 2021-08-18 08:06 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/perf/migrations/0044_perfdatum_bigint_fk.py b/treeherder/perf/migrations/0044_perfdatum_bigint_fk.py index 0f3ae82df22..7d1e0538de2 100644 --- a/treeherder/perf/migrations/0044_perfdatum_bigint_fk.py +++ b/treeherder/perf/migrations/0044_perfdatum_bigint_fk.py @@ -2,7 +2,7 @@ On large tables or production environment, it is recommanded to use an external tool (e.g. pt-osc) to update the column and fake this migration. Migration perf.0045 will restore a valid django's schema. """ -from django.db import migrations, connection +from django.db import connection, migrations def alter_perfdatum_pk(apps, schema_editor): diff --git a/treeherder/perf/migrations/0045_restore_perf_multicommitdatum_and_schema.py b/treeherder/perf/migrations/0045_restore_perf_multicommitdatum_and_schema.py index 9920c2527a4..81dab1da458 100644 --- a/treeherder/perf/migrations/0045_restore_perf_multicommitdatum_and_schema.py +++ b/treeherder/perf/migrations/0045_restore_perf_multicommitdatum_and_schema.py @@ -1,5 +1,5 @@ -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/perf/migrations/0047_performancealertsummary_triage_due.py b/treeherder/perf/migrations/0047_performancealertsummary_triage_due.py index 1b8cedad5d9..8847a369830 100644 --- a/treeherder/perf/migrations/0047_performancealertsummary_triage_due.py +++ b/treeherder/perf/migrations/0047_performancealertsummary_triage_due.py @@ -1,7 +1,7 @@ # Generated by Django 3.2.13 on 2022-05-30 11:02 from django.db import migrations, models -from treeherder.perf.utils import calculate_time_to, TRIAGE_DAYS +from treeherder.perf.utils import TRIAGE_DAYS, calculate_time_to def update_summary_triage_due_date(apps, schema_editor): diff --git a/treeherder/perf/migrations/0049_performancedatumreplicate.py b/treeherder/perf/migrations/0049_performancedatumreplicate.py index 7c5366c0ab7..0f8fbb58acf 100644 --- a/treeherder/perf/migrations/0049_performancedatumreplicate.py +++ b/treeherder/perf/migrations/0049_performancedatumreplicate.py @@ -1,7 +1,7 @@ # Generated by Django 4.0.8 on 2023-05-08 17:59 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/treeherder/perf/migrations/0051_performancealertsummary_bug_due_date.py b/treeherder/perf/migrations/0051_performancealertsummary_bug_due_date.py index 0d28c5b9718..a18a38e156f 100644 --- a/treeherder/perf/migrations/0051_performancealertsummary_bug_due_date.py +++ b/treeherder/perf/migrations/0051_performancealertsummary_bug_due_date.py @@ -2,7 +2,7 @@ from django.db import migrations, models -from treeherder.perf.utils import calculate_time_to, BUG_DAYS +from treeherder.perf.utils import BUG_DAYS, calculate_time_to def update_summary_bug_due_date(apps, schema_editor): diff --git a/treeherder/perf/migrations/0053_performancealertsummarytesting_and_more.py b/treeherder/perf/migrations/0053_performancealertsummarytesting_and_more.py index 0bf7955ba8b..7598619ef86 100644 --- a/treeherder/perf/migrations/0053_performancealertsummarytesting_and_more.py +++ b/treeherder/perf/migrations/0053_performancealertsummarytesting_and_more.py @@ -1,8 +1,8 @@ # Generated by Django 4.2.16 on 2024-09-18 16:26 +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/treeherder/perf/models.py b/treeherder/perf/models.py index a834fdf6609..7ab72a63c48 100644 --- a/treeherder/perf/models.py +++ b/treeherder/perf/models.py @@ -1,6 +1,6 @@ +import json import logging from datetime import datetime -import json from functools import reduce from django.contrib.auth.models import User @@ -11,14 +11,14 @@ from treeherder.model.models import ( Job, + JobGroup, + JobType, MachinePlatform, OptionCollection, Push, Repository, - JobType, - JobGroup, ) -from treeherder.perf.utils import calculate_time_to, TRIAGE_DAYS, BUG_DAYS +from treeherder.perf.utils import BUG_DAYS, TRIAGE_DAYS, calculate_time_to from treeherder.utils import default_serializer logger = logging.getLogger(__name__) diff --git a/treeherder/perf/sheriffing_criteria/__init__.py b/treeherder/perf/sheriffing_criteria/__init__.py index 07f1ad36b96..270feffa8ae 100644 --- a/treeherder/perf/sheriffing_criteria/__init__.py +++ b/treeherder/perf/sheriffing_criteria/__init__.py @@ -1,8 +1,8 @@ -from .bugzilla_formulas import ( # noqa - NonBlockableSession, - BugzillaFormula, - EngineerTractionFormula, - FixRatioFormula, - TotalAlertsFormula, -) -from .criteria_tracking import CriteriaTracker, RecordComputer, CriteriaRecord # noqa +from .bugzilla_formulas import BugzillaFormula # noqa +from .bugzilla_formulas import EngineerTractionFormula # noqa +from .bugzilla_formulas import FixRatioFormula # noqa +from .bugzilla_formulas import NonBlockableSession # noqa +from .bugzilla_formulas import TotalAlertsFormula # noqa +from .criteria_tracking import CriteriaRecord # noqa +from .criteria_tracking import CriteriaTracker # noqa +from .criteria_tracking import RecordComputer # noqa diff --git a/treeherder/perf/sheriffing_criteria/bugzilla_formulas.py b/treeherder/perf/sheriffing_criteria/bugzilla_formulas.py index d0473cc7e74..c33456b44a8 100644 --- a/treeherder/perf/sheriffing_criteria/bugzilla_formulas.py +++ b/treeherder/perf/sheriffing_criteria/bugzilla_formulas.py @@ -1,13 +1,13 @@ from abc import ABC, abstractmethod from copy import deepcopy -from datetime import timedelta, datetime +from datetime import datetime, timedelta import requests from django.conf import settings from requests import Session from treeherder.config.settings import BZ_DATETIME_FORMAT -from treeherder.perf.exceptions import NoFiledBugsError, BugzillaEndpointError +from treeherder.perf.exceptions import BugzillaEndpointError, NoFiledBugsError from treeherder.perf.models import PerformanceAlert # Google Doc specification diff --git a/treeherder/perf/sheriffing_criteria/criteria_tracking.py b/treeherder/perf/sheriffing_criteria/criteria_tracking.py index 043c7cde210..5a39ae3707f 100644 --- a/treeherder/perf/sheriffing_criteria/criteria_tracking.py +++ b/treeherder/perf/sheriffing_criteria/criteria_tracking.py @@ -1,16 +1,16 @@ import csv -from dataclasses import dataclass, asdict, replace, fields import logging -from multiprocessing import cpu_count -from multiprocessing.pool import Pool, ThreadPool, AsyncResult import time - +from dataclasses import asdict, dataclass, fields, replace from datetime import datetime, timedelta +from multiprocessing import cpu_count +from multiprocessing.pool import AsyncResult, Pool, ThreadPool from treeherder.perf.exceptions import NoFiledBugsError -from .bugzilla_formulas import BugzillaFormula, EngineerTractionFormula, FixRatioFormula from treeherder.utils import PROJECT_ROOT +from .bugzilla_formulas import BugzillaFormula, EngineerTractionFormula, FixRatioFormula + CRITERIA_FILENAME = "perf-sheriffing-criteria.csv" LOGGER = logging.getLogger(__name__) diff --git a/treeherder/push_health/builds.py b/treeherder/push_health/builds.py index e55df211a5e..0c92b6a61d7 100644 --- a/treeherder/push_health/builds.py +++ b/treeherder/push_health/builds.py @@ -1,6 +1,7 @@ +from django.db.models import Q + from treeherder.model.models import Job, JobType from treeherder.push_health.utils import get_job_results -from django.db.models import Q def get_build_failures(push): diff --git a/treeherder/push_health/compare.py b/treeherder/push_health/compare.py index 140b16f393a..29c8d284342 100644 --- a/treeherder/push_health/compare.py +++ b/treeherder/push_health/compare.py @@ -1,14 +1,14 @@ import logging from treeherder.model.models import Push, Repository -from treeherder.webapp.api.serializers import RepositorySerializer, PushSerializer, CommitSerializer +from treeherder.webapp.api.serializers import CommitSerializer, PushSerializer, RepositorySerializer logger = logging.getLogger(__name__) def get_commit_history(repository, revision, push): - from mozci.push import Push as MozciPush from mozci.errors import ParentPushNotFound + from mozci.push import Push as MozciPush mozci_push = MozciPush([revision], repository.name) parent = None diff --git a/treeherder/push_health/tests.py b/treeherder/push_health/tests.py index a2b92ac04d6..50ef609a7e3 100644 --- a/treeherder/push_health/tests.py +++ b/treeherder/push_health/tests.py @@ -7,7 +7,7 @@ from django.core.cache import cache from django.db.models import Q -from treeherder.model.models import FailureLine, Job, OptionCollection, InvestigatedTests, JobType +from treeherder.model.models import FailureLine, InvestigatedTests, Job, JobType, OptionCollection from treeherder.push_health.classification import get_grouped, set_classifications from treeherder.push_health.filter import filter_failure from treeherder.push_health.utils import clean_config, clean_platform, clean_test, job_to_dict diff --git a/treeherder/push_health/usage.py b/treeherder/push_health/usage.py index c1167f82237..22e89c44dae 100644 --- a/treeherder/push_health/usage.py +++ b/treeherder/push_health/usage.py @@ -1,7 +1,7 @@ import logging from treeherder.config import settings -from treeherder.model.models import Push, Job +from treeherder.model.models import Job, Push from treeherder.push_health.classification import NEED_INVESTIGATION from treeherder.utils.http import make_request from treeherder.webapp.api.serializers import PushSerializer diff --git a/treeherder/services/pulse/__init__.py b/treeherder/services/pulse/__init__.py index bff5025a13c..79727c9adc5 100644 --- a/treeherder/services/pulse/__init__.py +++ b/treeherder/services/pulse/__init__.py @@ -1,8 +1,8 @@ from .consumers import ( JointConsumer, + MozciClassificationConsumer, PushConsumer, TaskConsumer, - MozciClassificationConsumer, prepare_consumers, prepare_joint_consumers, ) diff --git a/treeherder/services/pulse/consumers.py b/treeherder/services/pulse/consumers.py index 04037314380..4a4f4a01449 100644 --- a/treeherder/services/pulse/consumers.py +++ b/treeherder/services/pulse/consumers.py @@ -1,6 +1,6 @@ import logging -import threading import socket +import threading import environ import newrelic.agent diff --git a/treeherder/services/taskcluster.py b/treeherder/services/taskcluster.py index 2da66db3c66..d0a068a6b83 100644 --- a/treeherder/services/taskcluster.py +++ b/treeherder/services/taskcluster.py @@ -1,9 +1,9 @@ import logging import uuid from abc import ABC, abstractmethod -import requests import jsone +import requests import taskcluster from django.conf import settings diff --git a/treeherder/webapp/api/classification.py b/treeherder/webapp/api/classification.py index 9100841380a..31c739aec3f 100644 --- a/treeherder/webapp/api/classification.py +++ b/treeherder/webapp/api/classification.py @@ -1,5 +1,4 @@ from rest_framework import mixins, viewsets - from rest_framework.response import Response from rest_framework.status import HTTP_401_UNAUTHORIZED, HTTP_403_FORBIDDEN, HTTP_404_NOT_FOUND diff --git a/treeherder/webapp/api/groups.py b/treeherder/webapp/api/groups.py index ccd3b1f157e..a934c0813a2 100644 --- a/treeherder/webapp/api/groups.py +++ b/treeherder/webapp/api/groups.py @@ -6,9 +6,7 @@ from rest_framework import generics from rest_framework.response import Response -from treeherder.model.models import ( - Job, -) +from treeherder.model.models import Job from treeherder.webapp.api.serializers import GroupNameSerializer logger = logging.getLogger(__name__) diff --git a/treeherder/webapp/api/infra_compare.py b/treeherder/webapp/api/infra_compare.py index 56ec759da90..b97992e3191 100644 --- a/treeherder/webapp/api/infra_compare.py +++ b/treeherder/webapp/api/infra_compare.py @@ -2,15 +2,14 @@ import logging import time -from rest_framework import generics from django.db.models import F -from treeherder.model import models - -from .infra_serializers import InfraCompareSerializer, InfraCompareQuerySerializers - +from rest_framework import generics from rest_framework.response import Response from rest_framework.status import HTTP_400_BAD_REQUEST +from treeherder.model import models + +from .infra_serializers import InfraCompareQuerySerializers, InfraCompareSerializer logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) diff --git a/treeherder/webapp/api/infra_serializers.py b/treeherder/webapp/api/infra_serializers.py index af80d785020..6ef9c4c884d 100644 --- a/treeherder/webapp/api/infra_serializers.py +++ b/treeherder/webapp/api/infra_serializers.py @@ -1,6 +1,5 @@ -from rest_framework import serializers - from django.core.exceptions import ObjectDoesNotExist +from rest_framework import serializers from treeherder.model.models import Repository diff --git a/treeherder/webapp/api/investigated_test.py b/treeherder/webapp/api/investigated_test.py index d1cd6f78139..4628d537681 100644 --- a/treeherder/webapp/api/investigated_test.py +++ b/treeherder/webapp/api/investigated_test.py @@ -1,9 +1,9 @@ from django.db import IntegrityError -from rest_framework import viewsets, status +from rest_framework import status, viewsets from rest_framework.response import Response -from rest_framework.status import HTTP_404_NOT_FOUND, HTTP_400_BAD_REQUEST +from rest_framework.status import HTTP_400_BAD_REQUEST, HTTP_404_NOT_FOUND -from treeherder.model.models import JobType, Push, Repository, InvestigatedTests +from treeherder.model.models import InvestigatedTests, JobType, Push, Repository from treeherder.webapp.api.serializers import InvestigatedTestsSerializers diff --git a/treeherder/webapp/api/note.py b/treeherder/webapp/api/note.py index 2ba421fb258..9082f3ec11e 100644 --- a/treeherder/webapp/api/note.py +++ b/treeherder/webapp/api/note.py @@ -1,21 +1,20 @@ -from django.core.cache import cache +import logging +from django.core.cache import cache from rest_framework import viewsets from rest_framework.decorators import action from rest_framework.exceptions import ParseError from rest_framework.response import Response from rest_framework.status import HTTP_404_NOT_FOUND -import logging - -from treeherder.model.models import Job, JobNote, Push, TextLogError from treeherder.model.error_summary import ( - get_cleaned_line, - cache_clean_error_line, LINE_CACHE_TIMEOUT, + cache_clean_error_line, + get_cleaned_line, ) +from treeherder.model.models import Job, JobNote, Push, TextLogError -from .serializers import JobNoteSerializer, JobNoteDetailSerializer +from .serializers import JobNoteDetailSerializer, JobNoteSerializer logger = logging.getLogger(__name__) diff --git a/treeherder/webapp/api/perfcompare_utils.py b/treeherder/webapp/api/perfcompare_utils.py index 697faf867c4..58a9bfbe674 100644 --- a/treeherder/webapp/api/perfcompare_utils.py +++ b/treeherder/webapp/api/perfcompare_utils.py @@ -1,9 +1,8 @@ import functools from math import sqrt -from statistics import mean, stdev, median -from treeherder.perf.models import ( - OptionCollection, -) +from statistics import mean, median, stdev + +from treeherder.perf.models import OptionCollection """ Constants """ diff --git a/treeherder/webapp/api/performance_data.py b/treeherder/webapp/api/performance_data.py index b49b8c0ddb9..dbf7ee046b2 100644 --- a/treeherder/webapp/api/performance_data.py +++ b/treeherder/webapp/api/performance_data.py @@ -6,7 +6,7 @@ import django_filters from django.conf import settings from django.db import transaction -from django.db.models import CharField, Count, Q, Subquery, Value, Case, When +from django.db.models import Case, CharField, Count, Q, Subquery, Value, When from django.db.models.functions import Concat from rest_framework import exceptions, filters, generics, pagination, viewsets from rest_framework.response import Response @@ -29,19 +29,20 @@ from treeherder.webapp.api import perfcompare_utils from treeherder.webapp.api.performance_serializers import OptionalBooleanField from treeherder.webapp.api.permissions import IsStaffOrReadOnly + from .exceptions import InsufficientAlertCreationData from .performance_serializers import ( IssueTrackerSerializer, + PerfAlertSummaryTasksQueryParamSerializer, + PerfCompareResultsQueryParamsSerializer, + PerfCompareResultsSerializer, PerformanceAlertSerializer, PerformanceAlertSummarySerializer, PerformanceAlertSummaryTasksSerializer, - PerfAlertSummaryTasksQueryParamSerializer, PerformanceBugTemplateSerializer, PerformanceFrameworkSerializer, PerformanceQueryParamsSerializer, - PerfCompareResultsQueryParamsSerializer, PerformanceSummarySerializer, - PerfCompareResultsSerializer, PerformanceTagSerializer, TestSuiteHealthParamsSerializer, TestSuiteHealthSerializer, diff --git a/treeherder/webapp/api/performance_serializers.py b/treeherder/webapp/api/performance_serializers.py index 2c66b5f739b..3c21eac4a14 100644 --- a/treeherder/webapp/api/performance_serializers.py +++ b/treeherder/webapp/api/performance_serializers.py @@ -19,7 +19,7 @@ PerformanceTag, Push, ) -from treeherder.webapp.api.utils import to_timestamp, FIVE_DAYS +from treeherder.webapp.api.utils import FIVE_DAYS, to_timestamp def get_tc_metadata(alert, push): diff --git a/treeherder/webapp/api/push.py b/treeherder/webapp/api/push.py index f523c33f5b1..2a2eca11ff0 100644 --- a/treeherder/webapp/api/push.py +++ b/treeherder/webapp/api/push.py @@ -14,8 +14,8 @@ from treeherder.push_health.compare import get_commit_history from treeherder.push_health.linting import get_lint_failures from treeherder.push_health.tests import ( - get_test_failures, get_test_failure_jobs, + get_test_failures, get_test_in_progress_count, ) from treeherder.push_health.usage import get_usage diff --git a/treeherder/workers/stats.py b/treeherder/workers/stats.py index 4217876de2f..7ba445664f3 100644 --- a/treeherder/workers/stats.py +++ b/treeherder/workers/stats.py @@ -1,12 +1,14 @@ -from celery import shared_task -from django.conf import settings -from django.utils import timezone +import logging from datetime import timedelta -from django.db.models import Count -from treeherder.model.models import Push, Job from itertools import groupby + import statsd -import logging +from celery import shared_task +from django.conf import settings +from django.db.models import Count +from django.utils import timezone + +from treeherder.model.models import Job, Push logging.basicConfig() logger = logging.getLogger(__name__)