From 2b1aebc8d31a4f1bcb6419012c242059fa2cb4c1 Mon Sep 17 00:00:00 2001 From: dbouget Date: Thu, 1 Feb 2024 13:00:57 +0000 Subject: [PATCH] Fixing the unit test script (working locally) --- .github/workflows/build_windows.yml | 2 +- .gitignore | 3 ++- tests/heatmap_generation_test.py | 24 +++++++++++++++--------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index 0f06dae..5538c19 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -49,7 +49,7 @@ jobs: strategy: matrix: os: [ windows-2019, windows-2022 ] - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10"] runs-on: ${{ matrix.os }} steps: diff --git a/.gitignore b/.gitignore index e29f398..af0d4de 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,5 @@ numpy /venv* *.nrrd /notebooks/.ipynb_checkpoints -.ipynb_checkpoints \ No newline at end of file +.ipynb_checkpoints +raidionicsmaps.egg-info \ No newline at end of file diff --git a/tests/heatmap_generation_test.py b/tests/heatmap_generation_test.py index 59d3272..471123d 100644 --- a/tests/heatmap_generation_test.py +++ b/tests/heatmap_generation_test.py @@ -43,7 +43,8 @@ def heatmap_generation_test(): raise ValueError('Resources download or extraction failed, content not available on disk.') except Exception as e: logging.error("Error during resources download with: \n {}.\n".format(traceback.format_exc())) - shutil.rmtree(test_dir) + if os.path.exists(test_dir): + shutil.rmtree(test_dir) raise ValueError("Error during resources download.\n") logging.info("Preparing configuration file.\n") @@ -54,7 +55,7 @@ def heatmap_generation_test(): unit_test_config.set('Default', 'input_folder', os.path.join(test_dir, 'Cohort_UnitTest1')) unit_test_config.set('Default', 'output_folder', os.path.join(test_dir, 'Cohort_UnitTest1_Output')) unit_test_config.add_section('Maps') - unit_test_config.set('Maps', 'input_folder', os.path.join(test_dir, 'label_tumor.nii.gz')) + unit_test_config.set('Maps', 'gt_files_suffix', 'label_tumor.nii.gz') unit_test_config.set('Maps', 'use_registered_data', 'true') config_filename = os.path.join(test_dir, 'config.ini') with open(config_filename, 'w') as outfile: @@ -65,10 +66,11 @@ def heatmap_generation_test(): compute(config_filename) logging.info("Collecting and comparing results.\n") - heatmap_filename = os.path.join(test_dir, 'Results', 'Heatmaps', 'heatmap_percentages.nii.gz') + heatmap_filename = os.path.join(test_dir, 'Cohort_UnitTest1_Output', 'Heatmaps', 'Overall', 'heatmap_percentages.nii.gz') if not os.path.exists(heatmap_filename): logging.error("Heatmap generation unit test failed, no heatmap was generated.\n") - shutil.rmtree(test_dir) + if os.path.exists(test_dir): + shutil.rmtree(test_dir) raise ValueError("Heatmap generation unit test failed, no heatmap was generated.\n") logging.info("Heatmap generation CLI unit test started.\n") @@ -88,23 +90,27 @@ def heatmap_generation_test(): '--verbose', 'debug']) except Exception as e: logging.error("Error during heatmap generation CLI unit test with: \n {}.\n".format(traceback.format_exc())) - shutil.rmtree(test_dir) + if os.path.exists(test_dir): + shutil.rmtree(test_dir) raise ValueError("Error during heatmap generation CLI unit test.\n") logging.info("Collecting and comparing results.\n") - heatmap_filename = os.path.join(test_dir, 'Results', 'Heatmaps', 'heatmap_percentages.nii.gz') + heatmap_filename = os.path.join(test_dir, 'Cohort_UnitTest1_Output', 'Heatmaps', 'Overall', 'heatmap_percentages.nii.gz') if not os.path.exists(heatmap_filename): logging.error("Heatmap generation unit test failed, no heatmap was generated.\n") - shutil.rmtree(test_dir) + if os.path.exists(test_dir): + shutil.rmtree(test_dir) raise ValueError("Heatmap generation unit test failed, no heatmap was generated.\n") logging.info("Heatmap generation CLI unit test succeeded.\n") except Exception as e: logging.error("Error during heatmap generation unit test with: \n {}.\n".format(traceback.format_exc())) - shutil.rmtree(test_dir) + if os.path.exists(test_dir): + shutil.rmtree(test_dir) raise ValueError("Error during heatmap generation unit test with.\n") logging.info("Heatmap generation unit test succeeded.\n") - shutil.rmtree(test_dir) + if os.path.exists(test_dir): + shutil.rmtree(test_dir) heatmap_generation_test()