Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test action #76

Closed
wants to merge 11 commits into from
22 changes: 22 additions & 0 deletions .github/workflows/github-actions-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on:
pull_request:
types: [opened, reopened]
jobs:
Explore-GitHub-Actions:
runs-on: [self-hosted, macOS, ARM64]
defaults:
run:
shell: zsh {0}
steps:
#- uses: actions/checkout@v2
- name: Activate Conda
run: |
conda activate BabelBrain
- name: Copy config files
run: |
cp /Users/spichardo/Public/TempForSim/config.ini Tests/
- name: run pytest
run: |
coverage run -m pytest Tests -k 'test_step1_normal[SDR_0p55-CT-H317-Deep_Target-brainsight]'
22 changes: 21 additions & 1 deletion Tests/Integration/test_integration_step1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,27 @@

class TestStep1:

def test_step1_valid_case(self,qtbot,trajectory,transducer,scan_type,dataset,babelbrain_widget,load_files,compare_data,mock_NotifyError,mock_UpdateMask,tmp_path):
def test_step1_normal(self,qtbot,babelbrain_widget):

# Run Step 1
babelbrain_widget.testing_error = False
babelbrain_widget.Widget.CalculatePlanningMask.click()

# Wait for step 1 completion before continuing. Test timeouts after 15 min have past
qtbot.waitUntil(babelbrain_widget.Widget.tabWidget.isEnabled,timeout=900000)

# Check if step 1 failed
if babelbrain_widget.testing_error == True:
pytest.fail(f"Test failed due to error in execution")


def test_step1_valid_case(self,qtbot,trajectory,
transducer,
scan_type,
dataset,
babelbrain_widget,
load_files,
compare_data,mock_NotifyError,mock_UpdateMask,tmp_path):

# Truth folder path
if scan_type == "NONE":
Expand Down
11 changes: 4 additions & 7 deletions Tests/Unit/GPU_Functions/test_GPUMedianFilter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
sys.path.append('BabelBrain/GPUMedianFilter')
sys.path.append('BabelBrain/GPUFunctions/GPUMedianFilter')
sys.path.append('BabelBrain/GPUFunctions')
import logging

