PVNet 4.0.9__tar.gz → 4.0.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {pvnet-4.0.9 → pvnet-4.0.11}/PKG-INFO +1 -1
  2. {pvnet-4.0.9 → pvnet-4.0.11}/PVNet.egg-info/PKG-INFO +1 -1
  3. pvnet-4.0.11/pvnet/__init__.py +2 -0
  4. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/base_model.py +69 -3
  5. pvnet-4.0.9/pvnet/__init__.py +0 -2
  6. {pvnet-4.0.9 → pvnet-4.0.11}/LICENSE +0 -0
  7. {pvnet-4.0.9 → pvnet-4.0.11}/MANIFEST.in +0 -0
  8. {pvnet-4.0.9 → pvnet-4.0.11}/PVNet.egg-info/SOURCES.txt +0 -0
  9. {pvnet-4.0.9 → pvnet-4.0.11}/PVNet.egg-info/dependency_links.txt +0 -0
  10. {pvnet-4.0.9 → pvnet-4.0.11}/PVNet.egg-info/requires.txt +0 -0
  11. {pvnet-4.0.9 → pvnet-4.0.11}/PVNet.egg-info/top_level.txt +0 -0
  12. {pvnet-4.0.9 → pvnet-4.0.11}/README.md +0 -0
  13. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/callbacks.py +0 -0
  14. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/data/__init__.py +0 -0
  15. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/data/base_datamodule.py +0 -0
  16. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/data/site_datamodule.py +0 -0
  17. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/data/uk_regional_datamodule.py +0 -0
  18. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/load_model.py +0 -0
  19. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/__init__.py +0 -0
  20. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/baseline/__init__.py +0 -0
  21. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/baseline/last_value.py +0 -0
  22. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/baseline/single_value.py +0 -0
  23. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/ensemble.py +0 -0
  24. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/model_cards/pv_india_model_card_template.md +0 -0
  25. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/model_cards/pv_uk_regional_model_card_template.md +0 -0
  26. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/model_cards/wind_india_model_card_template.md +0 -0
  27. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/__init__.py +0 -0
  28. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/basic_blocks.py +0 -0
  29. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/encoders/__init__.py +0 -0
  30. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/encoders/basic_blocks.py +0 -0
  31. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/encoders/encoders2d.py +0 -0
  32. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/encoders/encoders3d.py +0 -0
  33. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/encoders/encodersRNN.py +0 -0
  34. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/linear_networks/__init__.py +0 -0
  35. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/linear_networks/basic_blocks.py +0 -0
  36. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/linear_networks/networks.py +0 -0
  37. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/multimodal.py +0 -0
  38. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/multimodal_base.py +0 -0
  39. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/site_encoders/__init__.py +0 -0
  40. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/site_encoders/basic_blocks.py +0 -0
  41. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/site_encoders/encoders.py +0 -0
  42. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/multimodal/unimodal_teacher.py +0 -0
  43. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/models/utils.py +0 -0
  44. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/optimizers.py +0 -0
  45. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/training.py +0 -0
  46. {pvnet-4.0.9 → pvnet-4.0.11}/pvnet/utils.py +0 -0
  47. {pvnet-4.0.9 → pvnet-4.0.11}/pyproject.toml +0 -0
  48. {pvnet-4.0.9 → pvnet-4.0.11}/setup.cfg +0 -0
  49. {pvnet-4.0.9 → pvnet-4.0.11}/tests/test_end2end.py +0 -0
  50. {pvnet-4.0.9 → pvnet-4.0.11}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PVNet
3
- Version: 4.0.9
3
+ Version: 4.0.11
4
4
  Summary: PVNet
5
5
  Author-email: Peter Dudfield <info@openclimatefix.org>
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PVNet
3
- Version: 4.0.9
3
+ Version: 4.0.11
4
4
  Summary: PVNet
5
5
  Author-email: Peter Dudfield <info@openclimatefix.org>
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,2 @@
1
+ """PVNet"""
2
+ __version__ = "4.0.11"
@@ -4,6 +4,7 @@ import json
4
4
  import logging
5
5
  import os
6
6
  import tempfile
7
+ import time
7
8
  from pathlib import Path
8
9
  from typing import Dict, Optional, Union
9
10
 
@@ -141,6 +142,65 @@ def minimize_data_config(input_path, output_path, model):
141
142
  yaml.dump(config, outfile, default_flow_style=False)
142
143
 
143
144
 
