From e038c896c61597870ee9070d25d4c664bd27981d Mon Sep 17 00:00:00 2001 From: Frank Loesche Date: Mon, 9 Dec 2024 16:46:32 -0500 Subject: [PATCH 1/8] replicate error in pytest --- navis/meshes/b3d.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/navis/meshes/b3d.py b/navis/meshes/b3d.py index 79bc7879..36fc7254 100644 --- a/navis/meshes/b3d.py +++ b/navis/meshes/b3d.py @@ -37,6 +37,16 @@ def simplify_mesh_blender(x, F, inplace=False): simp Simplified mesh object. + Examples + -------- + >>> import navis + >>> n = navis.example_neurons(1, kind="mesh") + >>> n_sm = simplify_mesh_blender(n, + ... F=0.2, + ... inplace=False) + >>> n.n_vertices > n_sm.n_vertices + True + """ if not tm.interfaces.blender.exists: raise ModuleNotFoundError('No Blender 3D unavailable (executable not found).') From 259be832a0f6cb3d6d4f88bc5630e6ae6880286e Mon Sep 17 00:00:00 2001 From: Frank Loesche Date: Mon, 9 Dec 2024 16:47:05 -0500 Subject: [PATCH 2/8] potential fix for #174 --- .../templates/blender_decimate.py.template | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/navis/meshes/templates/blender_decimate.py.template b/navis/meshes/templates/blender_decimate.py.template index 98541352..8cbaed38 100644 --- a/navis/meshes/templates/blender_decimate.py.template +++ b/navis/meshes/templates/blender_decimate.py.template @@ -5,21 +5,29 @@ import os if __name__ == '__main__': # clear scene of default box bpy.ops.wm.read_homefile() - try: - bpy.ops.object.mode_set(mode='OBJECT') - except BaseException: - pass - bpy.ops.object.select_all(action='SELECT') - bpy.ops.object.delete(use_global=True) + if bpy.app.version > (3, 2, 0): + objs = [bpy.context.scene.objects['Camera'], bpy.context.scene.objects['Cube'], bpy.context.scene.objects['Light']] + with bpy.context.temp_override(selected_objects=objs): + bpy.ops.object.delete() + else: + try: + bpy.ops.object.mode_set(mode='OBJECT') + except BaseException: + pass + bpy.ops.object.select_all(action='SELECT') + bpy.ops.object.delete(use_global=True) # get temporary files from templated locations mesh_pre = $MESH_PRE mesh_post = os.path.abspath(r'$MESH_POST') for filename in mesh_pre: # use data.objects instead of context.scene.objects - bpy.ops.import_mesh.stl(filepath=os.path.abspath(filename)) - + if bpy.app.version > (4, 0, 0): + bpy.ops.wm.stl_import(filepath=os.path.abspath(filename)) + else: + bpy.ops.import_mesh.stl(filepath=os.path.abspath(filename)) mesh = bpy.data.objects[0] + # Make sure mesh is the active object try: # earlier than blender <2.8 @@ -29,6 +37,7 @@ if __name__ == '__main__': bpy.context.view_layer.objects.active = mesh # add decimate modifier + mod = mesh.modifiers.new('decimate', 'DECIMATE') mod.decimate_type = 'COLLAPSE' mod.ratio = $RATIO @@ -36,6 +45,9 @@ if __name__ == '__main__': bpy.ops.object.modifier_apply(modifier=mod.name) - bpy.ops.export_mesh.stl( - filepath=mesh_post, - use_mesh_modifiers=True) + if bpy.app.version > (4, 0, 0): + bpy.ops.wm.stl_export(filepath=mesh_post, apply_modifiers=True) + else: + bpy.ops.export_mesh.stl( + filepath=mesh_post, + use_mesh_modifiers=True) From 94ec009692363e6dc3254e691f803367ef91350c Mon Sep 17 00:00:00 2001 From: Frank Loesche Date: Tue, 10 Dec 2024 16:34:44 -0500 Subject: [PATCH 3/8] Issue 174 ci (#1) * install blender for mesh simplification test --- .github/workflows/test-package.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index d6cc727b..ac3ab4e7 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -29,8 +29,7 @@ jobs: sudo apt-get update -y -qq sudo apt-get install -y libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 \ libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \ - libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 graphviz graphviz-dev \ - mesa-vulkan-drivers + libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 graphviz - name: Install dependencies run: | pip install --upgrade pip @@ -45,6 +44,11 @@ jobs: # if: ${{ matrix.igraph == 'igraph' }} - name: Report dependency versions run: pip freeze -r requirements.txt + - uses: moguri/setup-blender@v1 + with: + blender-version: '4.2.4' + - name: Install Blender + run: blender --version - name: Test uses: coactions/setup-xvfb@v1 with: From b006dc363111874b5eaf469cf710463681b8b829 Mon Sep 17 00:00:00 2001 From: Frank Loesche Date: Tue, 10 Dec 2024 21:14:16 -0500 Subject: [PATCH 4/8] restart CI --- .github/workflows/test-package.yml | 77 ++++++++++++++++-------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index d6cc727b..8af78121 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -15,39 +15,46 @@ jobs: # igraph: ["igraph", "no-igraph"] steps: # This cancels any such job that is still runnning - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.9.1 - with: - access_token: ${{ github.token }} - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install Linux libraries - run: | - sudo apt-get update -y -qq - sudo apt-get install -y libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 \ - libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \ - libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 graphviz graphviz-dev \ - mesa-vulkan-drivers - - name: Install dependencies - run: | - pip install --upgrade pip - pip install zstandard==0.16.0 - pip install numpy - pip install flybrains --no-deps - pip install git+https://github.com/siavashk/pycpd@master - pip install pyarrow - - name: Install navis - run: pip install -e .[dev,all] - # - run: pip install python-igraph - # if: ${{ matrix.igraph == 'igraph' }} - - name: Report dependency versions - run: pip freeze -r requirements.txt - - name: Test - uses: coactions/setup-xvfb@v1 - with: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install Linux libraries run: | - export NAVIS_HEADLESS=TRUE - pytest --verbose + sudo apt-get update -y -qq + sudo apt-get install -y libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 \ + libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \ + libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 graphviz graphviz-dev \ + mesa-vulkan-drivers + - name: Install dependencies + run: | + pip install --upgrade pip + pip install zstandard==0.16.0 + pip install numpy + pip install flybrains --no-deps + pip install git+https://github.com/siavashk/pycpd@master + pip install pyarrow + - name: Set up Blender + run: | + pwd + wget -qO- https://mirrors.iu13.net/blender/release/Blender4.2/blender-4.2.4-linux-x64.tar.xz | tar xJ + export PATH=blender-4.2.4-linux-x64/:$PATH + which blender + blender --version + - name: Install navis + run: pip install -e .[dev,all] + # - run: pip install python-igraph + # if: ${{ matrix.igraph == 'igraph' }} + - name: Report dependency versions + run: pip freeze -r requirements.txt + - name: Test + uses: coactions/setup-xvfb@v1 + with: + run: | + export NAVIS_HEADLESS=TRUE + pytest --verbose From 09c7a154348f50e9e7e4823bbd3ef540d5c129e5 Mon Sep 17 00:00:00 2001 From: Frank Loesche Date: Tue, 10 Dec 2024 21:24:52 -0500 Subject: [PATCH 5/8] reset to original --- .github/workflows/test-package.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 8af78121..45908c30 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -39,13 +39,6 @@ jobs: pip install flybrains --no-deps pip install git+https://github.com/siavashk/pycpd@master pip install pyarrow - - name: Set up Blender - run: | - pwd - wget -qO- https://mirrors.iu13.net/blender/release/Blender4.2/blender-4.2.4-linux-x64.tar.xz | tar xJ - export PATH=blender-4.2.4-linux-x64/:$PATH - which blender - blender --version - name: Install navis run: pip install -e .[dev,all] # - run: pip install python-igraph From 50c552a5143b5b5974c2ecef0f9a6b9a34983e77 Mon Sep 17 00:00:00 2001 From: Frank Loesche Date: Tue, 10 Dec 2024 21:30:30 -0500 Subject: [PATCH 6/8] move blender --- .github/workflows/test-package.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 45908c30..9dd381d8 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -39,6 +39,14 @@ jobs: pip install flybrains --no-deps pip install git+https://github.com/siavashk/pycpd@master pip install pyarrow + - name: Set up Blender + run: | + pwd + wget -qO- https://mirrors.iu13.net/blender/release/Blender4.2/blender-4.2.4-linux-x64.tar.xz | tar xJ + mv blender-4.2.4-linux-x64 ../ + export PATH=../blender-4.2.4-linux-x64/:$PATH + which blender + blender --version - name: Install navis run: pip install -e .[dev,all] # - run: pip install python-igraph From eb96d7e72347aedbe2e5174d7ca9b19ccf36a1a9 Mon Sep 17 00:00:00 2001 From: Frank Loesche Date: Tue, 10 Dec 2024 21:39:40 -0500 Subject: [PATCH 7/8] create symlink --- .github/workflows/test-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 9dd381d8..21b5ff95 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -45,6 +45,7 @@ jobs: wget -qO- https://mirrors.iu13.net/blender/release/Blender4.2/blender-4.2.4-linux-x64.tar.xz | tar xJ mv blender-4.2.4-linux-x64 ../ export PATH=../blender-4.2.4-linux-x64/:$PATH + sudo ln -s ../blender-4.2.4-linux-x64/blender /usr/bin/blender which blender blender --version - name: Install navis From 05a5d6ead9df4609079b65a863e05bca4a0b9bbc Mon Sep 17 00:00:00 2001 From: Frank Loesche Date: Tue, 10 Dec 2024 21:56:11 -0500 Subject: [PATCH 8/8] modify env --- .github/workflows/test-package.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 21b5ff95..00de485a 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -24,6 +24,12 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Set up Blender + run: | + pwd + wget -qO- https://mirrors.iu13.net/blender/release/Blender4.2/blender-4.2.4-linux-x64.tar.xz | tar xJ + mv blender-4.2.4-linux-x64 ../ + echo "PATH=../blender-4.2.4-linux-x64/:$PATH" >> $GITHUB_ENV - name: Install Linux libraries run: | sudo apt-get update -y -qq @@ -39,21 +45,14 @@ jobs: pip install flybrains --no-deps pip install git+https://github.com/siavashk/pycpd@master pip install pyarrow - - name: Set up Blender - run: | - pwd - wget -qO- https://mirrors.iu13.net/blender/release/Blender4.2/blender-4.2.4-linux-x64.tar.xz | tar xJ - mv blender-4.2.4-linux-x64 ../ - export PATH=../blender-4.2.4-linux-x64/:$PATH - sudo ln -s ../blender-4.2.4-linux-x64/blender /usr/bin/blender - which blender - blender --version - name: Install navis run: pip install -e .[dev,all] # - run: pip install python-igraph # if: ${{ matrix.igraph == 'igraph' }} - name: Report dependency versions - run: pip freeze -r requirements.txt + run: | + which blender + pip freeze -r requirements.txt - name: Test uses: coactions/setup-xvfb@v1 with: