PVNet 5.3.20__tar.gz → 5.3.22__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.
- {pvnet-5.3.20 → pvnet-5.3.22}/PKG-INFO +1 -1
- {pvnet-5.3.20 → pvnet-5.3.22}/PVNet.egg-info/PKG-INFO +1 -1
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/datamodule.py +12 -12
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/base_model.py +8 -10
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/ensemble.py +1 -1
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/late_fusion/encoders/basic_blocks.py +0 -1
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/late_fusion/encoders/encoders3d.py +1 -1
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/late_fusion/late_fusion.py +1 -1
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/late_fusion/linear_networks/basic_blocks.py +1 -2
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/late_fusion/site_encoders/basic_blocks.py +0 -1
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/optimizers.py +1 -2
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/training/lightning_module.py +12 -10
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/training/train.py +2 -2
- {pvnet-5.3.20 → pvnet-5.3.22}/pyproject.toml +4 -1
- {pvnet-5.3.20 → pvnet-5.3.22}/LICENSE +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/PVNet.egg-info/SOURCES.txt +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/PVNet.egg-info/dependency_links.txt +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/PVNet.egg-info/requires.txt +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/PVNet.egg-info/top_level.txt +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/README.md +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/__init__.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/load_model.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/__init__.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/late_fusion/__init__.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/late_fusion/basic_blocks.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/late_fusion/encoders/__init__.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/late_fusion/linear_networks/__init__.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/late_fusion/linear_networks/networks.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/late_fusion/site_encoders/__init__.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/models/late_fusion/site_encoders/encoders.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/training/__init__.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/training/plots.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/pvnet/utils.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/setup.cfg +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/tests/test_datamodule.py +0 -0
- {pvnet-5.3.20 → pvnet-5.3.22}/tests/test_end2end.py +0 -0
|
@@ -60,18 +60,18 @@ class PVNetDataModule(LightningDataModule):
|
|
|
60
60
|
self.seed = seed
|
|
61
61
|
self.dataset_pickle_dir = dataset_pickle_dir
|
|
62
62
|
|
|
63
|
-
self._common_dataloader_kwargs =
|
|
64
|
-
batch_size
|
|
65
|
-
batch_sampler
|
|
66
|
-
num_workers
|
|
67
|
-
collate_fn
|
|
68
|
-
pin_memory
|
|
69
|
-
timeout
|
|
70
|
-
worker_init_fn
|
|
71
|
-
prefetch_factor
|
|
72
|
-
persistent_workers
|
|
73
|
-
multiprocessing_context
|
|
74
|
-
|
|
63
|
+
self._common_dataloader_kwargs = {
|
|
64
|
+
"batch_size": batch_size,
|
|
65
|
+
"batch_sampler": None,
|
|
66
|
+
"num_workers": num_workers,
|
|
67
|
+
"collate_fn": collate_fn,
|
|
68
|
+
"pin_memory": pin_memory,
|
|
69
|
+
"timeout": 0,
|
|
70
|
+
"worker_init_fn": None,
|
|
71
|
+
"prefetch_factor": prefetch_factor,
|
|
72
|
+
"persistent_workers": persistent_workers,
|
|
73
|
+
"multiprocessing_context": "spawn" if num_workers > 0 else None,
|
|
74
|
+
}
|
|
75
75
|
|
|
76
76
|
def setup(self, stage: str | None = None):
|
|
77
77
|
"""Called once to prepare the datasets."""
|
|
@@ -23,6 +23,7 @@ from pvnet.utils import (
|
|
|
23
23
|
PYTORCH_WEIGHTS_NAME,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
+
logger = logging.getLogger(__name__)
|
|
26
27
|
|
|
27
28
|
def fill_config_paths_with_placeholder(config: dict, placeholder: str = "PLACEHOLDER") -> dict:
|
|
28
29
|
"""Modify the config in place to fill data paths with placeholder strings.
|
|
@@ -34,10 +35,9 @@ def fill_config_paths_with_placeholder(config: dict, placeholder: str = "PLACEHO
|
|
|
34
35
|
input_config = config["input_data"]
|
|
35
36
|
|
|
36
37
|
for source in ["generation", "satellite"]:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
input_config[source]["zarr_path"] = f"{placeholder}.zarr"
|
|
38
|
+
# If source present but path not empty
|
|
39
|
+
if (source in input_config) and (input_config[source]["zarr_path"] != ""):
|
|
40
|
+
input_config[source]["zarr_path"] = f"{placeholder}.zarr"
|
|
41
41
|
|
|
42
42
|
if "nwp" in input_config:
|
|
43
43
|
for source in input_config["nwp"]:
|
|
@@ -101,8 +101,7 @@ def minimize_config_for_model(config: dict, model: "BaseModel") -> dict:
|
|
|
101
101
|
+ (model.sat_encoder.sequence_length - 1) * sat_config["time_resolution_minutes"]
|
|
102
102
|
)
|
|
103
103
|
|
|
104
|
-
if "pv" in input_config:
|
|
105
|
-
if not model.include_pv:
|
|
104
|
+
if ("pv" in input_config) and (not model.include_pv):
|
|
106
105
|
del input_config["pv"]
|
|
107
106
|
|
|
108
107
|
if "generation" in input_config:
|
|
@@ -166,11 +165,11 @@ def download_from_hf(
|
|
|
166
165
|
raise Exception(
|
|
167
166
|
f"Failed to download {filename} from {repo_id} after {max_retries} attempts."
|
|
168
167
|
) from e
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
logger.warning(
|
|
169
|
+
|
|
171
170
|
f"Attempt {attempt}/{max_retries} failed to download {filename} "
|
|
172
171
|
f"from {repo_id}. Retrying in {wait_time} seconds..."
|
|
173
|
-
|
|
172
|
+
|
|
174
173
|
)
|
|
175
174
|
time.sleep(wait_time)
|
|
176
175
|
|
|
@@ -343,7 +342,6 @@ class HuggingfaceMixin:
|
|
|
343
342
|
|
|
344
343
|
print(message)
|
|
345
344
|
|
|
346
|
-
return
|
|
347
345
|
|
|
348
346
|
@staticmethod
|
|
349
347
|
def create_hugging_face_model_card(
|
|
@@ -42,7 +42,7 @@ class Ensemble(BaseModel):
|
|
|
42
42
|
forecast_minutes,
|
|
43
43
|
interval_minutes,
|
|
44
44
|
]:
|
|
45
|
-
assert all(
|
|
45
|
+
assert all(p == param_list[0] for p in param_list), param_list
|
|
46
46
|
|
|
47
47
|
super().__init__(
|
|
48
48
|
history_minutes=history_minutes[0],
|
|
@@ -191,7 +191,7 @@ class LateFusionModel(BaseModel):
|
|
|
191
191
|
if add_image_embedding_channel:
|
|
192
192
|
self.nwp_embed_dict = torch.nn.ModuleDict()
|
|
193
193
|
|
|
194
|
-
for nwp_source in nwp_encoders_dict
|
|
194
|
+
for nwp_source in nwp_encoders_dict:
|
|
195
195
|
nwp_sequence_len = (
|
|
196
196
|
nwp_history_minutes[nwp_source] // nwp_interval_minutes[nwp_source]
|
|
197
197
|
+ nwp_forecast_minutes[nwp_source] // nwp_interval_minutes[nwp_source]
|
|
@@ -29,12 +29,11 @@ class AbstractLinearNetwork(nn.Module, metaclass=ABCMeta):
|
|
|
29
29
|
elif isinstance(x, torch.Tensor):
|
|
30
30
|
return x
|
|
31
31
|
else:
|
|
32
|
-
raise
|
|
32
|
+
raise TypeError(f"Input of unexpected type {type(x)}")
|
|
33
33
|
|
|
34
34
|
@abstractmethod
|
|
35
35
|
def forward(self, x: OrderedDict[str, torch.Tensor] | torch.Tensor) -> torch.Tensor:
|
|
36
36
|
"""Run model forward"""
|
|
37
|
-
pass
|
|
38
37
|
|
|
39
38
|
|
|
40
39
|
class ResidualLinearBlock(nn.Module):
|
|
@@ -67,7 +67,6 @@ class AbstractOptimizer(ABC):
|
|
|
67
67
|
@abstractmethod
|
|
68
68
|
def __call__(self, model: Module):
|
|
69
69
|
"""Abstract call"""
|
|
70
|
-
pass
|
|
71
70
|
|
|
72
71
|
|
|
73
72
|
class Adam(AbstractOptimizer):
|
|
@@ -166,7 +165,7 @@ class AdamWReduceLROnPlateau(AbstractOptimizer):
|
|
|
166
165
|
|
|
167
166
|
group_args = []
|
|
168
167
|
|
|
169
|
-
for key in self.lr
|
|
168
|
+
for key in self.lr:
|
|
170
169
|
if key == "default":
|
|
171
170
|
continue
|
|
172
171
|
|
|
@@ -153,7 +153,9 @@ class PVNetLightningModule(pl.LightningModule):
|
|
|
153
153
|
"""Internally store the validation predictions"""
|
|
154
154
|
|
|
155
155
|
y = batch["generation"][:, -self.model.forecast_len :].cpu().numpy()
|
|
156
|
-
|
|
156
|
+
# .float() as numpy has no bfloat16 dtype
|
|
157
|
+
# Fails under precision="bf16-mixed"
|
|
158
|
+
y_hat = y_hat.float().cpu().numpy()
|
|
157
159
|
ids = batch["location_id"].cpu().numpy()
|
|
158
160
|
init_times_utc = pd.to_datetime(
|
|
159
161
|
batch["time_utc"][:, self.model.history_len + 1].cpu().numpy().astype("datetime64[ns]")
|
|
@@ -166,15 +168,15 @@ class PVNetLightningModule(pl.LightningModule):
|
|
|
166
168
|
y_hat = y_hat[..., None]
|
|
167
169
|
|
|
168
170
|
ds_preds_batch = xr.Dataset(
|
|
169
|
-
data_vars=
|
|
170
|
-
y_hat
|
|
171
|
-
y
|
|
172
|
-
|
|
173
|
-
coords=
|
|
174
|
-
ids
|
|
175
|
-
init_times_utc
|
|
176
|
-
p_level
|
|
177
|
-
|
|
171
|
+
data_vars={
|
|
172
|
+
"y_hat": (["sample_num", "forecast_step", "p_level"], y_hat),
|
|
173
|
+
"y": (["sample_num", "forecast_step"], y),
|
|
174
|
+
},
|
|
175
|
+
coords={
|
|
176
|
+
"ids": ("sample_num", ids),
|
|
177
|
+
"init_times_utc": ("sample_num", init_times_utc),
|
|
178
|
+
"p_level": p_levels,
|
|
179
|
+
},
|
|
178
180
|
)
|
|
179
181
|
self.all_val_results.append(ds_preds_batch)
|
|
180
182
|
|
|
@@ -64,13 +64,13 @@ def train(config: DictConfig) -> None:
|
|
|
64
64
|
# Init lightning loggers
|
|
65
65
|
loggers: list[Logger] = []
|
|
66
66
|
if "logger" in config:
|
|
67
|
-
for
|
|
67
|
+
for lg_conf in config.logger.values():
|
|
68
68
|
loggers.append(hydra.utils.instantiate(lg_conf))
|
|
69
69
|
|
|
70
70
|
# Init lightning callbacks
|
|
71
71
|
callbacks: list[Callback] = []
|
|
72
72
|
if "callbacks" in config:
|
|
73
|
-
for
|
|
73
|
+
for cb_conf in config.callbacks.values():
|
|
74
74
|
callbacks.append(hydra.utils.instantiate(cb_conf))
|
|
75
75
|
|
|
76
76
|
# Align the wandb id with the checkpoint path
|
|
@@ -80,7 +80,10 @@ target-version = "py310"
|
|
|
80
80
|
|
|
81
81
|
[tool.ruff.lint]
|
|
82
82
|
extend-select = ["E", "D", "I"]
|
|
83
|
-
ignore = ["D200","D202","D210","D212","D415","D105"
|
|
83
|
+
ignore = ["D200","D202","D210","D212","D415","D105",
|
|
84
|
+
"TRY002", # Create your own exception
|
|
85
|
+
"B008", # Do not perform function call typer.Argument
|
|
86
|
+
]
|
|
84
87
|
|
|
85
88
|
[tool.ruff.lint.mccabe]
|
|
86
89
|
# Unlike Flake8, default to a complexity level of 10.
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|