From d0847681c182d9c1568e7ef966c62d0ed0c751b0 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Tue, 10 Feb 2026 09:42:29 +0000 Subject: [PATCH] tidy up logs --- backend/condition/handler/handler.py | 12 ++++++------ backend/condition/parsing/peabody_parser.py | 14 ++++++++------ backend/condition/processor.py | 3 +++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/backend/condition/handler/handler.py b/backend/condition/handler/handler.py index 08d67aa8..2f3616a4 100644 --- a/backend/condition/handler/handler.py +++ b/backend/condition/handler/handler.py @@ -17,27 +17,27 @@ def handler(event: Mapping[str, Any], context: Any) -> None: for record in event.get("Records", []): try: body_dict = json.loads(record["body"]) - logger.info("Validating request body") + logger.debug("Validating request body") payload = ConditionTriggerRequest.model_validate(body_dict) - logger.info("Successfully validated request body") + logger.debug("Successfully validated request body") if payload.uprn_lookup_file_bucket and payload.uprn_lookup_file_key: - logger.info("Getting UPRN lookup file from s3") + logger.debug("Getting UPRN lookup file from s3") uprn_lookup = UprnLookupS3( bucket=payload.uprn_lookup_file_bucket, key=payload.uprn_lookup_file_key, ) # TODO: replace with postgres implementation - logger.info("Successfully got UPRN lookup file from s3") + logger.debug("Successfully got UPRN lookup file from s3") else: uprn_lookup = None - logger.info("Getting conditions data from s3") + logger.debug("Getting conditions data from s3") file_bytes: BytesIO = read_io_from_s3( bucket_name=payload.trigger_file_bucket, file_key=payload.trigger_file_key, ) - logger.info( + logger.debug( "Successfully got conditions data from s3. Moving on to process file..." ) diff --git a/backend/condition/parsing/peabody_parser.py b/backend/condition/parsing/peabody_parser.py index 921f24d4..4620ba82 100644 --- a/backend/condition/parsing/peabody_parser.py +++ b/backend/condition/parsing/peabody_parser.py @@ -24,16 +24,16 @@ class PeabodyParser(Parser): file_stream: BinaryIO, ) -> Any: file_stream.seek(0) - logger.info("[PeabodyParser] Loading workbook...") + logger.debug("[PeabodyParser] Loading workbook...") wb: Workbook = load_workbook(file_stream, read_only=True, data_only=True) - logger.info("[PeabodyParser] Successfully loaded workbook. Parsing assets...") + logger.debug("[PeabodyParser] Successfully loaded workbook. Parsing assets...") assets = PeabodyParser._parse_assets(wb) - logger.info( + logger.debug( "[PeabodyParser] Successfully parsed assets. Parsing UPRN lookup..." ) location_ref_to_uprn_map = self.uprn_lookup.get_property_ref_to_uprn_lookup() - logger.info("[PeabodyParser] Successfully parsed UPRN lookup") + logger.debug("[PeabodyParser] Successfully parsed UPRN lookup") return PeabodyParser._group_assets_into_properties( assets=assets, location_ref_to_uprn_map=location_ref_to_uprn_map, @@ -55,7 +55,7 @@ class PeabodyParser(Parser): ) if not asset.is_block_level: # Block-level condition surveys are out of scope for now - # until we have a wider think on how to handle block + # until we have a wider think on how to handle blocks assets.append(asset) # TODO: handle block-level assets except Exception as e: @@ -80,13 +80,14 @@ class PeabodyParser(Parser): assets_by_location_reference[asset.lo_reference].append(asset) properties: List[PeabodyProperty] = [] + failed_mappings_count = 0 for location_ref, grouped_assets in assets_by_location_reference.items(): uprn = location_ref_to_uprn_map.get(location_ref) if uprn is None: - logger.warning(f"No UPRN found for Location Reference: {location_ref}") + failed_mappings_count += 1 continue properties.append( @@ -96,6 +97,7 @@ class PeabodyParser(Parser): ) ) + logger.warning(f"No UPRN found for {failed_mappings_count} Location References") return properties @staticmethod diff --git a/backend/condition/processor.py b/backend/condition/processor.py index b7c7d2b6..ad5b4232 100644 --- a/backend/condition/processor.py +++ b/backend/condition/processor.py @@ -19,10 +19,13 @@ def process_file( uprn_lookup: Optional[UprnLookup], ) -> None: # Instantiation + logger.debug(f"[processor] Instantiating classes...") parser: Parser = select_parser(file_type, uprn_lookup) mapper: Mapper = select_mapper(file_type) persistence = ConditionPostgres() + logger.debug(f"[processor] Finished instantiating classes. Calling Parser...") + # Orchestration raw_properties: List[Any] = parser.parse(file_stream)