From 5d3f050ad8398b43129354bf375e21d9050af498 Mon Sep 17 00:00:00 2001 From: Tim Koornstra Date: Thu, 17 Aug 2023 17:01:36 +0200 Subject: [PATCH] Update unittest logging --- .github/workflows/run_tests.yml | 12 ++++++++++-- tests/test_datagenerator.py | 8 ++++++++ tests/test_dataloader.py | 8 ++++++++ tests/test_model_creation.py | 21 ++++++++++++++------- tests/test_utils.py | 8 ++++++++ 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index ec8c8fe5..6031bf4b 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -3,7 +3,7 @@ name: Run Tests on: [push, pull_request] jobs: - test: + unittests: runs-on: ubuntu-latest steps: @@ -26,18 +26,26 @@ jobs: - name: Test utils run: | python -m unittest tests/test_utils.py + env: + TF_CPP_MIN_LOG_LEVEL: '2' - name: Test DataGeneratorNew2 if: always() run: | python -m unittest tests/test_datagenerator.py + env: + TF_CPP_MIN_LOG_LEVEL: '2' - name: Test DataLoaderNew if: always() run: | python -m unittest tests/test_dataloader.py + env: + TF_CPP_MIN_LOG_LEVEL: '2' - - name: Test basic model creation + - name: Test model creation if: always() run: | python -m unittest tests/test_model_creation.py + env: + TF_CPP_MIN_LOG_LEVEL: '2' diff --git a/tests/test_datagenerator.py b/tests/test_datagenerator.py index 380d8a2c..e025e01a 100644 --- a/tests/test_datagenerator.py +++ b/tests/test_datagenerator.py @@ -4,6 +4,7 @@ import numpy as np # > Standard library +import logging import os import sys import unittest @@ -28,6 +29,13 @@ class TestDataGenerator(unittest.TestCase): @classmethod def setUpClass(cls): + # Set up logging + logging.basicConfig( + format="%(asctime)s - %(levelname)s - %(message)s", + datefmt="%d/%m/%Y %H:%M:%S", + level=logging.ERROR, + ) + # Determine the directory of this file current_file_dir = os.path.dirname(os.path.realpath(__file__)) diff --git a/tests/test_dataloader.py b/tests/test_dataloader.py index ce6f8e41..2adfa3b7 100644 --- a/tests/test_dataloader.py +++ b/tests/test_dataloader.py @@ -1,6 +1,7 @@ # Imports # > Standard library +import logging import os import sys import tempfile @@ -35,6 +36,13 @@ class DataLoaderTest(unittest.TestCase): @classmethod def setUpClass(cls): + # Set up logging + logging.basicConfig( + format="%(asctime)s - %(levelname)s - %(message)s", + datefmt="%d/%m/%Y %H:%M:%S", + level=logging.ERROR, + ) + # Determine the directory of this file current_file_dir = os.path.dirname(os.path.realpath(__file__)) diff --git a/tests/test_model_creation.py b/tests/test_model_creation.py index 9dce5240..ccaaa177 100644 --- a/tests/test_model_creation.py +++ b/tests/test_model_creation.py @@ -8,6 +8,7 @@ from tensorflow.keras import activations # > Standard library +import logging import unittest import sys @@ -37,7 +38,13 @@ class VGSLModelGeneratorTest(unittest.TestCase): @classmethod def setUpClass(cls): sys.path.append("./src") - tf.get_logger().setLevel('ERROR') + + # Set up logging + logging.basicConfig( + format="%(asctime)s - %(levelname)s - %(message)s", + datefmt="%d/%m/%Y %H:%M:%S", + level=logging.ERROR, + ) from vgsl_model_generator import VGSLModelGenerator cls.VGSLModelGenerator = VGSLModelGenerator @@ -197,7 +204,7 @@ def test_fully_connected_layer(self): self.assertEqual(model.layers[5].activation, activations.softmax) def test_lstm_layer(self): - vgsl_spec_string = "None,64,None,1 Rc Lfxs128 O1s10" + vgsl_spec_string = "None,64,None,1 Rc Lfs128 O1s10" model_generator = self.VGSLModelGenerator(vgsl_spec_string) model = model_generator.build() self.assertIsInstance(model.layers[2], layers.LSTM) @@ -208,7 +215,7 @@ def test_lstm_layer(self): self.assertEqual(model.layers[2].return_sequences, True) # Check backwards LSTM with return_sequences - vgsl_spec_string = "None,64,None,1 Rc Lrx128 O1s10" + vgsl_spec_string = "None,64,None,1 Rc Lr128 O1s10" model_generator = self.VGSLModelGenerator(vgsl_spec_string) model = model_generator.build() @@ -216,7 +223,7 @@ def test_lstm_layer(self): self.assertEqual(model.layers[2].return_sequences, False) def test_gru_layer(self): - vgsl_spec_string = "None,64,None,1 Rc Gfxs128 O1s10" + vgsl_spec_string = "None,64,None,1 Rc Gfs128 O1s10" model_generator = self.VGSLModelGenerator(vgsl_spec_string) model = model_generator.build() self.assertIsInstance(model.layers[2], layers.GRU) @@ -227,7 +234,7 @@ def test_gru_layer(self): self.assertEqual(model.layers[2].return_sequences, True) # Check backwards GRU with return_sequences - vgsl_spec_string = "None,64,None,1 Rc Grx128 O1s10" + vgsl_spec_string = "None,64,None,1 Rc Gr128 O1s10" model_generator = self.VGSLModelGenerator(vgsl_spec_string) model = model_generator.build() @@ -235,14 +242,14 @@ def test_gru_layer(self): self.assertEqual(model.layers[2].return_sequences, False) def test_bidirectional_layer(self): - vgsl_spec_string = "None,64,None,1 Rc Bgxs128 O1s10" + vgsl_spec_string = "None,64,None,1 Rc Bgs128 O1s10" model_generator = self.VGSLModelGenerator(vgsl_spec_string) model = model_generator.build() self.assertIsInstance(model.layers[2], layers.Bidirectional) self.assertIsInstance(model.layers[2].layer, layers.GRU) self.assertEqual(model.layers[2].layer.units, 128) - vgsl_spec_string = "None,64,None,1 Rc Blxs128 O1s10" + vgsl_spec_string = "None,64,None,1 Rc Bls128 O1s10" model_generator = self.VGSLModelGenerator(vgsl_spec_string) model = model_generator.build() self.assertIsInstance(model.layers[2], layers.Bidirectional) diff --git a/tests/test_utils.py b/tests/test_utils.py index f7574990..60f84e11 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -5,6 +5,7 @@ import numpy as np # > Standard library +import logging import unittest import os import sys @@ -13,6 +14,13 @@ class TestUtils(unittest.TestCase): @classmethod def setUpClass(cls): + # Set up logging + logging.basicConfig( + format="%(asctime)s - %(levelname)s - %(message)s", + datefmt="%d/%m/%Y %H:%M:%S", + level=logging.ERROR, + ) + # Determine the directory of this file current_file_dir = os.path.dirname(os.path.realpath(__file__))