bugbug 0.0.655__tar.gz → 0.0.656__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bugbug-0.0.655 → bugbug-0.0.656}/PKG-INFO +4 -4
- bugbug-0.0.656/VERSION +1 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/model.py +16 -3
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/model_calibration.py +9 -5
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/regressor.py +115 -129
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/testconfigdimensions.py +2 -2
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/testconfigselect.py +4 -3
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/testselect.py +1 -1
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/repository.py +125 -11
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/test_scheduling.py +236 -80
- {bugbug-0.0.655 → bugbug-0.0.656}/pyproject.toml +6 -4
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/commit_classifier.py +2 -1
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/commit_retriever.py +2 -2
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/generate_landings_risk_report.py +21 -9
- bugbug-0.0.655/VERSION +0 -1
- {bugbug-0.0.655 → bugbug-0.0.656}/.gitignore +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/LICENSE +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/bug_features.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/bug_snapshot.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/bugzilla.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/build_platforms.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/code_search/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/code_search/function_search.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/code_search/mozilla.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/code_search/parser.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/code_search/searchfox_api.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/code_search/searchfox_data.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/code_search/searchfox_download.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/commit_features.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/db.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/feature_cleanup.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/github.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/issue_features.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/issue_snapshot.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/labels/annotateignore.csv +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/labels/bug_nobug.csv +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/labels/defect_enhancement_task.csv +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/labels/defect_enhancement_task_e.csv +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/labels/defect_enhancement_task_h.csv +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/labels/defect_enhancement_task_p.csv +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/labels/defect_enhancement_task_s.csv +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/labels/regression_bug_nobug.csv +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/labels/regressionrange.csv +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/labels/str.csv +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/labels/tracking.csv +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/labels.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/accessibility.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/annotate_ignore.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/assignee.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/backout.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/browsername.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/bugtype.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/component.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/component_specific.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/defect.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/defect_enhancement_task.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/devdocneeded.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/fenixcomponent.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/fixtime.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/invalid_compatibility_report.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/needsdiagnosis.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/perf_regression_predictor.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/performancebug.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/qaneeded.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/rcatype.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/regression.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/regressionrange.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/severity.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/spambug.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/stepstoreproduce.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/testfailure.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/tracking.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/uplift.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/models/worksforme.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/nlp.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/calibration.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/commit_risk.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/datasets.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/extraction.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/label_policy.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/push_status.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/regression_commits.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/regression_labeling.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/selection_pairs.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/simulation/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/simulation/capacity.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/simulation/detection.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/simulation/metrics.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/simulation/optimize.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/simulation/splits.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/simulation/stats.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/simulation/strategies.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/simulation/timeline.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/sql/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/sql/perf_alerts.sql +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/sql/perf_capacity_background.sql +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/sql/perf_capacity_builds.sql +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/sql/perf_capacity_eligible.sql +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/sql/perf_capacity_labels.sql +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/sql/perf_capacity_pools.sql +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/sql/perf_capacity_workers.sql +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/sql/perf_pushes.sql +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/sql/perf_task_costs.sql +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/sql/perf_task_filter.sql +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/task_costs.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/perf/task_labels.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/phabricator.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/redash.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/rust_code_analysis_server.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/swarm.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/test_scheduling_features.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/base.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/code_review/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/code_review/agent.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/code_review/data_types.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/code_review/database.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/code_review/langchain_tools.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/code_review/prompts.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/code_review/protocols.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/code_review/review_context.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/code_review/review_context_schema.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/code_review/scorer.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/code_review/utils.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/comment_matching/agent.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/comment_matching/prompts.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/comment_resolution/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/comment_resolution/agent.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/core/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/core/connection.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/core/data_types.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/core/exceptions.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/core/llms.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/core/platforms/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/core/platforms/base.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/core/platforms/bugzilla.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/core/platforms/patch_apply.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/core/platforms/phabricator.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/core/text.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/core/validators.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/patch_summarization/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/patch_summarization/agent.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/patch_summarization/prompts.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/suggestion_filtering/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/suggestion_filtering/agent.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/tools/suggestion_filtering/prompts.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/utils.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/bugbug/vectordb.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/__init__.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/analyze_training_metrics.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/backout_related_test_regressions.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/bug_classifier.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/bug_retriever.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/check.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/check_all_metrics.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/ci_failures_matching.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/comment_classifier.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/comment_level_labeler.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/comment_resolver_runner.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/compatibility_report_classifier.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/gcp_logs_retriever.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/generate_sheet.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/get_type_labels.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/get_untriaged.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/github_issue_classifier.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/github_issue_retriever.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/inline_comments_data_collection.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/integration_test.sh +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/maintenance_effectiveness_indicator.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/microannotate_generator.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/past_bugs_by_unit.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/perf_alerts_retriever.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/perf_commit_risk_scorer.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/perf_regression_predictor.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/perf_scheduling_simulator.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/redundant_failures.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/regressor_finder.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/retrieve_ci_failures.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/retrieve_training_metrics.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/retrieve_try_pushes.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/review_comments_retriever.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/revision_retriever.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/shadow_scheduler_stats.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/test_scheduling_history_retriever.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/testing_policy_stats.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/trainer.py +0 -0
- {bugbug-0.0.655 → bugbug-0.0.656}/scripts/trainer_extract_args.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bugbug
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.656
|
|
4
4
|
Summary: ML tools for Mozilla projects
|
|
5
5
|
Author-email: Marco Castelluccio <mcastelluccio@mozilla.com>
|
|
6
6
|
License-Expression: MPL-2.0
|
|
@@ -31,7 +31,7 @@ Requires-Dist: matplotlib<3.12.0,>=3.10.8
|
|
|
31
31
|
Requires-Dist: mercurial~=7.2
|
|
32
32
|
Requires-Dist: microannotate~=0.0.24
|
|
33
33
|
Requires-Dist: mozci~=2.6.0
|
|
34
|
-
Requires-Dist: numpy
|
|
34
|
+
Requires-Dist: numpy<2.6.0,>=2.4.3
|
|
35
35
|
Requires-Dist: orjson<3.14.0,>=3.11.7
|
|
36
36
|
Requires-Dist: ortools~=9.15.6755
|
|
37
37
|
Requires-Dist: pandas<3.2.0,>=3.0.1
|
|
@@ -62,7 +62,7 @@ Provides-Extra: nlp
|
|
|
62
62
|
Requires-Dist: spacy==3.8.18; extra == 'nlp'
|
|
63
63
|
Provides-Extra: nn
|
|
64
64
|
Provides-Extra: perf-regression-predictor
|
|
65
|
-
Requires-Dist: torch==2.
|
|
66
|
-
Requires-Dist: transformers==5.22.
|
|
65
|
+
Requires-Dist: torch==2.15.0; extra == 'perf-regression-predictor'
|
|
66
|
+
Requires-Dist: transformers==5.22.2; extra == 'perf-regression-predictor'
|
|
67
67
|
Provides-Extra: perf-simulation
|
|
68
68
|
Requires-Dist: optuna>=5.0.0; extra == 'perf-simulation'
|
bugbug-0.0.656/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.656
|
|
@@ -370,12 +370,12 @@ class Model:
|
|
|
370
370
|
"""Subclasses can return boolean masks over the test set, to also report metrics on those subsets."""
|
|
371
371
|
return {}
|
|
372
372
|
|
|
373
|
-
def get_sample_weights(self, y) -> np.ndarray | None:
|
|
373
|
+
def get_sample_weights(self, X, y) -> np.ndarray | None:
|
|
374
374
|
"""Subclasses can return a weight for each training sample, passed to the estimator."""
|
|
375
375
|
return None
|
|
376
376
|
|
|
377
377
|
def fit_classifier(self, X, y):
|
|
378
|
-
sample_weight = self.get_sample_weights(y)
|
|
378
|
+
sample_weight = self.get_sample_weights(X, y)
|
|
379
379
|
if sample_weight is None:
|
|
380
380
|
self.clf.fit(X, y)
|
|
381
381
|
else:
|
|
@@ -419,8 +419,21 @@ class Model:
|
|
|
419
419
|
if len(self.class_names) == 2:
|
|
420
420
|
scorings += ["precision", "recall"]
|
|
421
421
|
|
|
422
|
+
# The folds are weighted like the final model (see fit_classifier); the
|
|
423
|
+
# weights are computed once on the whole training set and split with it.
|
|
424
|
+
cv_y = self.le.transform(y_train)
|
|
425
|
+
sample_weight = self.get_sample_weights(X_train, cv_y)
|
|
422
426
|
scores = cross_validate(
|
|
423
|
-
self.clf,
|
|
427
|
+
self.clf,
|
|
428
|
+
X_train,
|
|
429
|
+
cv_y,
|
|
430
|
+
scoring=scorings,
|
|
431
|
+
cv=5,
|
|
432
|
+
params=(
|
|
433
|
+
{"estimator__sample_weight": sample_weight}
|
|
434
|
+
if sample_weight is not None
|
|
435
|
+
else None
|
|
436
|
+
),
|
|
424
437
|
)
|
|
425
438
|
|
|
426
439
|
logger.info("Cross Validation scores:")
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
from typing import Sequence
|
|
9
9
|
|
|
10
|
+
import numpy as np
|
|
10
11
|
from sklearn.base import BaseEstimator, ClassifierMixin
|
|
11
12
|
from sklearn.calibration import CalibratedClassifierCV
|
|
12
13
|
from sklearn.model_selection import train_test_split
|
|
@@ -39,12 +40,15 @@ class IsotonicRegressionCalibrator(BaseEstimator, ClassifierMixin):
|
|
|
39
40
|
base_clf, cv="prefit", method="isotonic"
|
|
40
41
|
)
|
|
41
42
|
|
|
42
|
-
def fit(self, X_train, y_train):
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
def fit(self, X_train, y_train, sample_weight=None):
|
|
44
|
+
if sample_weight is None:
|
|
45
|
+
sample_weight = np.ones(len(y_train))
|
|
46
|
+
|
|
47
|
+
X_train, X_val, y_train, y_val, w_train, w_val = train_test_split(
|
|
48
|
+
X_train, y_train, sample_weight, test_size=0.2, random_state=42
|
|
45
49
|
)
|
|
46
|
-
self.base_clf.fit(X_train, y_train)
|
|
47
|
-
self.calibrated_clf.fit(X_val, y_val)
|
|
50
|
+
self.base_clf.fit(X_train, y_train, sample_weight=w_train)
|
|
51
|
+
self.calibrated_clf.fit(X_val, y_val, sample_weight=w_val)
|
|
48
52
|
|
|
49
53
|
def predict(self, X):
|
|
50
54
|
return self.calibrated_clf.predict(X)
|
|
@@ -11,8 +11,6 @@ import dateutil.parser
|
|
|
11
11
|
import numpy as np
|
|
12
12
|
import xgboost
|
|
13
13
|
from dateutil.relativedelta import relativedelta
|
|
14
|
-
from imblearn.pipeline import Pipeline as ImblearnPipeline
|
|
15
|
-
from imblearn.under_sampling import RandomUnderSampler
|
|
16
14
|
from sklearn.compose import ColumnTransformer
|
|
17
15
|
from sklearn.feature_extraction import DictVectorizer
|
|
18
16
|
from sklearn.feature_extraction.text import CountVectorizer
|
|
@@ -49,14 +47,71 @@ db.register(
|
|
|
49
47
|
EVALUATION_MONTHS = 3
|
|
50
48
|
|
|
51
49
|
|
|
50
|
+
# Risk bands, as (name, share of bugs in the band). The model separates patches much better
|
|
51
|
+
# at the high end of the risk scale than at the low end, so the bands get narrower as the
|
|
52
|
+
# risk increases.
|
|
53
|
+
RISK_BAND_SHARES = (
|
|
54
|
+
("l", 0.5), # Lower than average risk.
|
|
55
|
+
("a", 0.3), # Average risk.
|
|
56
|
+
("h", 0.15), # Higher than average risk.
|
|
57
|
+
("v", 0.05), # Very high risk.
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def compute_risk_bands(risks: np.ndarray) -> list[tuple[str, float, float]]:
|
|
62
|
+
"""Split the risk scale into contiguous bands holding the RISK_BAND_SHARES of risks.
|
|
63
|
+
|
|
64
|
+
Calibrated risks take few distinct values, so a plain quantile could fall in a large
|
|
65
|
+
group of tied risks and leave a band almost empty. Instead, each threshold is the
|
|
66
|
+
distinct risk value whose share of risks at or below it is closest to the target.
|
|
67
|
+
A risk equal to a threshold belongs to the lower band.
|
|
68
|
+
"""
|
|
69
|
+
values, counts = np.unique(risks, return_counts=True)
|
|
70
|
+
# Share of risks lower than or equal to each distinct value.
|
|
71
|
+
cumulative = np.cumsum(counts) / counts.sum()
|
|
72
|
+
targets = np.cumsum([share for _, share in RISK_BAND_SHARES[:-1]])
|
|
73
|
+
|
|
74
|
+
thresholds = [
|
|
75
|
+
0.0,
|
|
76
|
+
*[float(values[np.argmin(np.abs(cumulative - target))]) for target in targets],
|
|
77
|
+
1.0,
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
return [
|
|
81
|
+
(name, thresholds[i], thresholds[i + 1])
|
|
82
|
+
for i, (name, _) in enumerate(RISK_BAND_SHARES)
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def log_risk_bands(
|
|
87
|
+
risk_bands: list[tuple[str, float, float]],
|
|
88
|
+
risks: np.ndarray,
|
|
89
|
+
is_regressor: np.ndarray,
|
|
90
|
+
) -> None:
|
|
91
|
+
logger.info("Average regression rate is %0.3f", is_regressor.mean())
|
|
92
|
+
|
|
93
|
+
lower_bound = -1.0
|
|
94
|
+
for name, start, end in risk_bands:
|
|
95
|
+
mask = (risks > lower_bound) & (risks <= end)
|
|
96
|
+
lower_bound = end
|
|
97
|
+
logger.info(
|
|
98
|
+
"Risk band %s (%0.4f-%0.4f): %d bugs, regression rate %0.3f",
|
|
99
|
+
name,
|
|
100
|
+
start,
|
|
101
|
+
end,
|
|
102
|
+
mask.sum(),
|
|
103
|
+
is_regressor[mask].mean() if mask.any() else 0.0,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
52
107
|
class RegressorModel(CommitModel):
|
|
53
|
-
|
|
108
|
+
risk_bands: list[tuple[str, float, float]] | None = None
|
|
54
109
|
|
|
55
110
|
def __init__(
|
|
56
111
|
self,
|
|
57
112
|
calibration: bool = True,
|
|
58
113
|
lemmatization: bool = False,
|
|
59
|
-
interpretable: bool =
|
|
114
|
+
interpretable: bool = False,
|
|
60
115
|
use_finder: bool = False,
|
|
61
116
|
exclude_finder: bool = True,
|
|
62
117
|
finder_regressions_only: bool = False,
|
|
@@ -140,18 +195,47 @@ class RegressorModel(CommitModel):
|
|
|
140
195
|
),
|
|
141
196
|
]
|
|
142
197
|
)
|
|
143
|
-
estimator = xgboost.XGBClassifier(
|
|
198
|
+
estimator = xgboost.XGBClassifier(
|
|
199
|
+
n_estimators=600,
|
|
200
|
+
learning_rate=0.03,
|
|
201
|
+
max_depth=6,
|
|
202
|
+
subsample=0.8,
|
|
203
|
+
colsample_bytree=0.5,
|
|
204
|
+
min_child_weight=5,
|
|
205
|
+
n_jobs=utils.get_physical_cpu_count(),
|
|
206
|
+
)
|
|
144
207
|
if calibration:
|
|
145
208
|
estimator = IsotonicRegressionCalibrator(estimator)
|
|
146
209
|
# This is a temporary workaround for the error : "Model type not yet supported by TreeExplainer"
|
|
147
210
|
self.calculate_importance = False
|
|
148
|
-
self.clf =
|
|
211
|
+
self.clf = Pipeline(
|
|
149
212
|
[
|
|
150
213
|
("union", ColumnTransformer(column_transformers)),
|
|
151
|
-
("sampler", RandomUnderSampler(random_state=0)),
|
|
152
214
|
("estimator", estimator),
|
|
153
215
|
]
|
|
154
216
|
)
|
|
217
|
+
self.train_bug_ids: list[int] = []
|
|
218
|
+
|
|
219
|
+
def items_gen(self, classes):
|
|
220
|
+
# Remember the bug of each item, to weight training samples by bug (see get_sample_weights).
|
|
221
|
+
self.train_bug_ids = []
|
|
222
|
+
for commit, label in super().items_gen(classes):
|
|
223
|
+
self.train_bug_ids.append(commit["bug_id"])
|
|
224
|
+
yield commit, label
|
|
225
|
+
|
|
226
|
+
def get_sample_weights(self, X, y):
|
|
227
|
+
# Labels are per bug (a commit is a regressor if its bug caused a regression), and
|
|
228
|
+
# predictions are evaluated per bug, so bugs with many commits would otherwise dominate
|
|
229
|
+
# training: each bug gets the same total weight, split among its commits. The classes
|
|
230
|
+
# are balanced with weights too (instead of undersampling, which would not keep the
|
|
231
|
+
# weights aligned with the samples).
|
|
232
|
+
bug_ids = np.array(self.train_bug_ids)[np.asarray(X.index)]
|
|
233
|
+
_, inverse, counts = np.unique(bug_ids, return_inverse=True, return_counts=True)
|
|
234
|
+
sample_weight = 1.0 / counts[inverse]
|
|
235
|
+
for label in np.unique(y):
|
|
236
|
+
mask = y == label
|
|
237
|
+
sample_weight[mask] *= len(y) / (2 * sample_weight[mask].sum())
|
|
238
|
+
return sample_weight
|
|
155
239
|
|
|
156
240
|
def get_labels(self):
|
|
157
241
|
classes = {}
|
|
@@ -191,21 +275,20 @@ class RegressorModel(CommitModel):
|
|
|
191
275
|
if push_date > datetime.utcnow() - relativedelta(months=EVALUATION_MONTHS):
|
|
192
276
|
continue
|
|
193
277
|
|
|
278
|
+
# Only use the last two years of data, for both classes. The clean set can't go
|
|
279
|
+
# further back anyway, as "Regressed by" data is only reliable since then (see
|
|
280
|
+
# https://groups.google.com/g/mozilla.dev.platform/c/SjjW6_O-FqM/m/G-CrIVT2BAAJ).
|
|
281
|
+
# Taking regressors from a longer period than clean commits would let the model
|
|
282
|
+
# learn "old-looking patch" (e.g. lower experience counts) instead of "risky patch".
|
|
283
|
+
if push_date < datetime.utcnow() - relativedelta(years=2):
|
|
284
|
+
continue
|
|
285
|
+
|
|
194
286
|
node = commit_data["node"]
|
|
195
287
|
if commit_data["bug_id"] in regressor_bugs or (
|
|
196
288
|
self.use_finder and node in regressors
|
|
197
289
|
):
|
|
198
290
|
classes[node] = 1
|
|
199
291
|
elif not self.exclude_finder or node not in regressors:
|
|
200
|
-
# The labels we have are only from two years ago (see https://groups.google.com/g/mozilla.dev.platform/c/SjjW6_O-FqM/m/G-CrIVT2BAAJ).
|
|
201
|
-
# While we can go further back with the regressor finder script, it isn't remotely
|
|
202
|
-
# as precise as the "Regressed By" data.
|
|
203
|
-
# In the future, we might want to re-evaluate this limit (e.g. extend ), but we
|
|
204
|
-
# have to be careful (using too old patches might cause worse results as patch
|
|
205
|
-
# characteristics evolve over time).
|
|
206
|
-
if push_date < datetime.utcnow() - relativedelta(years=2):
|
|
207
|
-
continue
|
|
208
|
-
|
|
209
292
|
# We remove the last 3 months, as there could be regressions which haven't been
|
|
210
293
|
# filed yet. While it is true that some regressions might not be found for a long
|
|
211
294
|
# time, more than 3 months seems overly conservative.
|
|
@@ -228,23 +311,11 @@ class RegressorModel(CommitModel):
|
|
|
228
311
|
|
|
229
312
|
return classes, [0, 1]
|
|
230
313
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
314
|
+
def find_risk_band(self, risk: float) -> str:
|
|
315
|
+
risk_bands = self.risk_bands
|
|
316
|
+
assert risk_bands is not None, "The risk bands are computed at training time"
|
|
234
317
|
|
|
235
|
-
|
|
236
|
-
name, start, end = risk_band.split("-")
|
|
237
|
-
return (name, float(start), float(end))
|
|
238
|
-
|
|
239
|
-
RegressorModel.RISK_BANDS = sorted(
|
|
240
|
-
(
|
|
241
|
-
_parse_risk_band(risk_band)
|
|
242
|
-
for risk_band in utils.get_secret("REGRESSOR_RISK_BANDS").split(";")
|
|
243
|
-
),
|
|
244
|
-
key=lambda x: x[1],
|
|
245
|
-
)
|
|
246
|
-
|
|
247
|
-
for name, start, end in RegressorModel.RISK_BANDS:
|
|
318
|
+
for name, start, end in risk_bands:
|
|
248
319
|
if start <= risk <= end:
|
|
249
320
|
return name
|
|
250
321
|
|
|
@@ -266,7 +337,7 @@ class RegressorModel(CommitModel):
|
|
|
266
337
|
|
|
267
338
|
push_date = dateutil.parser.parse(commit_data["pushdate"])
|
|
268
339
|
|
|
269
|
-
# Use the past
|
|
340
|
+
# Use the past months of data (make sure it is not also used for training!).
|
|
270
341
|
if push_date < datetime.utcnow() - relativedelta(months=EVALUATION_MONTHS):
|
|
271
342
|
continue
|
|
272
343
|
|
|
@@ -279,107 +350,22 @@ class RegressorModel(CommitModel):
|
|
|
279
350
|
# Sort commits by bug ID, so we can use itertools.groupby to group them by bug ID.
|
|
280
351
|
commits.sort(key=lambda x: x["bug_id"])
|
|
281
352
|
|
|
282
|
-
|
|
353
|
+
risks = []
|
|
354
|
+
is_regressor = []
|
|
283
355
|
for bug_id, commit_iter in itertools.groupby(commits, lambda x: x["bug_id"]):
|
|
284
356
|
probs = self.classify(list(commit_iter), probabilities=True)
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
# Let's define the risk bands relatively to average risk.
|
|
288
|
-
# On average, around 1 out of 8 (13%) patches cause regressions.
|
|
289
|
-
# Risk band 1 - around 1 out of 15 (7%) patches within this risk band cause regressions.
|
|
290
|
-
# Risk band 2 - around 1 out of 7 (15%) patches within this risk band cause regressions.
|
|
291
|
-
# Risk bank 3 - around 1 out of 3 (35%) patches within this risk band cause regressions.
|
|
292
|
-
|
|
293
|
-
# Step 1. Calculate % of patches which cause regressions.
|
|
294
|
-
total_landings = len(results)
|
|
295
|
-
total_regressions = sum(is_reg for _, is_reg in results)
|
|
296
|
-
average_regression_rate = total_regressions / total_landings
|
|
297
|
-
|
|
298
|
-
logger.info("Average risk is %0.2f", average_regression_rate)
|
|
299
|
-
|
|
300
|
-
MIN_SAMPLE = 200
|
|
301
|
-
|
|
302
|
-
# Step 2. Define risk band 1 (half than average risk).
|
|
303
|
-
max_band1_prob = 1.0
|
|
304
|
-
total_landings = 0
|
|
305
|
-
total_regressions = 0
|
|
306
|
-
results.sort(key=lambda x: x[0])
|
|
307
|
-
for prob, is_reg in results:
|
|
308
|
-
total_landings += 1
|
|
309
|
-
if is_reg:
|
|
310
|
-
total_regressions += 1
|
|
311
|
-
|
|
312
|
-
if total_landings < MIN_SAMPLE:
|
|
313
|
-
continue
|
|
314
|
-
|
|
315
|
-
print(
|
|
316
|
-
f"{total_regressions} out of {total_landings} patches with risk lower than {prob} caused regressions ({total_regressions / total_landings}"
|
|
317
|
-
)
|
|
318
|
-
|
|
319
|
-
# No need to go further, since we are interested in half than average risk.
|
|
320
|
-
if (
|
|
321
|
-
total_regressions / total_landings
|
|
322
|
-
>= (average_regression_rate / 2) + 0.01
|
|
323
|
-
):
|
|
324
|
-
max_band1_prob = prob
|
|
325
|
-
break
|
|
326
|
-
|
|
327
|
-
print("\n\n")
|
|
328
|
-
|
|
329
|
-
# Step 3. Define risk band 3 (double than average risk).
|
|
330
|
-
min_band3_prob = 0.0
|
|
331
|
-
total_landings = 0
|
|
332
|
-
total_regressions = 0
|
|
333
|
-
results.sort(key=lambda x: x[0], reverse=True)
|
|
334
|
-
for prob, is_reg in results:
|
|
335
|
-
total_landings += 1
|
|
336
|
-
if is_reg:
|
|
337
|
-
total_regressions += 1
|
|
338
|
-
|
|
339
|
-
if total_landings < MIN_SAMPLE:
|
|
340
|
-
continue
|
|
357
|
+
risks.append(max(probs[:, 1]))
|
|
358
|
+
is_regressor.append(bug_id in bug_regressors)
|
|
341
359
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
360
|
+
if len(risks) == 0:
|
|
361
|
+
logger.warning("No bugs in the evaluation set, risk bands not computed")
|
|
362
|
+
return
|
|
345
363
|
|
|
346
|
-
|
|
347
|
-
if (
|
|
348
|
-
total_regressions / total_landings
|
|
349
|
-
<= (average_regression_rate * 2) - 0.01
|
|
350
|
-
):
|
|
351
|
-
min_band3_prob = prob
|
|
352
|
-
break
|
|
353
|
-
|
|
354
|
-
print("\n\n")
|
|
355
|
-
|
|
356
|
-
# Step 4. Define risk band 2 (average risk).
|
|
357
|
-
results.sort(key=lambda x: x[0])
|
|
358
|
-
for prob_start in np.arange(max_band1_prob / 2, max_band1_prob + 0.02, 0.01):
|
|
359
|
-
for prob_end in np.arange(min_band3_prob - 0.02, 0.99, 0.01):
|
|
360
|
-
total_landings = 0
|
|
361
|
-
total_regressions = 0
|
|
362
|
-
for prob, is_reg in results:
|
|
363
|
-
if prob < prob_start or prob > prob_end:
|
|
364
|
-
continue
|
|
365
|
-
|
|
366
|
-
total_landings += 1
|
|
367
|
-
if is_reg:
|
|
368
|
-
total_regressions += 1
|
|
369
|
-
|
|
370
|
-
if total_landings < MIN_SAMPLE:
|
|
371
|
-
continue
|
|
364
|
+
self.risk_bands = compute_risk_bands(np.array(risks))
|
|
372
365
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
> (average_regression_rate * 2) - 0.01
|
|
377
|
-
):
|
|
378
|
-
continue
|
|
379
|
-
|
|
380
|
-
print(
|
|
381
|
-
f"{total_regressions} out of {total_landings} patches with risk between {prob_start} and {prob_end} caused regressions ({total_regressions / total_landings}"
|
|
382
|
-
)
|
|
366
|
+
# Regressions for recent patches might not have been filed yet, so the rates are
|
|
367
|
+
# lower than the actual ones, but their ratios between bands are still meaningful.
|
|
368
|
+
log_risk_bands(self.risk_bands, np.array(risks), np.array(is_regressor))
|
|
383
369
|
|
|
384
370
|
def get_feature_names(self):
|
|
385
371
|
return self.clf.named_steps["union"].get_feature_names_out()
|
|
@@ -489,7 +489,7 @@ class _DimensionClassifierModel(DimensionSelector, Model):
|
|
|
489
489
|
train_len = sum(1 for index in self.row_push_index if index < split)
|
|
490
490
|
return X[:train_len], X[train_len:], y[:train_len], y[train_len:]
|
|
491
491
|
|
|
492
|
-
def get_sample_weights(self, y):
|
|
492
|
+
def get_sample_weights(self, X, y):
|
|
493
493
|
return np.array(self.row_weights[: len(y)])
|
|
494
494
|
|
|
495
495
|
def _predict_proba(self, features: Sequence[dict[str, float]]) -> np.ndarray:
|
|
@@ -596,7 +596,7 @@ class TestConfigSelectClassModel(_DimensionClassifierModel):
|
|
|
596
596
|
y = np.concatenate([y, missing])
|
|
597
597
|
super().fit_classifier(X, y)
|
|
598
598
|
|
|
599
|
-
def get_sample_weights(self, y):
|
|
599
|
+
def get_sample_weights(self, X, y):
|
|
600
600
|
placeholders = getattr(self, "_placeholders", 0)
|
|
601
601
|
weights = np.array(self.row_weights[: len(y) - placeholders])
|
|
602
602
|
return np.concatenate([weights, np.full(placeholders, 1e-6)])
|
|
@@ -331,7 +331,8 @@ def live_candidates(
|
|
|
331
331
|
number if none matches (e.g. for a new platform).
|
|
332
332
|
|
|
333
333
|
As the candidates come from the current task graph, configs that don't exist anymore (e.g. after
|
|
334
|
-
a platform migration) are never selected.
|
|
334
|
+
a platform migration) are never selected. Groups are named as by the models (see
|
|
335
|
+
test_scheduling.normalize_group).
|
|
335
336
|
"""
|
|
336
337
|
patterns = sorted(
|
|
337
338
|
((len(c), c, re.compile(fnmatch.translate(c))) for c in set(known_configs)),
|
|
@@ -351,7 +352,7 @@ def live_candidates(
|
|
|
351
352
|
continue
|
|
352
353
|
config = config_of(_label_without_chunk(label))
|
|
353
354
|
for manifest in manifests:
|
|
354
|
-
result[
|
|
355
|
+
result[test_scheduling.normalize_group(manifest)].add(config)
|
|
355
356
|
|
|
356
357
|
return {group: sorted(configs) for group, configs in result.items()}
|
|
357
358
|
|
|
@@ -789,7 +790,7 @@ class TestConfigSelectModel(ConfigSelector, Model):
|
|
|
789
790
|
)
|
|
790
791
|
return X[:train_len], X[train_len:], y[:train_len], y[train_len:]
|
|
791
792
|
|
|
792
|
-
def get_sample_weights(self, y):
|
|
793
|
+
def get_sample_weights(self, X, y):
|
|
793
794
|
# The training samples are a prefix of the rows generated by items_gen.
|
|
794
795
|
return np.array(self.row_weights[: len(y)])
|
|
795
796
|
|
|
@@ -29,6 +29,7 @@ import lmdb
|
|
|
29
29
|
import requests
|
|
30
30
|
import rs_parsepatch
|
|
31
31
|
import tenacity
|
|
32
|
+
from dateutil.relativedelta import relativedelta
|
|
32
33
|
from tqdm import tqdm
|
|
33
34
|
|
|
34
35
|
from bugbug import db, rust_code_analysis_server, utils
|
|
@@ -62,6 +63,11 @@ REPO_DIR = None
|
|
|
62
63
|
EXPERIENCE_TIMESPAN = 90
|
|
63
64
|
EXPERIENCE_TIMESPAN_TEXT = f"{EXPERIENCE_TIMESPAN}_days"
|
|
64
65
|
|
|
66
|
+
# How far back to recompute the backout and ignore information of already mined
|
|
67
|
+
# commits. Backouts and .hg-annotate-ignore-revs entries usually land within days
|
|
68
|
+
# or weeks of the commit they refer to.
|
|
69
|
+
REFRESH_MONTHS = 6
|
|
70
|
+
|
|
65
71
|
SOURCE_CODE_TYPES_TO_EXT = {
|
|
66
72
|
"Assembly": [".asm", ".S"],
|
|
67
73
|
"Javascript": [".js", ".jsm", ".sjs", ".mjs", ".jsx"],
|
|
@@ -1261,22 +1267,28 @@ def calculate_experiences(
|
|
|
1261
1267
|
update_complex_experiences("component", day, commit.components)
|
|
1262
1268
|
|
|
1263
1269
|
|
|
1264
|
-
def
|
|
1265
|
-
hg: hglib.client, repo_dir: str, commits: Iterable[Commit]
|
|
1266
|
-
) -> None:
|
|
1267
|
-
# Skip commits which are in .hg-annotate-ignore-revs or which have
|
|
1268
|
-
# 'ignore-this-changeset' in their description (mostly consisting of very
|
|
1269
|
-
# large and not meaningful formatting changes).
|
|
1270
|
+
def get_ignore_revs(hg: hglib.client, repo_dir: str) -> set[str]:
|
|
1270
1271
|
ignore_revs_content = hg.cat(
|
|
1271
1272
|
[os.path.join(repo_dir, ".hg-annotate-ignore-revs").encode("ascii")],
|
|
1272
1273
|
rev=b"default",
|
|
1273
1274
|
).decode("utf-8")
|
|
1274
|
-
|
|
1275
|
+
return set(line[:40] for line in ignore_revs_content.splitlines())
|
|
1276
|
+
|
|
1277
|
+
|
|
1278
|
+
def is_ignored(node: str, desc: str, ignore_revs: set[str]) -> bool:
|
|
1279
|
+
# Skip commits which are in .hg-annotate-ignore-revs or which have
|
|
1280
|
+
# 'ignore-this-changeset' in their description (mostly consisting of very
|
|
1281
|
+
# large and not meaningful formatting changes).
|
|
1282
|
+
return node in ignore_revs or "ignore-this-changeset" in desc
|
|
1283
|
+
|
|
1284
|
+
|
|
1285
|
+
def set_commits_to_ignore(
|
|
1286
|
+
hg: hglib.client, repo_dir: str, commits: Iterable[Commit]
|
|
1287
|
+
) -> None:
|
|
1288
|
+
ignore_revs = get_ignore_revs(hg, repo_dir)
|
|
1275
1289
|
|
|
1276
1290
|
for commit in commits:
|
|
1277
|
-
commit.ignored = (
|
|
1278
|
-
commit.node in ignore_revs or "ignore-this-changeset" in commit.desc
|
|
1279
|
-
)
|
|
1291
|
+
commit.ignored = is_ignored(commit.node, commit.desc, ignore_revs)
|
|
1280
1292
|
|
|
1281
1293
|
|
|
1282
1294
|
def download_coverage_mapping() -> None:
|
|
@@ -1521,7 +1533,106 @@ def download_commits(
|
|
|
1521
1533
|
)
|
|
1522
1534
|
|
|
1523
1535
|
|
|
1524
|
-
def
|
|
1536
|
+
def get_backsout(hg: hglib.client, revs: list[bytes]) -> dict[str, list[str]]:
|
|
1537
|
+
"""Get the (short) nodes of the commits backed out by each of the given commits."""
|
|
1538
|
+
if len(revs) == 0:
|
|
1539
|
+
return {}
|
|
1540
|
+
|
|
1541
|
+
args = hglib.util.cmdbuilder(
|
|
1542
|
+
b"log",
|
|
1543
|
+
template="{node}\\0{backsoutnodes}\\0",
|
|
1544
|
+
no_merges=True,
|
|
1545
|
+
rev=revs,
|
|
1546
|
+
)
|
|
1547
|
+
out = hg.rawcommand(args).split(b"\x00")[:-1]
|
|
1548
|
+
|
|
1549
|
+
return {
|
|
1550
|
+
node.decode("ascii"): list(set(backsout.decode("ascii").split(" ")))
|
|
1551
|
+
if backsout != b""
|
|
1552
|
+
else []
|
|
1553
|
+
for node, backsout in hglib.util.grouper(2, out)
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
|
|
1557
|
+
BACKOUT_DESC_RE = re.compile(
|
|
1558
|
+
r"^(Backed out|Back out|Backout|Revert\b)|This reverts commit", re.I | re.M
|
|
1559
|
+
)
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
def refresh_backouts_and_ignored(
|
|
1563
|
+
repo_dir: str, commits: list[CommitDict], months: int = REFRESH_MONTHS
|
|
1564
|
+
) -> None:
|
|
1565
|
+
"""Recompute the backout and ignore information of already mined commits.
|
|
1566
|
+
|
|
1567
|
+
This information is computed when a commit is mined, but it can change
|
|
1568
|
+
afterwards: a commit can be backed out after it was mined, it can be added
|
|
1569
|
+
to .hg-annotate-ignore-revs in a follow-up patch, and the hg extensions that
|
|
1570
|
+
detect backouts can be improved (e.g. to detect git reverts). Everything is
|
|
1571
|
+
repaired in place, so no full re-mining of the commits DB is needed:
|
|
1572
|
+
- `ignored` is recomputed for all commits (a lookup in the current
|
|
1573
|
+
.hg-annotate-ignore-revs);
|
|
1574
|
+
- `backsout` is recomputed for recent commits and for older commits that look
|
|
1575
|
+
like backouts or reverts but were not detected as such when mined;
|
|
1576
|
+
- `backedoutby` is derived from the `backsout` of all commits.
|
|
1577
|
+
|
|
1578
|
+
The experiences (e.g. the number of backouts in the touched files) are not
|
|
1579
|
+
updated, as they are computed incrementally in push order when commits are
|
|
1580
|
+
mined.
|
|
1581
|
+
"""
|
|
1582
|
+
cutoff = str(datetime.utcnow() - relativedelta(months=months))
|
|
1583
|
+
to_refresh = [
|
|
1584
|
+
commit
|
|
1585
|
+
for commit in commits
|
|
1586
|
+
if commit["pushdate"] >= cutoff
|
|
1587
|
+
or (not commit["backsout"] and BACKOUT_DESC_RE.search(commit["desc"]))
|
|
1588
|
+
]
|
|
1589
|
+
|
|
1590
|
+
with hglib.open(repo_dir) as hg:
|
|
1591
|
+
backsout = get_backsout(
|
|
1592
|
+
hg, [commit["node"].encode("ascii") for commit in to_refresh]
|
|
1593
|
+
)
|
|
1594
|
+
ignore_revs = get_ignore_revs(hg, repo_dir)
|
|
1595
|
+
|
|
1596
|
+
updated_backsout = 0
|
|
1597
|
+
for commit in to_refresh:
|
|
1598
|
+
new_backsout = backsout.get(commit["node"], commit["backsout"])
|
|
1599
|
+
if set(new_backsout) != set(commit["backsout"]):
|
|
1600
|
+
updated_backsout += 1
|
|
1601
|
+
commit["backsout"] = new_backsout
|
|
1602
|
+
|
|
1603
|
+
updated_ignored = 0
|
|
1604
|
+
for commit in commits:
|
|
1605
|
+
new_ignored = is_ignored(commit["node"], commit["desc"], ignore_revs)
|
|
1606
|
+
if new_ignored != commit["ignored"]:
|
|
1607
|
+
updated_ignored += 1
|
|
1608
|
+
commit["ignored"] = new_ignored
|
|
1609
|
+
|
|
1610
|
+
# Commits can be backed out by commits mined in a later run, so we derive
|
|
1611
|
+
# {backedoutby} from the backouts instead of relying on its value at mining
|
|
1612
|
+
# time (this is also much faster than the {backedoutby} template keyword,
|
|
1613
|
+
# which searches the descendants of each commit). Commits are in push order,
|
|
1614
|
+
# so the first backout of a commit wins.
|
|
1615
|
+
backedoutby: dict[str, str] = {}
|
|
1616
|
+
for commit in commits:
|
|
1617
|
+
for backedout in commit["backsout"]:
|
|
1618
|
+
backedoutby.setdefault(backedout[:12], commit["node"])
|
|
1619
|
+
|
|
1620
|
+
updated_backedoutby = 0
|
|
1621
|
+
for commit in commits:
|
|
1622
|
+
if not commit["backedoutby"] and commit["node"][:12] in backedoutby:
|
|
1623
|
+
commit["backedoutby"] = backedoutby[commit["node"][:12]]
|
|
1624
|
+
updated_backedoutby += 1
|
|
1625
|
+
|
|
1626
|
+
logger.info(
|
|
1627
|
+
"Refreshed %d commits: updated backsout of %d, ignored of %d, backedoutby of %d",
|
|
1628
|
+
len(to_refresh),
|
|
1629
|
+
updated_backsout,
|
|
1630
|
+
updated_ignored,
|
|
1631
|
+
updated_backedoutby,
|
|
1632
|
+
)
|
|
1633
|
+
|
|
1634
|
+
|
|
1635
|
+
def update_commits(repo_dir: str | None = None) -> None:
|
|
1525
1636
|
if not os.path.exists("data/coverage_mapping.lmdb"):
|
|
1526
1637
|
logger.info("Downloading commit->coverage mapping...")
|
|
1527
1638
|
download_coverage_mapping()
|
|
@@ -1534,6 +1645,9 @@ def update_commits() -> None:
|
|
|
1534
1645
|
# We need to do this because coverage information is sometimes slow to come in.
|
|
1535
1646
|
set_commit_coverage(commits)
|
|
1536
1647
|
|
|
1648
|
+
if repo_dir is not None:
|
|
1649
|
+
refresh_backouts_and_ignored(repo_dir, commits)
|
|
1650
|
+
|
|
1537
1651
|
db.write(COMMITS_DB, commits)
|
|
1538
1652
|
|
|
1539
1653
|
|