From 26f4d3d979f0fcdd0c25f6761947ca406a7020ef Mon Sep 17 00:00:00 2001 From: Taha Abdullah Date: Wed, 4 Sep 2024 16:49:59 +0200 Subject: [PATCH] Previous PR review changes - documentation fixes in quicktest.yaml - docstring fixes in test_errors_in_logfiles.py - removed loop over assert in test_file_existence.py --- .github/workflows/quicktest.yaml | 6 +-- test/quick_test/test_errors_in_logfiles.py | 10 ++--- test/quick_test/test_file_existence.py | 46 +++++++++++----------- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/.github/workflows/quicktest.yaml b/.github/workflows/quicktest.yaml index 1f7d2055..bcf1a7b3 100644 --- a/.github/workflows/quicktest.yaml +++ b/.github/workflows/quicktest.yaml @@ -6,8 +6,7 @@ name: quicktest # Functionality: This workflow runs some quick integration tests on FastSurfer commits. It checks out the new # FastSurfer repo, sets up Python, builds a Singularity image, runs FastSurfer on sample MRI data, and # runs pytest to check if the results are acceptable -# Usage: This workflow is triggered on a push or pull-request to the dev and main branch of DeepMI/FastSurfer. -# It can also be triggered manually with workflow-dispatch +# Usage: This workflow is exclusively triggered manually with workflow-dispatch in DeepMI/FastSurfer. on: @@ -57,7 +56,6 @@ jobs: echo "SIF File does not exist. Building file." cd $FASTSURFER_HOME python3 Docker/build.py --device cuda --tag fastsurfer_gpu:cuda - cd $RUNNER_FASTSURFER_IMGS apptainer build --force fastsurfer-gpu.sif docker-daemon://fastsurfer_gpu:cuda else echo "File already exists" @@ -85,7 +83,7 @@ jobs: --env FASTSURFER_HOME=/fastsurfer-dev \ -B $RUNNER_FS_MRI_DATA:/data \ -B $RUNNER_FS_OUTPUT:/output \ - -B $RUNNER_FS_LICENSE:/fs_license \ + -B $RUNNER_FS_LICENSE:/fs_license/.license \ $RUNNER_FASTSURFER_IMGS/fastsurfer-gpu.sif \ /fastsurfer/brun_fastsurfer.sh \ --fs_license /fs_license/.license \ diff --git a/test/quick_test/test_errors_in_logfiles.py b/test/quick_test/test_errors_in_logfiles.py index 9c2875c5..dab5f58e 100644 --- a/test/quick_test/test_errors_in_logfiles.py +++ b/test/quick_test/test_errors_in_logfiles.py @@ -12,13 +12,13 @@ def load_errors(): """ - Load the errors and whitelist from the given file path. + Load the errors and whitelist strings from ./data/logfile.errors.yaml. Returns ------- - errors : list + errors : list[str] List of errors. - whitelist : list + whitelist : list[str] List of whitelisted errors. """ @@ -45,7 +45,7 @@ def load_log_files(test_subject: str): Returns ------- - log_files : list + log_files : list[Path] List of log files in the given log directory. """ @@ -88,7 +88,7 @@ def test_errors(subjects_dir, test_dir, test_subject): # Check if any of the keywords are in the log files for log_file in log_files: - rel_path = log_file.relative_to(os.environ["SUBJECTS_DIR"]) + rel_path = log_file.relative_to(subjects_dir) logger.debug(f"Checking file: {rel_path}") try: with log_file.open('r') as file: diff --git a/test/quick_test/test_file_existence.py b/test/quick_test/test_file_existence.py index 27135ae9..6e85d8d5 100644 --- a/test/quick_test/test_file_existence.py +++ b/test/quick_test/test_file_existence.py @@ -9,27 +9,27 @@ logger = getLogger(__name__) -def get_files_from_yaml(file_path: str): - """ - Get the list of files from the YAML file. - - Parameters - ---------- - file_path : str - Path to the YAML file. - - Returns - ------- - list - List of files specified in the YAML file. - """ - - # Open the file_path and read the files into an array - with open(file_path, 'r') as file: - data = yaml.safe_load(file) - files = data.get('files', []) - - return files +# def get_files_from_yaml(file_path: str): +# """ +# Get the list of files from the YAML file. +# +# Parameters +# ---------- +# file_path : str +# Path to the YAML file. +# +# Returns +# ------- +# list +# List of files specified in the YAML file. +# """ +# +# # Open the file_path and read the files into an array +# with open(file_path, 'r') as file: +# data = yaml.safe_load(file) +# files = data.get('files', []) +# +# return files def get_files_from_folder(folder_path: str): @@ -89,7 +89,7 @@ def test_file_existence(subjects_dir, test_dir, reference_dir, test_subject): test_files = get_files_from_folder(test_subject) # Check if each file in the reference list exists in the test list - for file in reference_files: - assert file in test_files, f"File '{file}' does not exist." + missing_files = [file for file in reference_files if file not in test_files] + assert not missing_files, f"Files '{missing_files}' do not exist in test subject." logger.debug("\nAll files present.")