bugbug 0.0.661__tar.gz → 0.0.663__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.
Files changed (193) hide show
  1. {bugbug-0.0.661 → bugbug-0.0.663}/PKG-INFO +4 -4
  2. bugbug-0.0.663/VERSION +1 -0
  3. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/model.py +5 -0
  4. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/testselect.py +251 -52
  5. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/repository.py +10 -0
  6. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/test_scheduling.py +111 -0
  7. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/code_review/agent.py +27 -5
  8. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/code_review/data_types.py +5 -20
  9. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/code_review/langchain_tools.py +33 -8
  10. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/code_review/prompts.py +10 -0
  11. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/code_review/review_context.py +6 -17
  12. bugbug-0.0.663/bugbug/tools/code_review/stack.py +166 -0
  13. bugbug-0.0.663/bugbug/tools/core/connection.py +113 -0
  14. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/core/platforms/base.py +33 -6
  15. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/core/platforms/phabricator.py +253 -166
  16. {bugbug-0.0.661 → bugbug-0.0.663}/pyproject.toml +7 -7
  17. bugbug-0.0.661/VERSION +0 -1
  18. bugbug-0.0.661/bugbug/tools/core/connection.py +0 -47
  19. {bugbug-0.0.661 → bugbug-0.0.663}/.gitignore +0 -0
  20. {bugbug-0.0.661 → bugbug-0.0.663}/LICENSE +0 -0
  21. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/__init__.py +0 -0
  22. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/bug_features.py +0 -0
  23. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/bug_snapshot.py +0 -0
  24. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/bugzilla.py +0 -0
  25. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/build_platforms.py +0 -0
  26. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/code_search/__init__.py +0 -0
  27. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/code_search/function_search.py +0 -0
  28. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/code_search/mozilla.py +0 -0
  29. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/code_search/parser.py +0 -0
  30. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/code_search/searchfox_api.py +0 -0
  31. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/code_search/searchfox_data.py +0 -0
  32. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/code_search/searchfox_download.py +0 -0
  33. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/commit_features.py +0 -0
  34. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/db.py +0 -0
  35. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/feature_cleanup.py +0 -0
  36. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/github.py +0 -0
  37. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/issue_features.py +0 -0
  38. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/issue_snapshot.py +0 -0
  39. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/labels/annotateignore.csv +0 -0
  40. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/labels/bug_nobug.csv +0 -0
  41. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/labels/defect_enhancement_task.csv +0 -0
  42. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/labels/defect_enhancement_task_e.csv +0 -0
  43. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/labels/defect_enhancement_task_h.csv +0 -0
  44. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/labels/defect_enhancement_task_p.csv +0 -0
  45. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/labels/defect_enhancement_task_s.csv +0 -0
  46. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/labels/regression_bug_nobug.csv +0 -0
  47. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/labels/regressionrange.csv +0 -0
  48. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/labels/str.csv +0 -0
  49. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/labels/tracking.csv +0 -0
  50. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/labels.py +0 -0
  51. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/model_calibration.py +0 -0
  52. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/__init__.py +0 -0
  53. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/accessibility.py +0 -0
  54. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/annotate_ignore.py +0 -0
  55. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/assignee.py +0 -0
  56. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/backout.py +0 -0
  57. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/browsername.py +0 -0
  58. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/bugtype.py +0 -0
  59. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/component.py +0 -0
  60. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/component_specific.py +0 -0
  61. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/defect.py +0 -0
  62. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/defect_enhancement_task.py +0 -0
  63. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/devdocneeded.py +0 -0
  64. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/fenixcomponent.py +0 -0
  65. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/fixtime.py +0 -0
  66. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/invalid_compatibility_report.py +0 -0
  67. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/needsdiagnosis.py +0 -0
  68. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/perf_regression_predictor.py +0 -0
  69. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/performancebug.py +0 -0
  70. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/qaneeded.py +0 -0
  71. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/rcatype.py +0 -0
  72. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/regression.py +0 -0
  73. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/regressionrange.py +0 -0
  74. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/regressor.py +0 -0
  75. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/severity.py +0 -0
  76. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/spambug.py +0 -0
  77. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/stepstoreproduce.py +0 -0
  78. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/testconfigdimensions.py +0 -0
  79. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/testconfigselect.py +0 -0
  80. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/testfailure.py +0 -0
  81. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/tracking.py +0 -0
  82. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/uplift.py +0 -0
  83. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/models/worksforme.py +0 -0
  84. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/nlp.py +0 -0
  85. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/__init__.py +0 -0
  86. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/calibration.py +0 -0
  87. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/commit_risk.py +0 -0
  88. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/datasets.py +0 -0
  89. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/extraction.py +0 -0
  90. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/label_policy.py +0 -0
  91. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/push_status.py +0 -0
  92. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/regression_commits.py +0 -0
  93. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/regression_labeling.py +0 -0
  94. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/selection_pairs.py +0 -0
  95. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/simulation/__init__.py +0 -0
  96. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/simulation/capacity.py +0 -0
  97. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/simulation/detection.py +0 -0
  98. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/simulation/metrics.py +0 -0
  99. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/simulation/optimize.py +0 -0
  100. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/simulation/splits.py +0 -0
  101. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/simulation/stats.py +0 -0
  102. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/simulation/strategies.py +0 -0
  103. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/simulation/timeline.py +0 -0
  104. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/sql/__init__.py +0 -0
  105. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/sql/perf_alerts.sql +0 -0
  106. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/sql/perf_capacity_background.sql +0 -0
  107. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/sql/perf_capacity_builds.sql +0 -0
  108. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/sql/perf_capacity_eligible.sql +0 -0
  109. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/sql/perf_capacity_labels.sql +0 -0
  110. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/sql/perf_capacity_pools.sql +0 -0
  111. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/sql/perf_capacity_workers.sql +0 -0
  112. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/sql/perf_pushes.sql +0 -0
  113. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/sql/perf_task_costs.sql +0 -0
  114. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/sql/perf_task_filter.sql +0 -0
  115. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/task_costs.py +0 -0
  116. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/perf/task_labels.py +0 -0
  117. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/phabricator.py +0 -0
  118. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/redash.py +0 -0
  119. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/rust_code_analysis_server.py +0 -0
  120. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/sklearn_utils.py +0 -0
  121. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/swarm.py +0 -0
  122. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/test_scheduling_features.py +0 -0
  123. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/__init__.py +0 -0
  124. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/base.py +0 -0
  125. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/code_review/__init__.py +0 -0
  126. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/code_review/database.py +0 -0
  127. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/code_review/protocols.py +0 -0
  128. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/code_review/review_context_schema.py +0 -0
  129. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/code_review/scorer.py +0 -0
  130. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/code_review/utils.py +0 -0
  131. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/comment_matching/agent.py +0 -0
  132. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/comment_matching/prompts.py +0 -0
  133. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/comment_resolution/__init__.py +0 -0
  134. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/comment_resolution/agent.py +0 -0
  135. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/core/__init__.py +0 -0
  136. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/core/data_types.py +0 -0
  137. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/core/exceptions.py +0 -0
  138. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/core/llms.py +0 -0
  139. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/core/platforms/__init__.py +0 -0
  140. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/core/platforms/bugzilla.py +0 -0
  141. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/core/platforms/patch_apply.py +0 -0
  142. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/core/text.py +0 -0
  143. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/core/validators.py +0 -0
  144. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/patch_summarization/__init__.py +0 -0
  145. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/patch_summarization/agent.py +0 -0
  146. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/patch_summarization/prompts.py +0 -0
  147. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/suggestion_filtering/__init__.py +0 -0
  148. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/suggestion_filtering/agent.py +0 -0
  149. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/tools/suggestion_filtering/prompts.py +0 -0
  150. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/utils.py +0 -0
  151. {bugbug-0.0.661 → bugbug-0.0.663}/bugbug/vectordb.py +0 -0
  152. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/__init__.py +0 -0
  153. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/analyze_training_metrics.py +0 -0
  154. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/backout_related_test_regressions.py +0 -0
  155. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/bug_classifier.py +0 -0
  156. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/bug_retriever.py +0 -0
  157. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/check.py +0 -0
  158. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/check_all_metrics.py +0 -0
  159. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/ci_failures_matching.py +0 -0
  160. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/comment_classifier.py +0 -0
  161. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/comment_level_labeler.py +0 -0
  162. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/comment_resolver_runner.py +0 -0
  163. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/commit_classifier.py +0 -0
  164. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/commit_retriever.py +0 -0
  165. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/compatibility_report_classifier.py +0 -0
  166. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/gcp_logs_retriever.py +0 -0
  167. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/generate_landings_risk_report.py +0 -0
  168. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/generate_sheet.py +0 -0
  169. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/get_type_labels.py +0 -0
  170. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/get_untriaged.py +0 -0
  171. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/github_issue_classifier.py +0 -0
  172. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/github_issue_retriever.py +0 -0
  173. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/inline_comments_data_collection.py +0 -0
  174. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/integration_test.sh +0 -0
  175. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/maintenance_effectiveness_indicator.py +0 -0
  176. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/microannotate_generator.py +0 -0
  177. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/past_bugs_by_unit.py +0 -0
  178. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/perf_alerts_retriever.py +0 -0
  179. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/perf_commit_risk_scorer.py +0 -0
  180. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/perf_regression_predictor.py +0 -0
  181. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/perf_scheduling_simulator.py +0 -0
  182. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/redundant_failures.py +0 -0
  183. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/regressor_finder.py +0 -0
  184. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/retrieve_ci_failures.py +0 -0
  185. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/retrieve_training_metrics.py +0 -0
  186. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/retrieve_try_pushes.py +0 -0
  187. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/review_comments_retriever.py +0 -0
  188. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/revision_retriever.py +0 -0
  189. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/shadow_scheduler_stats.py +0 -0
  190. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/test_scheduling_history_retriever.py +0 -0
  191. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/testing_policy_stats.py +0 -0
  192. {bugbug-0.0.661 → bugbug-0.0.663}/scripts/trainer.py +0 -0
  193. {bugbug-0.0.661 → bugbug-0.0.663}/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.661
3
+ Version: 0.0.663
4
4
  Summary: ML tools for Mozilla projects
5
5
  Author-email: Marco Castelluccio <mcastelluccio@mozilla.com>
6
6
  License-Expression: MPL-2.0
@@ -30,7 +30,7 @@ Requires-Dist: markdown2~=2.5.5
30
30
  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
- Requires-Dist: mozci~=2.6.2
33
+ Requires-Dist: mozci~=2.6.6
34
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
@@ -50,7 +50,7 @@ Requires-Dist: searchfox>=0.20.3
50
50
  Requires-Dist: sendgrid~=6.12.5
51
51
  Requires-Dist: shap[plots]<0.55,>=0.51
52
52
  Requires-Dist: tabulate~=0.10.0
53
- Requires-Dist: taskcluster~=116.0
53
+ Requires-Dist: taskcluster~=117.2
54
54
  Requires-Dist: tenacity~=9.1.4
55
55
  Requires-Dist: tqdm<4.71.0,>=4.67.3
56
56
  Requires-Dist: unidiff<1.1.0,>=0.7.5
@@ -63,6 +63,6 @@ Requires-Dist: spacy==3.8.18; extra == 'nlp'
63
63
  Provides-Extra: nn
64
64
  Provides-Extra: perf-regression-predictor
