From 1c6341e2cf36aa1f1cdf393d688ddd02a8a5022e Mon Sep 17 00:00:00 2001 From: spichardo Date: Sat, 14 Sep 2024 11:09:03 -0600 Subject: [PATCH 01/12] Create github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/github-actions-demo.yml diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml new file mode 100644 index 0000000..0c39b83 --- /dev/null +++ b/.github/workflows/github-actions-demo.yml @@ -0,0 +1,19 @@ +name: GitHub Actions Demo +run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 +on: [push] +runs-on: [self-hosted, macOS, ARM64] +jobs: + Explore-GitHub-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v4 + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: List files in the repository + run: | + ls ${{ github.workspace }} + - run: echo "🍏 This job's status is ${{ job.status }}." From e6574f43705567219ab3c71f3047bc31d69f4711 Mon Sep 17 00:00:00 2001 From: spichardo Date: Sat, 14 Sep 2024 11:21:22 -0600 Subject: [PATCH 02/12] Update github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 0c39b83..79c66d7 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -1,10 +1,11 @@ name: GitHub Actions Demo run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 -on: [push] -runs-on: [self-hosted, macOS, ARM64] +on: + pull_request: + types: [opened, reopened] jobs: Explore-GitHub-Actions: - runs-on: ubuntu-latest + runs-on: [self-hosted, macOS, ARM64] steps: - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" From 96d4ad86175a507e5d607965cf113a7129a4782a Mon Sep 17 00:00:00 2001 From: spichardo Date: Sat, 14 Sep 2024 15:24:50 -0600 Subject: [PATCH 03/12] updating to run simple unit tests for successful execution --- .github/workflows/github-actions-demo.yml | 17 ++++------- Tests/Integration/test_integration_step1.py | 22 ++++++++++++++- .../GPU_Functions/test_GPUMedianFilter.py | 11 +++----- Tests/Unit/GPU_Functions/test_GPUResample.py | 3 +- Tests/Unit/GPU_Functions/test_GPUVoxelize.py | 10 ++----- Tests/conftest.py | 28 +++++++++++++------ 6 files changed, 55 insertions(+), 36 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 79c66d7..b1993a6 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -7,14 +7,9 @@ jobs: Explore-GitHub-Actions: runs-on: [self-hosted, macOS, ARM64] steps: - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - name: Check out repository code - uses: actions/checkout@v4 - - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ github.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." + - uses: actions/checkout@v2 + - name: Activate Conda + -run: | + cd BabelBrain + conda activate BabelBrain + - name: 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)) From 07b7242603d80fa0c0c025cd7bcf42ccad12b603 Mon Sep 17 00:00:00 2001 From: spichardo Date: Sat, 14 Sep 2024 15:37:52 -0600 Subject: [PATCH 04/12] Update github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index b1993a6..2b14ba2 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -12,4 +12,9 @@ jobs: -run: | cd BabelBrain conda activate BabelBrain - - name: + - name: Copy config files + -run: | + cp ~/Documents/BabelBrain/Test/config.ini Test/ + - name: run pytest + -run: | + coverage run -m pytest Tests -k 'test_step1_normal[SDR_0p55-CT-H317-Deep_Target-brainsight]' From 090740d6b8255b1feec403f25491d5bf7baad294 Mon Sep 17 00:00:00 2001 From: spichardo Date: Sat, 14 Sep 2024 15:40:55 -0600 Subject: [PATCH 05/12] Update github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 2b14ba2..99567a2 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -7,7 +7,6 @@ jobs: Explore-GitHub-Actions: runs-on: [self-hosted, macOS, ARM64] steps: - - uses: actions/checkout@v2 - name: Activate Conda -run: | cd BabelBrain From 30f6f9e96239a4df04adec85ecadf59c6de988d7 Mon Sep 17 00:00:00 2001 From: spichardo Date: Sat, 14 Sep 2024 15:45:13 -0600 Subject: [PATCH 06/12] Update github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 99567a2..0eb437e 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -7,13 +7,14 @@ jobs: Explore-GitHub-Actions: runs-on: [self-hosted, macOS, ARM64] steps: + #- uses: actions/checkout@v2 - name: Activate Conda - -run: | + run: | cd BabelBrain conda activate BabelBrain - name: Copy config files - -run: | + run: | cp ~/Documents/BabelBrain/Test/config.ini Test/ - name: run pytest - -run: | + run: | coverage run -m pytest Tests -k 'test_step1_normal[SDR_0p55-CT-H317-Deep_Target-brainsight]' From e6683d135a2d1d6e87fb6b9d151c4be24a6dc1f0 Mon Sep 17 00:00:00 2001 From: spichardo Date: Sat, 14 Sep 2024 16:02:28 -0600 Subject: [PATCH 07/12] Update github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 0eb437e..b22a15f 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -10,11 +10,11 @@ jobs: #- uses: actions/checkout@v2 - name: Activate Conda run: | - cd BabelBrain + /Users/spichardo/miniconda3/etc/profile.d/conda.sh conda activate BabelBrain - name: Copy config files run: | - cp ~/Documents/BabelBrain/Test/config.ini Test/ + cp /Users/spichardo/Documents/BabelBrain/Tests/config.ini Tests/ - name: run pytest run: | coverage run -m pytest Tests -k 'test_step1_normal[SDR_0p55-CT-H317-Deep_Target-brainsight]' From 8cd30c046052b7cd8a5ee77d2b9083f99b4c76ce Mon Sep 17 00:00:00 2001 From: spichardo Date: Sat, 14 Sep 2024 16:28:36 -0600 Subject: [PATCH 08/12] Update github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index b22a15f..701654b 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -10,11 +10,12 @@ jobs: #- uses: actions/checkout@v2 - name: Activate Conda run: | - /Users/spichardo/miniconda3/etc/profile.d/conda.sh - conda activate BabelBrain + conda init + conda env create --name Babel --file=environment_mac_arm64-39.yml + conda activate Babel - name: Copy config files - run: | - cp /Users/spichardo/Documents/BabelBrain/Tests/config.ini Tests/ + #run: | + # cp /Users/spichardo/Documents/BabelBrain/Tests/config.ini Tests/ - name: run pytest run: | coverage run -m pytest Tests -k 'test_step1_normal[SDR_0p55-CT-H317-Deep_Target-brainsight]' From 1539d0164c91b154cf49831abd989fe1f4d5dfc7 Mon Sep 17 00:00:00 2001 From: spichardo Date: Sat, 14 Sep 2024 16:37:55 -0600 Subject: [PATCH 09/12] Update github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 701654b..58d90e4 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -13,7 +13,7 @@ jobs: conda init conda env create --name Babel --file=environment_mac_arm64-39.yml conda activate Babel - - name: Copy config files + #- name: Copy config files #run: | # cp /Users/spichardo/Documents/BabelBrain/Tests/config.ini Tests/ - name: run pytest From 7414c6e7346f2352221e76cb4a13dbf68b639737 Mon Sep 17 00:00:00 2001 From: spichardo Date: Sat, 14 Sep 2024 16:50:32 -0600 Subject: [PATCH 10/12] Update github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 58d90e4..533a76f 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -10,12 +10,10 @@ jobs: #- uses: actions/checkout@v2 - name: Activate Conda run: | - conda init - conda env create --name Babel --file=environment_mac_arm64-39.yml - conda activate Babel - #- name: Copy config files - #run: | - # cp /Users/spichardo/Documents/BabelBrain/Tests/config.ini Tests/ + 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]' From 6c46cfb5ff273f992061f7b0e654ef91a4e5f38c Mon Sep 17 00:00:00 2001 From: spichardo Date: Sat, 14 Sep 2024 16:57:07 -0600 Subject: [PATCH 11/12] Update github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 533a76f..ce733eb 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -6,6 +6,9 @@ on: jobs: Explore-GitHub-Actions: runs-on: [self-hosted, macOS, ARM64] + defaults: + run: + shell: zsh {0} steps: #- uses: actions/checkout@v2 - name: Activate Conda From 2a29b363c272db050cf5bed8fb052b0ff736d316 Mon Sep 17 00:00:00 2001 From: spichardo Date: Sat, 14 Sep 2024 17:04:53 -0600 Subject: [PATCH 12/12] Update github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index ce733eb..322a657 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -13,10 +13,13 @@ jobs: #- uses: actions/checkout@v2 - name: Activate Conda run: | + /Users/spichardo/miniconda3/etc/profile.d/conda.sh conda activate BabelBrain - name: Copy config files run: | cp /Users/spichardo/Public/TempForSim/config.ini Tests/ - name: run pytest run: | + /Users/spichardo/miniconda3/etc/profile.d/conda.sh + conda activate BabelBrain coverage run -m pytest Tests -k 'test_step1_normal[SDR_0p55-CT-H317-Deep_Target-brainsight]'