Skip to content

Commit

Permalink
Previous PR review changes
Browse files Browse the repository at this point in the history
- documentation fixes in quicktest.yaml

- docstring fixes in test_errors_in_logfiles.py

- removed loop over assert in test_file_existence.py
  • Loading branch information
taha-abdullah committed Sep 4, 2024
1 parent 3c40791 commit 26f4d3d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 32 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/quicktest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 \
Expand Down
10 changes: 5 additions & 5 deletions test/quick_test/test_errors_in_logfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand All @@ -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.
"""

Expand Down Expand Up @@ -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:
Expand Down
46 changes: 23 additions & 23 deletions test/quick_test/test_file_existence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.")

0 comments on commit 26f4d3d

Please sign in to comment.