65
65
  Requires-Dist: torch==2.15.0; extra == 'perf-regression-predictor'
66
- Requires-Dist: transformers==5.22.2; extra == 'perf-regression-predictor'
66
+ Requires-Dist: transformers==5.24.0; extra == 'perf-regression-predictor'
67
67
  Provides-Extra: perf-simulation
68
68
  Requires-Dist: optuna>=5.0.0; extra == 'perf-simulation'
bugbug-0.0.663/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.663
@@ -403,6 +403,9 @@ class Model:
403
403
  """Subclasses can return a weight for each training sample, passed to the estimator."""
404
404
  return None
405
405
 
406
+ def post_training(self) -> None:
407
+ """Subclasses can update the final model once it's trained (e.g. on the entire dataset), before it's saved."""
408
+
406
409
  def fit_classifier(self, X, y):
407
410
  sample_weight = self.get_sample_weights(X, y)
408
411
  if sample_weight is None:
@@ -705,6 +708,8 @@ class Model:
705
708
 
706
709
  self.fit_classifier(X_train, self.le.transform(y_train))
707
710
 
711
+ self.post_training()
712
+
708
713
  model_directory = self.__class__.__name__.lower()
709
714
  makedirs(model_directory, exist_ok=True)
710
715
 
@@ -34,7 +34,6 @@ from bugbug import (
34
34
  utils,
35
35
  )
36
36
  from bugbug.model import Model
37
- from bugbug.model_calibration import fit_isotonic_breakpoints
38
37
 
39
38
  logging.basicConfig(level=logging.INFO)
40
39
  logger = logging.getLogger(__name__)
