From 9c43880da987e1c7bc03348928603f4aecec572a Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 26 Feb 2020 10:34:42 -0500 Subject: [PATCH 1/8] FIX: Remove force render --- surfer/viz.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/surfer/viz.py b/surfer/viz.py index df6763b..935b0f8 100644 --- a/surfer/viz.py +++ b/surfer/viz.py @@ -2296,6 +2296,9 @@ def hide_colorbar(self, row=-1, col=-1): def close(self): """Close all figures and cleanup data structure.""" + self._close() + + def _close(self, force_render=True): for ri, ff in enumerate(self._figures): for ci, f in enumerate(ff): if f is not None: @@ -2305,7 +2308,8 @@ def close(self): pass self._figures[ri][ci] = None - _force_render([]) + if force_render: + _force_render([]) # should we tear down other variables? if getattr(self, '_v', None) is not None: @@ -2316,7 +2320,8 @@ def close(self): self._v = None def __del__(self): - self.close() + # Forcing the GUI updates during GC seems to be problematic + self.close(force_render=False) ########################################################################### # SAVING OUTPUT From 38db2038b8de9c0fdc33cc511b81f8885391e28d Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 26 Feb 2020 11:10:55 -0500 Subject: [PATCH 2/8] ENH: Azure --- azure-pipelines.yml | 65 +++++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index aa91291..cc162c3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,19 +1,50 @@ -# Starter pipeline -# Start with a minimal pipeline that you can customize to build and deploy your code. -# Add steps that build, run tests, deploy, and more: -# https://aka.ms/yaml - trigger: -- master - -pool: - vmImage: 'ubuntu-latest' - -steps: -- script: echo Hello, world! - displayName: 'Run a one-line script' + # start a new build for every push + batch: False + branches: + include: + - master -- script: | - echo Add other tasks to build, test, and deploy your project. - echo See https://aka.ms/yaml - displayName: 'Run a multi-line script' +jobs: +- job: Windows + pool: + vmIMage: 'VS2017-Win2016' + strategy: + maxParallel: 4 + matrix: + Python37-64bit: + PYTHON_VERSION: '3.7' + PYTHON_ARCH: 'x64' + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: $(PYTHON_VERSION) + architecture: $(PYTHON_ARCH) + addToPath: true + - powershell: | + pip install numpy scipy matplotlib nose pillow pytest pytest-cov pytest-faulthandler coverage imageio imageio-ffmpeg codecov pyqt5==5.9 + pip install traits traitsui pyface vtk mayavi nibabel + displayName: 'Install pip dependencies' + - powershell: | + powershell make/get_fsaverage.ps1 + $env:SUBJECTS_DIR = '$(System.DefaultWorkingDirectory)' + '\subjects' + Write-Host ("##vso[task.setvariable variable=PATH]" + $env:PATH) SET SUBJECTS_DIR=%CD%\\subjects" + displayName: 'Get fsaverage' + - powershell: | + git clone --depth 1 git://github.com/pyvista/gl-ci-helpers.git + powershell gl-ci-helpers/appveyor/install_opengl.ps1 + displayName: 'Get OpenGL' + - script: python setup.py develop + displayName: 'Install' + - script: pytest surfer --cov=surfer -v + displayName: 'Run tests' + - script: codecov --root %BUILD_REPOSITORY_LOCALPATH% -t %CODECOV_TOKEN% + displayName: 'Codecov' + env: + CODECOV_TOKEN: $(CODECOV_TOKEN) + condition: always() + - task: PublishTestResults@2 + inputs: + testResultsFiles: 'junit-*.xml' + testRunTitle: 'Publish test results for Python $(python.version)' + condition: always() From b7f25dba1fe53a1417a4722c4f87d0fc76ffd38c Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 26 Feb 2020 11:15:37 -0500 Subject: [PATCH 3/8] FIX: Missed --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cc162c3..a4b0840 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -28,7 +28,7 @@ jobs: - powershell: | powershell make/get_fsaverage.ps1 $env:SUBJECTS_DIR = '$(System.DefaultWorkingDirectory)' + '\subjects' - Write-Host ("##vso[task.setvariable variable=PATH]" + $env:PATH) SET SUBJECTS_DIR=%CD%\\subjects" + Write-Host ("##vso[task.setvariable variable=PATH]" + $env:PATH) displayName: 'Get fsaverage' - powershell: | git clone --depth 1 git://github.com/pyvista/gl-ci-helpers.git From 963c9b655704bb0257f95836d90e034a441068d2 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 26 Feb 2020 11:22:12 -0500 Subject: [PATCH 4/8] FIX: Missed again --- azure-pipelines.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a4b0840..1b25558 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,6 +7,8 @@ trigger: jobs: - job: Windows + variables: + PIP_CACHE_FOLDER: $(Pipeline.Workspace)/.cache/pip pool: vmIMage: 'VS2017-Win2016' strategy: @@ -21,14 +23,19 @@ jobs: versionSpec: $(PYTHON_VERSION) architecture: $(PYTHON_ARCH) addToPath: true +- task: Cache@2 + inputs: + key: 'python -VV' + path: $(PIP_CACHE_FOLDER) + displayName: Cache pip packages - powershell: | - pip install numpy scipy matplotlib nose pillow pytest pytest-cov pytest-faulthandler coverage imageio imageio-ffmpeg codecov pyqt5==5.9 - pip install traits traitsui pyface vtk mayavi nibabel + pip install numpy scipy matplotlib nose pillow pytest pytest-cov pytest-faulthandler coverage imageio imageio-ffmpeg codecov pyqt5==5.9 --cache-dir $(PIP_CACHE_FOLDER) + pip install traits traitsui pyface vtk mayavi nibabel --cache-dir $(PIP_CACHE_FOLDER) displayName: 'Install pip dependencies' - powershell: | powershell make/get_fsaverage.ps1 $env:SUBJECTS_DIR = '$(System.DefaultWorkingDirectory)' + '\subjects' - Write-Host ("##vso[task.setvariable variable=PATH]" + $env:PATH) + Write-Host ("##vso[task.setvariable variable=SUBJECTS_DIR]" + $env:SUBJECTS_DIR) displayName: 'Get fsaverage' - powershell: | git clone --depth 1 git://github.com/pyvista/gl-ci-helpers.git From b3522d472f87a3dfa86396c25d1b022a81d3d2d8 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 26 Feb 2020 11:29:01 -0500 Subject: [PATCH 5/8] FIX: Try again --- azure-pipelines.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1b25558..7d98a8e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,11 +23,11 @@ jobs: versionSpec: $(PYTHON_VERSION) architecture: $(PYTHON_ARCH) addToPath: true -- task: Cache@2 - inputs: - key: 'python -VV' - path: $(PIP_CACHE_FOLDER) - displayName: Cache pip packages + - task: Cache@2 + inputs: + key: 'pip' + path: $(PIP_CACHE_FOLDER) + displayName: Cache pip packages - powershell: | pip install numpy scipy matplotlib nose pillow pytest pytest-cov pytest-faulthandler coverage imageio imageio-ffmpeg codecov pyqt5==5.9 --cache-dir $(PIP_CACHE_FOLDER) pip install traits traitsui pyface vtk mayavi nibabel --cache-dir $(PIP_CACHE_FOLDER) From 11afc4ae48623d9ff04872ba573f892dd4d7a831 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 26 Feb 2020 11:49:21 -0500 Subject: [PATCH 6/8] FIX: Wrong call --- surfer/viz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfer/viz.py b/surfer/viz.py index 935b0f8..8df843c 100644 --- a/surfer/viz.py +++ b/surfer/viz.py @@ -2321,7 +2321,7 @@ def _close(self, force_render=True): def __del__(self): # Forcing the GUI updates during GC seems to be problematic - self.close(force_render=False) + self._close(force_render=False) ########################################################################### # SAVING OUTPUT From 283a5800228176c80bec1a83f1b7d80229e8a9b0 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 26 Feb 2020 11:56:55 -0500 Subject: [PATCH 7/8] FIX: Explicit close/del --- surfer/tests/test_viz.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/surfer/tests/test_viz.py b/surfer/tests/test_viz.py index 206d1f2..ac96fe2 100644 --- a/surfer/tests/test_viz.py +++ b/surfer/tests/test_viz.py @@ -1,3 +1,4 @@ +import gc import os import os.path as op from os.path import join as pjoin @@ -210,6 +211,17 @@ def test_data(): brain.close() +@requires_fsaverage() +def test_close(): + """Test that close and del actually work.""" + _set_backend() + brain = Brain('fsaverage', 'both', 'inflated') + brain.close() + brain.__del__() + del brain + gc.collect() + + @requires_fsaverage() def test_data_limits(): """Test handling of data limits.""" From ce7ac2dbcd290765fbb1ca80981faded3a48f20c Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 27 Feb 2020 11:26:34 -0500 Subject: [PATCH 8/8] FIX: Safer del --- surfer/viz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surfer/viz.py b/surfer/viz.py index 8df843c..b6579c9 100644 --- a/surfer/viz.py +++ b/surfer/viz.py @@ -2299,7 +2299,7 @@ def close(self): self._close() def _close(self, force_render=True): - for ri, ff in enumerate(self._figures): + for ri, ff in enumerate(getattr(self, '_figures', [])): for ci, f in enumerate(ff): if f is not None: try: