Skip to content

Commit

Permalink
Updating the path to test-data in the test suite and redirecting work…
Browse files Browse the repository at this point in the history
…flow_test to Be_model
  • Loading branch information
pcagas committed Jun 7, 2024
1 parent a8a2a0a commit 67e7c3f
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 46 deletions.
4 changes: 1 addition & 3 deletions test/all_lazy_loading_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import torch
import pytest

from mala.datahandling.data_repo import data_repo_path

data_path = os.path.join(data_repo_path, "Be2")
from mala.datahandling.data_repo import data_path

# This test compares the data scaling using the regular scaling procedure and
# the lazy-loading one (incremental fitting).
Expand Down
8 changes: 3 additions & 5 deletions test/basic_gpu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
which MALA relies on). Two things are tested:
1. Whether or not your system has GPU support.
2. Whether or not the GPU does what it is supposed to. For this,
2. Whether or not the GPU does what it is supposed to. For this,
a training is performed. It is measured whether or not the utilization
of the GPU results in a speed up.
of the GPU results in a speed up.
"""
import os
import time
Expand All @@ -19,9 +19,7 @@
import pytest
import torch

from mala.datahandling.data_repo import data_repo_path

data_path = os.path.join(data_repo_path, "Be2")
from mala.datahandling.data_repo import data_path

test_checkpoint_name = "test"

Expand Down
4 changes: 1 addition & 3 deletions test/checkpoint_hyperopt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
from mala import printout
import numpy as np

from mala.datahandling.data_repo import data_repo_path

data_path = os.path.join(data_repo_path, "Be2")
from mala.datahandling.data_repo import data_path

checkpoint_name = "test_ho"

Expand Down
3 changes: 1 addition & 2 deletions test/checkpoint_training_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
from mala import printout
import numpy as np

from mala.datahandling.data_repo import data_repo_path
from mala.datahandling.data_repo import data_path

data_path = os.path.join(data_repo_path, "Be2")
test_checkpoint_name = "test"

# Define the accuracy used in the tests.
Expand Down
4 changes: 1 addition & 3 deletions test/complete_interfaces_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import pytest


from mala.datahandling.data_repo import data_repo_path

data_path = os.path.join(data_repo_path, "Be2")
from mala.datahandling.data_repo import data_path


# This test checks whether MALA interfaces to other codes, mainly the ASE
Expand Down
4 changes: 1 addition & 3 deletions test/descriptor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import numpy as np
import pytest

from mala.datahandling.data_repo import data_repo_path

data_path = os.path.join(data_repo_path, "Be2")
from mala.datahandling.data_repo import data_path

# Accuracy of test.
accuracy_descriptors = 5e-8
Expand Down
4 changes: 1 addition & 3 deletions test/hyperopt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import mala
import numpy as np

from mala.datahandling.data_repo import data_repo_path

data_path = os.path.join(data_repo_path, "Be2")
from mala.datahandling.data_repo import data_path

# Control how much the loss should be better after hyperopt compared to
# before. This value is fairly high, but we're training on absolutely
Expand Down
8 changes: 3 additions & 5 deletions test/inference_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import numpy as np
from mala import Tester, Runner

from mala.datahandling.data_repo import data_repo_path
from mala.datahandling.data_repo import data_path

data_path = os.path.join(data_repo_path, "Be2")
param_path = os.path.join(data_repo_path, "workflow_test/")
accuracy_strict = 1e-16
accuracy_coarse = 5e-7
accuracy_very_coarse = 3
Expand All @@ -18,7 +16,7 @@ class TestInference:
def test_unit_conversion(self):
"""Test that RAM inexpensive unit conversion works."""
parameters, network, data_handler = Runner.load_run(
"workflow_test", load_runner=False, path=param_path
"Be_model", load_runner=False, path=data_path
)
parameters.data.use_lazy_loading = False
parameters.running.mini_batch_size = 50
Expand Down Expand Up @@ -99,7 +97,7 @@ def test_inference_lazy_loading(self):
def __run(use_lazy_loading=False, batchsize=46):
# First we load Parameters and network.
parameters, network, data_handler, tester = Tester.load_run(
"workflow_test", path=param_path
"Be_model", path=data_path
)
parameters.data.use_lazy_loading = use_lazy_loading
parameters.running.mini_batch_size = batchsize
Expand Down
3 changes: 1 addition & 2 deletions test/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import scipy as sp
import pytest

from mala.datahandling.data_repo import data_repo_path
from mala.datahandling.data_repo import data_path

# In order to test the integration capabilities of MALA we need a
# QuantumEspresso
Expand All @@ -18,7 +18,6 @@
# Scripts to reproduce the data files used in this test script can be found
# in the data repo.

data_path = os.path.join(data_repo_path, "Be2")
path_to_out = os.path.join(data_path, "Be_snapshot0.out")
path_to_ldos_npy = os.path.join(data_path, "Be_snapshot0.out.npy")
path_to_dos_npy = os.path.join(data_path, "Be_snapshot0.dos.npy")
Expand Down
4 changes: 1 addition & 3 deletions test/parallel_run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
from ase.io import read
import pytest

from mala.datahandling.data_repo import data_repo_path

data_path = os.path.join(data_repo_path, "Be2")
from mala.datahandling.data_repo import data_path

# Control the various accuracies..
accuracy_snaps = 1e-4
Expand Down
4 changes: 1 addition & 3 deletions test/scaling_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import numpy as np
import torch

from mala.datahandling.data_repo import data_repo_path

data_path = os.path.join(data_repo_path, "Be2")
from mala.datahandling.data_repo import data_path

# This test checks that all scaling options are working and are not messing
# up the data.
Expand Down
4 changes: 1 addition & 3 deletions test/shuffling_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import mala
import numpy as np

from mala.datahandling.data_repo import data_repo_path

data_path = os.path.join(data_repo_path, "Be2")
from mala.datahandling.data_repo import data_path

# Accuracy for the shuffling test.
accuracy = np.finfo(float).eps
Expand Down
4 changes: 1 addition & 3 deletions test/tensor_memory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from torch.utils.data import TensorDataset
from torch.utils.data import DataLoader

from mala.datahandling.data_repo import data_repo_path

data_path = os.path.join(data_repo_path, "Be2")
from mala.datahandling.data_repo import data_path

# Define the accuracy used in the tests.
accuracy = 1e-5
Expand Down
9 changes: 4 additions & 5 deletions test/workflow_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import numpy as np
import pytest

from mala.datahandling.data_repo import data_repo_path
from mala.datahandling.data_repo import data_path

data_path = os.path.join(data_repo_path, "Be2")
# Control how much the loss should be better after training compared to
# before. This value is fairly high, but we're training on absolutely
# minimal amounts of data.
Expand Down Expand Up @@ -382,7 +381,7 @@ def test_training_with_postprocessing_data_repo(self):
"""
# Load parameters, network and data scalers.
parameters, network, data_handler, tester = mala.Tester.load_run(
"workflow_test", path=os.path.join(data_repo_path, "workflow_test")
"Be_model", path=data_path
)

parameters.targets.target_type = "LDOS"
Expand Down Expand Up @@ -431,7 +430,7 @@ def test_predictions(self):
####################

parameters, network, data_handler, tester = mala.Tester.load_run(
"workflow_test", path=os.path.join(data_repo_path, "workflow_test")
"Be_model", path=data_path
)
parameters.targets.target_type = "LDOS"
parameters.targets.ldos_gridsize = 11
Expand Down Expand Up @@ -518,7 +517,7 @@ def test_total_energy_predictions(self):
####################

parameters, network, data_handler, predictor = mala.Predictor.load_run(
"workflow_test", path=os.path.join(data_repo_path, "workflow_test")
"Be_model", path=data_path
)
parameters.targets.target_type = "LDOS"
parameters.targets.ldos_gridsize = 11
Expand Down

0 comments on commit 67e7c3f

Please sign in to comment.