import pytest
Expand All @@ -16,12 +17,8 @@ def test_median_filter(computing_backend,dataset,check_os,get_gpu_device,load_fi

# Initialize GPU Backend
gpu_device = get_gpu_device()
if computing_backend['type'] == 'OpenCL':
MedianFilter.InitOpenCL(gpu_device)
elif computing_backend['type'] == 'CUDA':
MedianFilter.InitCUDA(gpu_device)
elif computing_backend['type'] == 'Metal':
MedianFilter.InitMetal(gpu_device)
MedianFilter.InitResample(DeviceName=gpu_device,GPUBackend=computing_backend['type'])


# Load inputs
input_files = {
Expand Down
3 changes: 2 additions & 1 deletion Tests/Unit/GPU_Functions/test_GPUResample.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
sys.path.append('BabelBrain/GPUResample')
sys.path.append('BabelBrain/GPUFunctions/GPUResample')
sys.path.append('BabelBrain/GPUFunctions')
import logging

import pytest
Expand Down
10 changes: 3 additions & 7 deletions Tests/Unit/GPU_Functions/test_GPUVoxelize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
sys.path.append('BabelBrain/GPUVoxelize')
sys.path.append('BabelBrain/GPUFunctions/GPUVoxelize')
sys.path.append('BabelBrain/GPUFunctions')
import logging

import pytest
Expand All @@ -17,12 +18,7 @@ def test_voxelize(computing_backend,dataset,spatial_step,check_os,get_gpu_device

# Initialize GPU Backend
gpu_device = get_gpu_device()
if computing_backend['type'] == 'OpenCL':
Voxelize.InitOpenCL(gpu_device)
elif computing_backend['type'] == 'CUDA':
Voxelize.InitCUDA(gpu_device)
elif computing_backend['type'] == 'Metal':
Voxelize.InitMetal(gpu_device)
Voxelize.InitVoxelize(DeviceName=gpu_device,GPUBackend=computing_backend['type'])

# Load inputs
input_files = {
Expand Down
28 changes: 19 additions & 9 deletions Tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
config.read('Tests' + os.sep + 'config.ini')
test_data_folder = config['Paths']['data_folder_path']
gpu_device = config['GPU']['device_name']
print('gpu_device',gpu_device)

# PARAMETERS
trajectory_type = {
test_trajectory_type = {
'brainsight': 0,
'slicer': 1
}
Expand Down Expand Up @@ -65,9 +66,9 @@
'yes': 1
}
thermal_profiles = {
'thermal_profile_1': test_data_folder + 'Thermal_Profiles' + os.sep + 'Profile_1.yaml',
'thermal_profile_2': test_data_folder + 'Thermal_Profiles' + os.sep + 'Profile_1.yaml',
'thermal_profile_3': test_data_folder + 'Thermal_Profiles' + os.sep + 'Profile_1.yaml'
'thermal_profile_1': test_data_folder + 'Profiles' + os.sep + 'Thermal_Profile_1.yaml',
'thermal_profile_2': test_data_folder + 'Profiles' + os.sep + 'Thermal_Profile_2.yaml',
'thermal_profile_3': test_data_folder + 'Profiles' + os.sep + 'Thermal_Profile_3.yaml'
}
transducers = [
{'name': 'Single', 'dropdown_index': 0, 'diameter': 0}, # EDIT DIAMETER
Expand Down Expand Up @@ -352,7 +353,7 @@ def get_freq():

def _get_freq(tx):
if tx == 'H317':
freq = '700'
freq = '250'
elif tx == 'BSonix':
freq = '650'
else:
Expand All @@ -362,7 +363,10 @@ def _get_freq(tx):
return _get_freq

@pytest.fixture()
def babelbrain_widget(qtbot,trajectory,transducer,scan_type,dataset,selfiles_widget,get_freq,tmp_path):
def babelbrain_widget(qtbot,trajectory,
trajectory_type,
transducer,
scan_type,dataset,selfiles_widget,get_freq,tmp_path):

# Folder paths
input_folder = dataset['folder_path']
Expand All @@ -377,7 +381,7 @@ def babelbrain_widget(qtbot,trajectory,transducer,scan_type,dataset,selfiles_wid
trajectory_file = trajectory_folder + f"{trajectory}.txt"

# Set SelFiles Parameters
selfiles_widget.ui.TrajectoryTypecomboBox.setCurrentIndex(trajectory_type['slicer'])
selfiles_widget.ui.TrajectoryTypecomboBox.setCurrentIndex(test_trajectory_type[trajectory_type])
selfiles_widget.ui.TrajectorylineEdit.setText(trajectory_file)
selfiles_widget.ui.SimbNIBSTypecomboBox.setCurrentIndex(SimNIBS_type['charm'])
selfiles_widget.ui.SimbNIBSlineEdit.setText(simNIBS_folder)
Expand Down Expand Up @@ -420,9 +424,10 @@ def babelbrain_widget(qtbot,trajectory,transducer,scan_type,dataset,selfiles_wid
bb_widget.Config['CT_or_ZTE_input'] = os.path.join(tmp_path,os.path.basename(bb_widget.Config['CT_or_ZTE_input']))

# Set Sim Parameters
freq = get_freq(transducer)
freq = get_freq(transducer['name'])

freq_index = bb_widget.Widget.USMaskkHzDropDown.findText(freq)

bb_widget.Widget.USMaskkHzDropDown.setCurrentIndex(freq_index)
bb_widget.Widget.USPPWSpinBox.setProperty('UserData',6) # 6 PPW
if scan_type != 'NONE':
Expand Down Expand Up @@ -474,8 +479,13 @@ def pytest_generate_tests(metafunc):

if 'trajectory' in metafunc.fixturenames and 'invalid' in metafunc.function.__name__:
metafunc.parametrize('trajectory', tuple(invalid_trajectories))
elif 'trajectory' in metafunc.fixturenames and 'valid' in metafunc.function.__name__:
elif 'trajectory' in metafunc.fixturenames and ('valid' in metafunc.function.__name__ or
'normal' in metafunc.function.__name__):
metafunc.parametrize('trajectory', tuple(valid_trajectories))


if 'trajectory_type' in metafunc.fixturenames:
metafunc.parametrize('trajectory_type', tuple(test_trajectory_type))

if 'computing_backend' in metafunc.fixturenames:
metafunc.parametrize('computing_backend',tuple(computing_backends),ids=tuple(cb['type'] for cb in computing_backends))
Expand Down
Loading