in bugbug/models/component.py [0:0]
def get_labels(self):
product_components = {}
for bug_data in bugzilla.get_bugs():
if dateutil.parser.parse(bug_data["creation_time"]) < datetime.now(
timezone.utc
) - relativedelta(years=2):
continue
product_components[bug_data["id"]] = (
bug_data["product"],
bug_data["component"],
)
self.meaningful_product_components = self.get_meaningful_product_components(
(
(product, component)
for product, component in product_components.values()
if self.is_meaningful(product, component)
)
)
classes = {}
for bug_id, (product, component) in product_components.items():
component = self.filter_component(product, component)
if component:
classes[bug_id] = component
component_counts = Counter(classes.values()).most_common()
top_components = set(component for component, count in component_counts)
logger.info("%d components", len(top_components))
for component, count in component_counts:
logger.info("%s: %d", component, count)
# Assert there is at least one bug for each conflated component.
for conflated_component in self.CONFLATED_COMPONENTS:
assert any(
conflated_component == component
for component, count in component_counts
), f"There should be at least one bug matching {conflated_component}*"
# Assert there is at least one bug for each component the conflated components are mapped to.
for conflated_component_mapping in self.CONFLATED_COMPONENTS_MAPPING.values():
assert any(
conflated_component_mapping == f"{product}::{component}"
for product, component in product_components.values()
), f"There should be at least one bug in {conflated_component_mapping}"
# Assert all conflated components are either in conflated_components_mapping or exist as components.
for conflated_component in self.CONFLATED_COMPONENTS:
assert conflated_component in self.CONFLATED_COMPONENTS_MAPPING or any(
conflated_component == f"{product}::{component}"
for product, component in product_components.values()
), f"It should be possible to map {conflated_component}"
classes = {
bug_id: component
for bug_id, component in classes.items()
if component in top_components
}
return classes, set(classes.values())