145
+ def download_hf_hub_with_retries(
146
+ repo_id,
147
+ filename,
148
+ revision,
149
+ cache_dir,
150
+ force_download,
151
+ proxies,
152
+ resume_download,
153
+ token,
154
+ local_files_only,
155
+ max_retries=5,
156
+ wait_time=10,
157
+ ):
158
+ """
159
+ Tries to download a file from HuggingFace up to max_retries times.
160
+
161
+ Args:
162
+ repo_id (str): HuggingFace repo ID
163
+ filename (str): Name of the file to download
164
+ revision (str): Specific model revision
165
+ cache_dir (str): Cache directory
166
+ force_download (bool): Whether to force a new download
167
+ proxies (dict): Proxy settings
168
+ resume_download (bool): Resume interrupted downloads
169
+ token (str): HuggingFace auth token
170
+ local_files_only (bool): Use local files only
171
+ max_retries (int): Maximum number of retry attempts
172
+ wait_time (int): Wait time (in seconds) before retrying
173
+
174
+ Returns:
175
+ str: The local file path of the downloaded file
176
+ """
177
+ for attempt in range(1, max_retries + 1):
178
+ try:
179
+ return hf_hub_download(
180
+ repo_id=repo_id,
181
+ filename=filename,
182
+ revision=revision,
183
+ cache_dir=cache_dir,
184
+ force_download=force_download,
185
+ proxies=proxies,
186
+ resume_download=resume_download,
187
+ token=token,
188
+ local_files_only=local_files_only,
189
+ )
190
+ except Exception as e:
191
+ if attempt == max_retries:
192
+ raise Exception(
193
+ f"Failed to download {filename} from {repo_id} after {max_retries} attempts."
194
+ ) from e
195
+ logging.warning(
196
+ (
197
+ f"Attempt {attempt}/{max_retries} failed to download {filename} "
198
+ f"from {repo_id}. Retrying in {wait_time} seconds..."
199
+ )
200
+ )
201
+ time.sleep(wait_time)
202
+
203
+
144
204
  class PVNetModelHubMixin(PyTorchModelHubMixin):
145
205
  """
146
206
  Implementation of [`PyTorchModelHubMixin`] to provide model Hub upload/download capabilities.
@@ -169,7 +229,7 @@ class PVNetModelHubMixin(PyTorchModelHubMixin):
169
229
  config_file = os.path.join(model_id, CONFIG_NAME)
170
230
  else:
171
231
  # load model file
172
- model_file = hf_hub_download(
232
+ model_file = download_hf_hub_with_retries(
173
233
  repo_id=model_id,
174
234
  filename=PYTORCH_WEIGHTS_NAME,
175
235
  revision=revision,
@@ -179,10 +239,12 @@ class PVNetModelHubMixin(PyTorchModelHubMixin):
179
239
  resume_download=resume_download,
180
240
  token=token,
181
241
  local_files_only=local_files_only,
242
+ max_retries=5,
243
+ wait_time=10,
182
244
  )
183
245
 
184
246
  # load config file
185
- config_file = hf_hub_download(
247
+ config_file = download_hf_hub_with_retries(
186
248
  repo_id=model_id,
187
249
  filename=CONFIG_NAME,
188
250
  revision=revision,
@@ -192,6 +254,8 @@ class PVNetModelHubMixin(PyTorchModelHubMixin):
192
254
  resume_download=resume_download,
193
255
  token=token,
194
256
  local_files_only=local_files_only,
257
+ max_retries=5,
258
+ wait_time=10,
195
259
  )
196
260
 
197
261
  with open(config_file, "r", encoding="utf-8") as f:
@@ -222,7 +286,7 @@ class PVNetModelHubMixin(PyTorchModelHubMixin):
222
286
  print("Loading data config from local directory")
223
287
  data_config_file = os.path.join(model_id, DATA_CONFIG_NAME)
224
288
  else:
225
- data_config_file = hf_hub_download(
289
+ data_config_file = download_hf_hub_with_retries(
226
290
  repo_id=model_id,
227
291
  filename=DATA_CONFIG_NAME,
228
292
  revision=revision,
@@ -232,6 +296,8 @@ class PVNetModelHubMixin(PyTorchModelHubMixin):
232
296
  resume_download=resume_download,
233
297
  token=token,
234
298
  local_files_only=local_files_only,
299
+ max_retries=5,
300
+ wait_time=10,
235
301
  )
236
302
 
237
303
  return data_config_file
@@ -1,2 +0,0 @@
1
- """PVNet"""
2
- __version__ = "4.0.9"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes