Skip to content
Snippets Groups Projects
Commit 05def7d2 authored by Tim O'Donnell's avatar Tim O'Donnell
Browse files

Add teardown to tests to clear keras session

parent 52977dd7
No related branches found
No related tags found
No related merge requests found
Showing
with 53 additions and 2 deletions
......@@ -44,5 +44,4 @@ script:
# download data and models, then run tests
- mhcflurry-downloads fetch data_curated models_class1 models_class1_pan allele_sequences
- mhcflurry-downloads info # just to test this command works
#- travis_wait 30 nosetests --with-timer -sv
- bash -c 'for i in $(ls test/test_*.py) ; do echo "Invoking test: $i" ; nosetests -sv $i ; done'
- nosetests --with-timer -sv test
def module_cleanup():
import keras.backend as K
K.clear_session()
......@@ -14,6 +14,9 @@ from mhcflurry.downloads import get_path
os.environ["CUDA_VISIBLE_DEVICES"] = ""
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
def run_and_check(n_jobs=0, delete=True, additional_args=[]):
source_models_dir = get_path("models_class1_pan", "models.with_mass_spec")
......
......@@ -8,6 +8,9 @@ from mhcflurry.downloads import get_path
from numpy.testing import assert_equal
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
ALLELE_TO_SEQUENCE = pandas.read_csv(
get_path(
"allele_sequences", "allele_sequences.csv"),
......
......@@ -16,6 +16,10 @@ from numpy import testing
from mhcflurry.downloads import get_path
import mhcflurry.testing_utils
teardown = mhcflurry.testing_utils.module_cleanup
DOWNLOADED_PREDICTOR = Class1AffinityPredictor.load()
logging.basicConfig(level=logging.DEBUG)
......@@ -252,3 +256,4 @@ def test_predict_implementations_equivalent():
peptides=peptides,
centrality_measure=centrality_measure).prediction.values
testing.assert_almost_equal(pred1, pred2, decimal=2)
......@@ -13,6 +13,9 @@ from mhcflurry.class1_neural_network import Class1NeuralNetwork
from mhcflurry.downloads import get_path
from mhcflurry.common import random_peptides
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
def test_class1_neural_network_a0205_training_accuracy():
# Memorize the dataset.
......
......@@ -11,6 +11,9 @@ from mhcflurry import Class1AffinityPredictor,Class1NeuralNetwork
from mhcflurry.allele_encoding import AlleleEncoding
from mhcflurry.downloads import get_path
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
HYPERPARAMETERS = {
'activation': 'tanh',
......
......@@ -11,6 +11,9 @@ import keras.backend as K
from mhcflurry.custom_loss import CUSTOM_LOSSES
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
def evaluate_loss(loss, y_true, y_pred):
y_true = numpy.array(y_true)
......
......@@ -5,6 +5,9 @@ from numpy.testing import assert_equal
from mhcflurry import Class1AffinityPredictor, Class1NeuralNetwork
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
DOWNLOADED_PREDICTOR = Class1AffinityPredictor.load()
......
......@@ -12,6 +12,9 @@ logging.getLogger('tensorflow').disabled = True
from mhcflurry.class1_neural_network import Class1NeuralNetwork
from mhcflurry.common import random_peptides
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
def test_multi_output():
hyperparameters = dict(
......
......@@ -5,6 +5,9 @@ from mhcflurry import Class1AffinityPredictor, Class1NeuralNetwork
from mhcflurry.common import random_peptides
from mhcflurry.downloads import get_path
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
logging.getLogger('tensorflow').disabled = True
PAN_ALLELE_PREDICTOR = Class1AffinityPredictor.load(
......
......@@ -6,6 +6,9 @@ from numpy.testing import assert_equal
from mhcflurry import predict_command
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
TEST_CSV = '''
Allele,Peptide,Experiment
HLA-A0201,SYNFEKKL,17
......
......@@ -13,6 +13,9 @@ from nose.tools import eq_, assert_less, assert_greater, assert_almost_equal
from mhcflurry import Class1AffinityPredictor
from mhcflurry.downloads import get_path
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
def data_path(name):
'''
......
......@@ -15,6 +15,9 @@ from mhcflurry.encodable_sequences import EncodableSequences
from mhcflurry.downloads import get_path
from mhcflurry.common import random_peptides
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
PREDICTORS = {
'allele-specific': Class1AffinityPredictor.load(
......
......@@ -18,6 +18,9 @@ from mhcflurry.encodable_sequences import EncodableSequences
from mhcflurry.common import random_peptides
from mhcflurry.downloads import get_path
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
ALLELE_SPECIFIC_PREDICTOR = Class1AffinityPredictor.load(
get_path("models_class1", "models"))
......
......@@ -14,6 +14,9 @@ from numpy.testing import assert_array_less, assert_equal
from mhcflurry import Class1AffinityPredictor
from mhcflurry.downloads import get_path
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
os.environ["CUDA_VISIBLE_DEVICES"] = ""
HYPERPARAMETERS = [
......
......@@ -15,6 +15,9 @@ from numpy.testing import assert_equal, assert_array_less
from mhcflurry import Class1AffinityPredictor,Class1NeuralNetwork
from mhcflurry.downloads import get_path
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
os.environ["CUDA_VISIBLE_DEVICES"] = ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment