diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml new file mode 100644 index 0000000..ce733eb --- /dev/null +++ b/.github/workflows/github-actions-demo.yml @@ -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]' diff --git a/Tests/Integration/test_integration_step1.py b/Tests/Integration/test_integration_step1.py index 9ab5f9c..708d4f8 100644 --- a/Tests/Integration/test_integration_step1.py +++ b/Tests/Integration/test_integration_step1.py @@ -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": diff --git a/Tests/Unit/GPU_Functions/test_GPUMedianFilter.py b/Tests/Unit/GPU_Functions/test_GPUMedianFilter.py index 6026bed..857e544 100644 --- a/Tests/Unit/GPU_Functions/test_GPUMedianFilter.py +++ b/Tests/Unit/GPU_Functions/test_GPUMedianFilter.py @@ -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 @@ -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 = { diff --git a/Tests/Unit/GPU_Functions/test_GPUResample.py b/Tests/Unit/GPU_Functions/test_GPUResample.py index d365023..24c780d 100644 --- a/Tests/Unit/GPU_Functions/test_GPUResample.py +++ b/Tests/Unit/GPU_Functions/test_GPUResample.py @@ -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 diff --git a/Tests/Unit/GPU_Functions/test_GPUVoxelize.py b/Tests/Unit/GPU_Functions/test_GPUVoxelize.py index 2d74d61..886423e 100644 --- a/Tests/Unit/GPU_Functions/test_GPUVoxelize.py +++ b/Tests/Unit/GPU_Functions/test_GPUVoxelize.py @@ -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 @@ -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 = { diff --git a/Tests/conftest.py b/Tests/conftest.py index dd538c6..bb2121a 100644 --- a/Tests/conftest.py +++ b/Tests/conftest.py @@ -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 } @@ -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 @@ -352,7 +353,7 @@ def get_freq(): def _get_freq(tx): if tx == 'H317': - freq = '700' + freq = '250' elif tx == 'BSonix': freq = '650' else: @@ -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'] @@ -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) @@ -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': @@ -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))