diff --git a/india_forecast_app/models/pvnet/model.py b/india_forecast_app/models/pvnet/model.py index e64e8ac..6e4c084 100644 --- a/india_forecast_app/models/pvnet/model.py +++ b/india_forecast_app/models/pvnet/model.py @@ -229,10 +229,8 @@ def _prepare_data_sources(self): # Remove local cached zarr if already exists for nwp_source_file_path, nwp_path in zip(nwp_source_file_paths, nwp_paths, strict=False): # Process/cache remote zarr locally - shutil.rmtree(nwp_path, ignore_errors=True) process_and_cache_nwp(nwp_source_file_path, nwp_path) if use_satellite: - shutil.rmtree(satellite_path, ignore_errors=True) download_satellite_data(satellite_source_file_path) if self.asset_type == "wind": diff --git a/india_forecast_app/models/pvnet/utils.py b/india_forecast_app/models/pvnet/utils.py index 378e487..980d3a5 100644 --- a/india_forecast_app/models/pvnet/utils.py +++ b/india_forecast_app/models/pvnet/utils.py @@ -93,7 +93,12 @@ def populate_data_config_sources(input_path, output_path): def process_and_cache_nwp(source_nwp_path: str, dest_nwp_path: str): """Reads zarr file, renames t variable to t2m and saves zarr to new destination""" - log.info(f"Processing and caching NWP data for {source_nwp_path}") + log.info(f"Processing and caching NWP data for {source_nwp_path}, " + f"and saving to {dest_nwp_path}") + + if os.path.exists(dest_nwp_path): + log.info(f"File already exists at {dest_nwp_path}") + return # Load dataset from source ds = xr.open_zarr(source_nwp_path)