@@ -414,9 +413,20 @@ TUNED_XGBOOST_PARAMS = {"n_estimators": 400, "learning_rate": 0.03, "max_depth":
414
413
  # "very_low" level, used by the taskgraph on expanded pushes, selects three times as many as "low".
415
414
  # Groups at the "very_high" level run on a config of each OS family (see the HTTP service's config
416
415
  # selection): in offline evaluations, failing pushes caught at the same cost were ~2.3 points
417
- # higher with one such group per push, and about as high with 0.5 to 3.
416
+ # higher with one such group per push, and about as high with 0.5 to 3. Tasks at the "very_high" level
417
+ # (one per push, as for groups) caught, with the tasks always selected, ~78% of the failing pushes in
418
+ # offline evaluations, vs ~88% at the "high" level, with a fifth of the tasks.
419
+ # The counts don't include the runnables which the HTTP service always selects: the manifests including
420
+ # the modified tests and the tasks running the tests close to the modified files (see
421
+ # test_scheduling.find_manifests_for_paths and find_tasks_for_paths).
418
422
  CONFIDENCE_LEVEL_TARGETS = {
419
- "label": {"very_low": 78.0, "low": 26.0, "medium": 15.0, "high": 5.5},
423
+ "label": {
424
+ "very_low": 78.0,
425
+ "low": 26.0,
426
+ "medium": 15.0,
427
+ "high": 5.5,
428
+ "very_high": 1.0,
429
+ },
420
430
  "group": {
421
431
  "very_low": 309.0,
422
432
  "low": 103.0,
@@ -433,23 +443,36 @@ CONFIDENCE_LEVEL_TARGETS = {
433
443
  CONFIDENCE_LEVEL_MIN_CAUGHT = {"label": 0.6, "group": 0.85}
434
444
 
435
445
 
436
- def fit_calibration(
437
- totals: Sequence[int], failures: Sequence[int]
438
- ) -> tuple[list[float], list[float]] | None:
439
- """Isotonic regression of the failure rate on the confidence, from counts per confidence (0, 0.01, ..., 1).
446
+ # Numbers of runnables per push delimiting the bands of confidences in which the probability of failing is
447
+ # considered constant (see fit_band_rates): in offline evaluations, the config selection catches as many
448
+ # failures as with an isotonic regression of the failure rate on the confidence, and much fewer with the
449
+ # CONFIDENCE_LEVEL_TARGETS counts only.
450
+ CALIBRATION_COUNTS = (0.25, 0.5, 1.0, 2.0, 5.0, 11.0, 20.0, 36.0, 103.0, 309.0)
451
+
452
+ # Minimum number of recent pushes on which to compute the confidence thresholds of the trained model (see
453
+ # TestSelectModel.post_training).
454
+ MIN_RECENT_PUSHES = 100
455
+
456
+
457
+ def fit_band_rates(
458
+ thresholds: Sequence[float], totals: Sequence[float], failures: Sequence[float]
459
+ ) -> list[float]:
460
+ """The failure rate in each band of confidences, from counts per confidence (0, 0.01, ..., 1).
440
461
 
441
- The confidences are not probabilities (the models are trained with class-balancing weights), but they rank
442
- runnables well: the regression maps them to probabilities without changing their order. Returns the
443
- regression's breakpoints, to interpolate, or None if there are no failures.
462
+ The bands are delimited by the (decreasing) `thresholds`: band i holds the confidences from
463
+ thresholds[i] up to the previous threshold, and the last band the confidences below the last
464
+ threshold. An empty band gets the rate of the band above it (or 0, for the first band).
444
465
  """
445
- points = [(i / 100, n, f) for i, (n, f) in enumerate(zip(totals, failures)) if n]
446
- if not any(f for _, _, f in points):
447
- return None
448
- return fit_isotonic_breakpoints(
449
- [x for x, _, _ in points],
450
- [f / n for _, n, f in points],
451
- [n for _, n, _ in points],
452
- )
466
+ rates: list[float] = []
467
+ upper = len(totals)
468
+ for lower in [round(t * 100) for t in thresholds] + [0]:
469
+ total = sum(totals[lower:upper])
470
+ if total:
471
+ rates.append(sum(failures[lower:upper]) / total)
472
+ else:
473
+ rates.append(rates[-1] if rates else 0.0)
474
+ upper = min(upper, lower)
475
+ return rates
453
476
 
454
477
 
455
478
  def compute_confidence_thresholds(
@@ -466,10 +489,75 @@ def compute_confidence_thresholds(
466
489
  thresholds = {}
467
490
  for level, target in targets.items():
468
491
  k = min(len(confidences), max(1, round(target * len(push_confidences))))
469
- thresholds[level] = math.floor(confidences[k - 1] * 100) / 100
492
+ # Rounded before flooring, as confidences which are already rounded down can be slightly
493
+ # lower than their number of hundredths when multiplied (e.g. 0.57 * 100 is 56.99...).
494
+ thresholds[level] = math.floor(round(confidences[k - 1] * 100, 6)) / 100
470
495
  return thresholds
471
496
 
472
497
 
498
+ def merge_tied_bands(
499
+ thresholds: Sequence[float], rates: Sequence[float]
500
+ ) -> tuple[list[float], list[float]]:
501
+ """Merge the calibration bands with the same threshold (see fit_band_rates).
502
+
503
+ `thresholds` are the thresholds of the CALIBRATION_COUNTS, and `rates` the failure rates of
504
+ their bands. When thresholds are computed on another model than the rates, bands which were
505
+ distinct can get the same threshold, and only the first one would be used: their rates are
506
+ averaged instead, weighted by the number of runnables per push in each band.
507
+ """
508
+ counts = [0.0, *CALIBRATION_COUNTS]
509
+ merged_thresholds: list[float] = []
510
+ merged_rates: list[float] = []
511
+ merged_weights: list[float] = []
512
+ for i, (threshold, rate) in enumerate(zip(thresholds, rates)):
513
+ weight = counts[i + 1] - counts[i]
514
+ if merged_thresholds and merged_thresholds[-1] == threshold:
515
+ merged_rates[-1] = (
516
+ merged_rates[-1] * merged_weights[-1] + rate * weight
517
+ ) / (merged_weights[-1] + weight)
518
+ merged_weights[-1] += weight
519
+ else:
520
+ merged_thresholds.append(threshold)
521
+ merged_rates.append(rate)
522
+ merged_weights.append(weight)
523
+ return merged_thresholds, merged_rates + [rates[-1]]
524
+
525
+
526
+ def top_fit_confidences(
527
+ confidences: Mapping[str, float], excluded: Collection[str]
528
+ ) -> list[float]:
529
+ """The highest confidences of a push's runnables, except `excluded`, to compute thresholds.
530
+
531
+ Enough are kept for all the counts of CONFIDENCE_LEVEL_TARGETS and CALIBRATION_COUNTS.
532
+ """
533
+ n = int(
534
+ 10
535
+ * max(
536
+ *CALIBRATION_COUNTS,
537
+ *(
538
+ t
539
+ for targets in CONFIDENCE_LEVEL_TARGETS.values()
540
+ for t in targets.values()
541
+ ),
542
+ )
543
+ )
544
+ return heapq.nlargest(
545
+ n, (c for name, c in confidences.items() if name not in excluded)
546
+ )
547
+
548
+
549
+ def get_recent_pushes(after_rev: str) -> list[list[str]]:
550
+ """The changesets of the autoland pushes after the one including `after_rev`, oldest first."""
551
+ r = utils.get_session("hgmo").get(
552
+ "https://hg.mozilla.org/integration/autoland/json-pushes",
553
+ params={"version": "2", "fromchange": after_rev},
554
+ headers={"User-Agent": utils.get_user_agent()},
555
+ )
556
+ r.raise_for_status()
557
+ pushes = r.json()["pushes"]
558
+ return [pushes[push_id]["changesets"] for push_id in sorted(pushes, key=int)]
559
+
560
+
473
561
  def share_caught(pushes: Iterable[dict[str, Any]], threshold: float) -> float | None:
474
562
  """Share of the pushes with failures where a failure is selected at the threshold."""
475
563
  caught = [
@@ -573,12 +661,16 @@ class TestSelectModel(Model):
573
661
  test_scheduling.TOUCHED_TOGETHER_DB,
574
662
  )
575
663
 
576
- # Confidence thresholds for the levels in CONFIDENCE_LEVEL_TARGETS, computed on the test
577
- # pushes during the evaluation.
664
+ # Confidence thresholds for the levels in CONFIDENCE_LEVEL_TARGETS, computed on the trained
665
+ # model's confidences on recent pushes (see post_training).
578
666
  self.confidence_thresholds: dict[str, float] | None = None
579
- # Mapping from confidences to probabilities of failing (see fit_calibration), computed on the
580
- # test pushes during the evaluation.
667
+ # Probabilities of failing by band of confidences: the thresholds at which the trained model
668
+ # selects the CALIBRATION_COUNTS runnables per push (computed as confidence_thresholds), and
669
+ # the failure rate of each band during the evaluation (see fit_band_rates).
581
670
  self.calibration: tuple[list[float], list[float]] | None = None
671
+ # The gtest folders of the Firefox tree, to find the tasks which the HTTP service always selects
672
+ # (see forced_runnables).
673
+ self.gtest_folders: tuple[str, ...] = ()
582
674
 
583
675
  self.cross_validation_enabled = False
584
676
  self.calculate_importance = False
@@ -835,16 +927,114 @@ class TestSelectModel(Model):
835
927
  ) -> dict[str, float]:
836
928
  """The probabilities of failing of runnables with the given confidences (unchanged if not calibrated).
837
929
 
838
- The order of the runnables doesn't change, so selections by confidence are the same.
930
+ Each runnable gets the failure rate of its band of confidences (see calibration).
839
931
  """
840
932
  calibration = getattr(self, "calibration", None)
841
933
  if calibration is None:
842
934
  return dict(confidences)
843
- names = list(confidences)
844
- probabilities = np.interp(
845
- [confidences[name] for name in names], calibration[0], calibration[1]
935
+ thresholds, rates = calibration
936
+ return {
937
+ name: next(
938
+ (rate for t, rate in zip(thresholds, rates) if confidence >= t),
939
+ rates[-1],
940
+ )
941
+ for name, confidence in confidences.items()
942
+ }
943
+
944
+ def forced_runnables(
945
+ self, commits: Sequence[repository.CommitDict], runnables: Collection[str]
946
+ ) -> set[str]:
947
+ """The runnables among `runnables` which the HTTP service selects whatever their confidence.
948
+
949
+ The manifests including the modified tests, and the tasks running the tests close to the
950
+ modified files (approximated, as the repository isn't available when training, see
951
+ test_scheduling.approximate_manifests_for_paths and approximate_tasks_for_paths).
952
+ """
953
+ paths = {path for commit in commits for path in commit["files"]}
954
+ if self.granularity == "group":
955
+ return test_scheduling.approximate_manifests_for_paths(paths, runnables)
956
+ if self.granularity == "label":
957
+ return test_scheduling.approximate_tasks_for_paths(
958
+ paths, runnables, self.gtest_folders
959
+ )
960
+ return set()
961
+
962
+ def post_training(self) -> None:
963
+ """Compute the confidence thresholds and calibration bands on the trained model's confidences.
964
+
965
+ After the evaluation, the model is retrained on all the pushes, which changes the scale of its
966
+ confidences, so the thresholds computed during the evaluation don't fit it. They are computed
967
+ again on the autoland pushes after the ones of the history (which the model wasn't trained on),
968
+ scored as the HTTP service does. The failure rates of the bands are the evaluation's.
969
+ """
970
+ targets = CONFIDENCE_LEVEL_TARGETS.get(self.granularity)
971
+ if not targets or self.confidence_thresholds is None:
972
+ return
973
+
974
+ ((last_revs, _),) = collections.deque(
975
+ test_scheduling.get_test_scheduling_history(self.granularity), maxlen=1
846
976
  )
847
- return {name: float(p) for name, p in zip(names, probabilities)}
977
+ pushes = get_recent_pushes(last_revs[0])
978
+ revs = {rev for push in pushes for rev in push}
979
+ commits = {
980
+ commit["node"]: commit
981
+ for commit in repository.get_commits(
982
+ include_no_bug=True, include_backouts=True, include_ignored=True
983
+ )
984
+ if commit["node"] in revs
985
+ }
986
+
987
+ fit_confidences = []
988
+ for push in tqdm(pushes):
989
+ # The commits which aren't in the commits DB yet (e.g. not merged to mozilla-central).
990
+ if not all(rev in commits for rev in push):
991
+ continue
992
+ # The HTTP service doesn't score backouts and ignored commits.
993
+ push_commits = [
994
+ commits[rev]
995
+ for rev in push
996
+ if not commits[rev]["ignored"] and not commits[rev]["backsout"]
997
+ ]
998
+ if not push_commits:
999
+ continue
1000
+ confidences = self.get_confidences(push_commits)
1001
+ fit_confidences.append(
1002
+ top_fit_confidences(
1003
+ confidences, self.forced_runnables(push_commits, confidences.keys())
1004
+ )
1005
+ )
1006
+
1007
+ if len(fit_confidences) < MIN_RECENT_PUSHES:
1008
+ logger.warning(
1009
+ "Only %d of %d recent pushes could be scored, keeping the confidence thresholds of the evaluation.",
1010
+ len(fit_confidences),
1011
+ len(pushes),
1012
+ )
1013
+ return
1014
+
1015
+ logger.info(
1016
+ "Confidence thresholds of the evaluation: %s", self.confidence_thresholds
1017
+ )
1018
+ self.confidence_thresholds = compute_confidence_thresholds(
1019
+ fit_confidences, targets
1020
+ )
1021
+ logger.info(
1022
+ "Confidence thresholds (on %d recent pushes): %s",
1023
+ len(fit_confidences),
1024
+ self.confidence_thresholds,
1025
+ )
1026
+ if self.calibration is not None:
1027
+ band_thresholds = list(
1028
+ compute_confidence_thresholds(
1029
+ fit_confidences, {str(c): c for c in CALIBRATION_COUNTS}
1030
+ ).values()
1031
+ )
1032
+ logger.info(
1033
+ "Calibration band thresholds: %s (evaluation: %s)",
1034
+ band_thresholds,
1035
+ self.calibration[0],
1036
+ )
1037
+ self.calibration = merge_tied_bands(band_thresholds, self.calibration[1])
848
1038
 
849
1039
  def get_confidences(
850
1040
  self,
@@ -957,9 +1147,9 @@ class TestSelectModel(Model):
957
1147
 
958
1148
  targets = CONFIDENCE_LEVEL_TARGETS.get(self.granularity)
959
1149
  max_target = max(targets.values()) if targets else 0
960
- # The highest confidences of the runnables on each test push, to compute the confidence
961
- # thresholds.
962
- top_confidences: list[list[tuple[str, float]]] = []
1150
+ # The highest confidences of the runnables on each test push which the HTTP service doesn't
1151
+ # always select, to compute the confidence thresholds.
1152
+ fit_confidences: list[list[float]] = []
963
1153
  # Test pushes too old for their past failures to be known (see below).
964
1154
  clamped_pushes = []
965
1155
  # Runnables and failing runnables per confidence (0, 0.01, ..., 1), for the calibration.
@@ -1001,8 +1191,11 @@ class TestSelectModel(Model):
1001
1191
  continue
1002
1192
 
1003
1193
  confidences = self.get_confidences(commits, push_num)
1194
+ forced = self.forced_runnables(commits, confidences.keys())
1004
1195
  failing = set(push["failures"])
1005
1196
  for name, confidence in confidences.items():
1197
+ if name in forced:
1198
+ continue
1006
1199
  calibration_totals[round(confidence * 100)] += 1
1007
1200
  calibration_failures[round(confidence * 100)] += name in failing
1008
1201
  push["all_possibly_selected"] = {
@@ -1015,7 +1208,7 @@ class TestSelectModel(Model):
1015
1208
  push["top_confidences"] = heapq.nlargest(
1016
1209
  int(10 * max_target), confidences.items(), key=lambda x: x[1]
1017
1210
  )
1018
- top_confidences.append(push["top_confidences"])
1211
+ fit_confidences.append(top_fit_confidences(confidences, forced))
1019
1212
 
1020
1213
  for rev in clamped_pushes:
1021
1214
  del test_pushes[rev]
@@ -1026,33 +1219,35 @@ class TestSelectModel(Model):
1026
1219
  sum(1 for push in test_pushes.values() if len(push["failures"]) > 0),
1027
1220
  )
1028
1221
 
1029
- self.calibration = fit_calibration(calibration_totals, calibration_failures)
1030
- if self.calibration is not None:
1031
- logger.info(
1032
- "Calibration (confidence -> observed failure rate -> probability):"
1033
- )
1034
- for confidence in (0.1, 0.3, 0.5, 0.7, 0.8, 0.9, 0.95, 0.99):
1035
- b = round(confidence * 100)
1036
- logger.info(
1037
- " %.2f -> %s -> %.4f",
1038
- confidence,
1039
- f"{calibration_failures[b] / calibration_totals[b]:.4f}"
1040
- if calibration_totals[b]
1041
- else "-",
1042
- np.interp(confidence, *self.calibration),
1043
- )
1044
-
1045
1222
  confidence_thresholds = [0.5, 0.7, 0.8, 0.85, 0.9, 0.95]
1046
- if targets and top_confidences:
1223
+ if targets and fit_confidences:
1224
+ # Until post_training computes them on the trained model's confidences.
1047
1225
  self.confidence_thresholds = compute_confidence_thresholds(
1048
- [[confidence for _, confidence in top] for top in top_confidences],
1049
- targets,
1226
+ fit_confidences, targets
1050
1227
  )
1051
1228
  logger.info(
1052
1229
  "Confidence thresholds (on %d test pushes): %s",
1053
- len(top_confidences),
1230
+ len(fit_confidences),
1054
1231
  self.confidence_thresholds,
1055
1232
  )
1233
+ band_thresholds = list(
1234
+ compute_confidence_thresholds(
1235
+ fit_confidences, {str(c): c for c in CALIBRATION_COUNTS}
1236
+ ).values()
1237
+ )
1238
+ rates = fit_band_rates(
1239
+ band_thresholds, calibration_totals, calibration_failures
1240
+ )
1241
+ if any(rates):
1242
+ self.calibration = (band_thresholds, rates)
1243
+ logger.info(
1244
+ "Calibration (runnables per push: confidence threshold -> failure rate): %s",
1245
+ ", ".join(
1246
+ f"{c:g}: {t:.2f} -> {r:.4f}"
1247
+ for c, t, r in zip(CALIBRATION_COUNTS, band_thresholds, rates)
1248
+ )
1249
+ + f", below: {rates[-1]:.4f}",
1250
+ )
1056
1251
  confidence_thresholds = sorted(
1057
1252
  set(confidence_thresholds) | set(self.confidence_thresholds.values())
1058
1253
  )
@@ -1271,12 +1466,15 @@ class TestLabelSelectModel(TestSelectModel):
1271
1466
  # The directories with the tests of some suites come from a Firefox tree (only its moz.build
1272
1467
  # files are needed), and are stored with the model.
1273
1468
  suite_test_dirs = None
1469
+ gtest_folders: tuple[str, ...] = ()
1274
1470
  if repo_dir:
1275
1471
  suite_test_dirs = test_scheduling.get_suite_test_dirs(repo_dir)
1276
1472
  logger.info(
1277
1473
  "Test directories of the suites: %s",
1278
1474
  {suite: len(dirs) for suite, dirs in suite_test_dirs.items()},
1279
1475
  )
1476
+ gtest_folders = test_scheduling.get_gtest_folders(repo_dir)
1477
+ logger.info("%d gtest folders", len(gtest_folders))
1280
1478
  else:
1281
1479
  logger.warning(
1282
1480
  "No Firefox repository (repo_dir): the suite files features only include the "
@@ -1297,6 +1495,7 @@ class TestLabelSelectModel(TestSelectModel):
1297
1495
  # Android builds) better than skipping them (the previous failures_skip=60).
1298
1496
  positive_weight_k=5,
1299
1497
  )
1498
+ self.gtest_folders = gtest_folders
1300
1499
 
1301
1500
 
1302
1501
  class TestGroupSelectModel(TestSelectModel):
@@ -1962,6 +1962,16 @@ def clone(
1962
1962
  logger.info("%s cloned", repo_dir)
1963
1963
 
1964
1964
 
1965
+ def has_revision(repo_dir: str, revision: str) -> bool:
1966
+ """Whether a revision is in a local repository."""
1967
+ with hglib.open(repo_dir) as hg:
1968
+ try:
1969
+ hg.log(revrange=revision.encode("ascii"))
1970
+ except hglib.error.CommandError:
1971
+ return False
1972
+ return True
1973
+
1974
+
1965
1975
  def pull(repo_dir: str, branch: str, revision: str, update: bool = False) -> None:
1966
1976
  """Pull a revision from a branch of a remote repository into a local repository."""
1967
1977
 
@@ -1825,6 +1825,69 @@ def find_manifests_for_paths(repo_dir: str, paths: list[str], rev: str) -> set[s
1825
1825
  return manifests
1826
1826
 
1827
1827
 
1828
+ def approximate_manifests_for_paths(
1829
+ paths: Iterable[str], groups: Collection[str]
1830
+ ) -> set[str]:
1831
+ """The groups among `groups` that find_manifests_for_paths likely runs for modified paths.
1832
+
1833
+ Without the repository, the files included by each manifest aren't known: a manifest is assumed
1834
+ to include the files in its directory, and a web-platform test directory to be the closest one
1835
+ among `groups` that contains the modified file. On autoland pushes, ~85% of the groups returned
1836
+ are also run by find_manifests_for_paths, and they include ~95% of its groups.
1837
+ """
1838
+ manifests = [
1839
+ (group, os.path.dirname(group))
1840
+ for group in groups
1841
+ if not group.startswith(WPT_ROOTS)
1842
+ ]
1843
+ wpt_groups = {group for group in groups if group.startswith(WPT_ROOTS)}
1844
+
1845
+ result: set[str] = set()
1846
+ for path in paths:
1847
+ parent = os.path.dirname(path)
1848
+
1849
+ result.update(
1850
+ group
1851
+ for group, group_dir in manifests
1852
+ if path == group or (group_dir and path.startswith(f"{group_dir}/"))
1853
+ )
1854
+
1855
+ # The manifests in test subfolders close to a modified file, as find_manifests_for_paths.
1856
+ if parent:
1857
+ siblings = {
1858
+ group
1859
+ for group, group_dir in manifests
1860
+ if group_dir.startswith(f"{parent}/")
1861
+ and repository.is_test(f"/{group_dir}/")
1862
+ }
1863
+ if len(siblings) <= MAX_SIBLING_MANIFESTS:
1864
+ result |= siblings
1865
+
1866
+ if path.endswith(("/META.yml", "/README.md")):
1867
+ continue
1868
+ for root in WPT_ROOTS:
1869
+ prefix = next(
1870
+ (
1871
+ f"{root}/{sub}/"
1872
+ for sub in ("tests", "meta")
1873
+ if path.startswith(f"{root}/{sub}/")
1874
+ ),
1875
+ None,
1876
+ )
1877
+ if prefix is None:
1878
+ continue
1879
+
1880
+ # The closest directory containing the file.
1881
+ cur_dir = os.path.dirname(path[len(prefix) :])
1882
+ while cur_dir and f"{root}/tests/{cur_dir}" not in wpt_groups:
1883
+ cur_dir = os.path.dirname(cur_dir)
1884
+ if cur_dir:
1885
+ result.add(f"{root}/tests/{cur_dir}")
1886
+ break
1887
+
1888
+ return result
1889
+
1890
+
1828
1891
  _GTEST_RE = re.compile(rb"^[ \t]*(?:TEST|TEST_F)\(", re.MULTILINE)
1829
1892
  _GTEST_FOLDERS = ("gtest", "gtests", "googletest")
1830
1893
  _CPPUNIT_INFRA_FILES = {
@@ -1924,3 +1987,51 @@ def find_tasks_for_paths(
1924
1987
  selected_tasks.append(task)
1925
1988
 
1926
1989
  return selected_tasks
1990
+
1991
+
1992
+ def get_gtest_folders(repo_dir: str) -> tuple[str, ...]:
1993
+ """The gtest folders of a Firefox tree (see find_tasks_for_paths), from its moz.build files.
1994
+
1995
+ Only the moz.build files are needed (e.g. a sparse checkout), as gtest folders contain one.
1996
+ """
1997
+ folders = set()
1998
+ for root, subdirs, files in os.walk(repo_dir):
1999
+ subdirs[:] = [d for d in subdirs if not d.startswith((".", "obj-"))]
2000
+ rel_root = os.path.relpath(root, repo_dir).replace(os.sep, "/")
2001
+ if "moz.build" in files and any(
2002
+ part in _GTEST_FOLDERS for part in rel_root.split("/")
2003
+ ):
2004
+ folders.add(rel_root)
2005
+ return tuple(sorted(folders))
2006
+
2007
+
2008
+ def approximate_tasks_for_paths(
2009
+ paths: Iterable[str], tasks: Iterable[str], gtest_folders: Collection[str]
2010
+ ) -> set[str]:
2011
+ """The tasks among `tasks` that find_tasks_for_paths likely runs for modified paths.
2012
+
2013
+ Without the repository, the gtest folders close to the modified files are among `gtest_folders`
2014
+ (see get_gtest_folders), and the C/C++ files containing gtests and the cppunit tests aren't known.
2015
+ On autoland pushes, the tasks returned are run by find_tasks_for_paths, and include ~98% of its
2016
+ tasks.
2017
+ """
2018
+ paths = list(paths)
2019
+ select_rusttests = any(repository.get_type(path) == "Rust" for path in paths)
2020
+ select_gtest = any(
2021
+ f"/{folder}/" in path for path in paths for folder in _GTEST_FOLDERS
2022
+ ) or any(
2023
+ any(part in _GTEST_FOLDERS for part in folder[len(parent) + 1 :].split("/"))
2024
+ for parent in {os.path.dirname(path) for path in paths}
2025
+ if parent
2026
+ for folder in gtest_folders
2027
+ if folder.startswith(f"{parent}/")
2028
+ )
2029
+ select_cppunit = any(path in _CPPUNIT_INFRA_FILES for path in paths)
2030
+
2031
+ return {
2032
+ task
2033
+ for task in tasks
2034
+ if (select_gtest and "gtest" in task)
2035
+ or (select_cppunit and "cppunit" in task)
2036
+ or (select_rusttests and "rusttests" in task)
2037
+ }