Skip to content

Commit

Permalink
turn meps testdata download into pytest fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
leifdenby committed Jul 16, 2024
1 parent 0b5687a commit 095fdbc
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions tests/test_mllam_dataset.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Standard library
import os
from pathlib import Path

# Third-party
import pooch
import pytest

# First-party
from create_mesh import main as create_mesh
from neural_lam.config import Config

# First-party
from neural_lam.create_mesh import main as create_mesh
from neural_lam.train_model import main as train_model
from neural_lam.utils import load_static_data
from neural_lam.weather_dataset import WeatherDataset
from train_model import main as train_model

# Disable weights and biases to avoid unnecessary logging
# and to avoid having to deal with authentication
Expand All @@ -25,7 +28,8 @@
)


def test_retrieve_data_ewc():
@pytest.fixture
def meps_example_reduced_filepath():
# Download and unzip test data into data/meps_example_reduced
pooch.retrieve(
url=S3_FULL_PATH,
Expand All @@ -34,16 +38,17 @@ def test_retrieve_data_ewc():
path="data",
fname="meps_example_reduced.zip",
)
return Path("data/meps_example_reduced")


def test_load_reduced_meps_dataset():
def test_load_reduced_meps_dataset(meps_example_reduced_filepath):
# The data_config.yaml file is downloaded and extracted in
# test_retrieve_data_ewc together with the dataset itself
data_config_file = "data/meps_example_reduced/data_config.yaml"
dataset_name = "meps_example_reduced"
data_config_file = meps_example_reduced_filepath / "data_config.yaml"
dataset_name = meps_example_reduced_filepath.name

dataset = WeatherDataset(dataset_name="meps_example_reduced")
config = Config.from_file(data_config_file)
dataset = WeatherDataset(dataset_name=dataset_name)
config = Config.from_file(str(data_config_file))

var_names = config.values["dataset"]["var_names"]
var_units = config.values["dataset"]["var_units"]
Expand Down

0 comments on commit 095fdbc

Please sign in to comment.