Skip to content

Commit

Permalink
Loading test (#267)
Browse files Browse the repository at this point in the history
Forecast compiler test for loading functionality
  • Loading branch information
felix-e-h-p authored Feb 27, 2025
1 parent 531b5e2 commit 353413c
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/test_forecast_compiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import pytest
import torch

from pvnet.models.base_model import BaseModel as PVNetBaseModel
from pvnet_summation.models.base_model import BaseModel as SummationBaseModel

from pvnet_app.forecast_compiler import ForecastCompiler
from pvnet_app.model_configs.pydantic_models import get_all_models


def test_model_loading():
"""Test that all configured models can be loaded correctly."""

models = get_all_models(run_extra_models=True, use_ocf_data_sampler=True)
device = torch.device("cpu")

for model_config in models:
# Extract model info
model_name = model_config.pvnet.repo
model_version = model_config.pvnet.version
summation_name = model_config.summation.repo if model_config.summation else None
summation_version = model_config.summation.version if model_config.summation else None

# Load models via ForecastCompiler
pvnet_model, summation_model = ForecastCompiler.load_model(
model_name=model_name,
model_version=model_version,
summation_name=summation_name,
summation_version=summation_version,
device=device
)

# Verify models loaded correctly
assert isinstance(pvnet_model, PVNetBaseModel)

# Verify summation model if configured
if summation_name:
assert isinstance(summation_model, SummationBaseModel)
else:
assert summation_model is None

# Assertion major required attributes actually exist
assert hasattr(pvnet_model, "forecast_len")
assert hasattr(pvnet_model, "output_quantiles")

0 comments on commit 353413c

Please sign in to comment.