ImproveRunner is responsible for populating the database with any consumable data. It does so in its ``run`` method by invoking the given improver and parsing the returned Inferences into proper database fields
| 33 | |
| 34 | |
| 35 | class ImproveRunner: |
| 36 | """ |
| 37 | ImproveRunner is responsible for populating the database with any |
| 38 | consumable data. It does so in its ``run`` method by invoking the given |
| 39 | improver and parsing the returned Inferences into proper database fields |
| 40 | """ |
| 41 | |
| 42 | def __init__(self, improver_class): |
| 43 | self.improver_class = improver_class |
| 44 | |
| 45 | def run(self) -> None: |
| 46 | improver = self.improver_class() |
| 47 | logger.info(f"Running improver: {improver.qualified_name}") |
| 48 | for advisory in improver.interesting_advisories: |
| 49 | logger.info(f"Processing advisory: {advisory!r}") |
| 50 | try: |
| 51 | inferences = improver.get_inferences(advisory_data=advisory.to_advisory_data()) |
| 52 | process_inferences( |
| 53 | inferences=inferences, |
| 54 | advisory=advisory, |
| 55 | improver_name=improver.qualified_name, |
| 56 | ) |
| 57 | except Exception as e: |
| 58 | logger.info(f"Failed to process advisory: {advisory!r} with error {e!r}") |
| 59 | logger.info("Finished improving using %s.", self.improver_class.qualified_name) |
| 60 | |
| 61 | |
| 62 | @transaction.atomic |
no outgoing calls