diff --git a/api/app/weather_models/precip_rdps_model.py b/api/app/weather_models/precip_rdps_model.py index 714030909..d5fcd20f1 100644 --- a/api/app/weather_models/precip_rdps_model.py +++ b/api/app/weather_models/precip_rdps_model.py @@ -32,13 +32,14 @@ async def compute_and_store_precip_rasters(current_time: datetime): Given a UTC datetime, trigger 24 hours worth of accumulated precip difference rasters and store them. """ - for hour in range(0, 24): - timestamp = current_time + timedelta(hours=hour) - (precip_diff_raster, geotransform, projection) = await generate_24_hour_accumulating_precip_raster(timestamp) - key = f"weather_models/{ModelEnum.RDPS.lower()}/{current_time.date().isoformat()}/" + compose_computed_precip_rdps_key( - current_time, current_time.hour, hour, SourcePrefix.COMPUTED - ) - async with get_client() as (client, bucket): + async with get_client() as (client, bucket): + for hour in range(0, 24): + timestamp = current_time + timedelta(hours=hour) + (precip_diff_raster, geotransform, projection) = await generate_24_hour_accumulating_precip_raster(timestamp) + key = f"weather_models/{ModelEnum.RDPS.lower()}/{current_time.date().isoformat()}/" + compose_computed_precip_rdps_key( + current_time, current_time.hour, hour, SourcePrefix.COMPUTED + ) + res = await client.list_objects_v2(Bucket=bucket, Prefix=key, MaxKeys=1) if "Contents" in res: logger.info("File already exists for key: %s, skipping", key)