Skip to content

Commit

Permalink
Merge pull request #476 from BradyAJohnston/4.1
Browse files Browse the repository at this point in the history
Upgrade for Blender 4.1
  • Loading branch information
BradyAJohnston authored Apr 9, 2024
2 parents ccb6a64 + c527f99 commit e909a1b
Show file tree
Hide file tree
Showing 316 changed files with 47,582 additions and 12,455 deletions.
29 changes: 18 additions & 11 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,30 @@ jobs:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11.7"
cache: pip
- name: Install dependencies
run: |
make template
pip install quartodoc
pip install .

- uses: quarto-dev/quarto-actions/setup@v2
with:
version: "1.4.549"
- name: Build docs
- name: Build docs using blender
run: |
python docs/build_node_docs.py
make docs-build
wget -nv https://download.blender.org/release/Blender4.1/blender-4.1.0-linux-x64.tar.xz
tar -xf blender-4.1.0-linux-x64.tar.xz
blender-4.1.0-linux-x64/blender --version
blender-4.1.0-linux-x64/blender -b --python docs/install.py
blender-4.1.0-linux-x64/blender -b --python docs/build_node_docs.py

- name: Build Docs
run: make docs-build

# push to netlify -------------------------------------------------------

# set release name ----
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/test-addon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Test in Blender

on:
push:
branches: ["main"]
pull_request:
branches: ["main", "4.1"]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
fail-fast: false
matrix:
blender-version: ["4.1"]
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
# os: [macos-13]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11.7

- name: Test in Blender MacOS Intel
if: matrix.os == 'macos-13'
run: |
curl -L -o blender.dmg https://download.blender.org/release/Blender4.1/blender-4.1.0-macos-x64.dmg
hdiutil attach blender.dmg
cp -R /Volumes/Blender/Blender.app /Applications/
hdiutil detach /Volumes/Blender
/Applications/Blender.app/Contents/MacOS/Blender --version
/Applications/Blender.app/Contents/MacOS/Blender -b --python tests/install.py
/Applications/Blender.app/Contents/MacOS/Blender -b --python tests/run.py -- -v
- name: Test in Blender MacOS ARM
if: matrix.os == 'macos-14'
run: |
curl -L -o blender.dmg https://download.blender.org/release/Blender4.1/blender-4.1.0-macos-arm64.dmg
hdiutil attach blender.dmg
cp -R /Volumes/Blender/Blender.app /Applications/
hdiutil detach /Volumes/Blender
/Applications/Blender.app/Contents/MacOS/Blender --version
/Applications/Blender.app/Contents/MacOS/Blender -b --python tests/install.py
/Applications/Blender.app/Contents/MacOS/Blender -b --python tests/run.py -- -v
- name: Test in Blender Windows
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://download.blender.org/release/Blender4.1/blender-4.1.0-windows-x64.zip" -OutFile "blender.zip"
Expand-Archive -Path "blender.zip" -DestinationPath "blender"
.\blender\blender-4.1.0-windows-x64\blender.exe --version
.\blender\blender-4.1.0-windows-x64\blender.exe -b --python tests/install.py
.\blender\blender-4.1.0-windows-x64\blender.exe -b --python tests/run.py -- -v tests/
- name: Test in Blender Linux
if: matrix.os == 'ubuntu-latest'
run: |
wget -nv https://download.blender.org/release/Blender4.1/blender-4.1.0-linux-x64.tar.xz
tar -xf blender-4.1.0-linux-x64.tar.xz
blender-4.1.0-linux-x64/blender --version
blender-4.1.0-linux-x64/blender -b --python tests/install.py
blender-4.1.0-linux-x64/blender -b --python tests/run.py -- -v tests/ --cov=molecularnodes --cov-report=xml:coverage.xml --ignore=molecularnodes/ui/panel.py
- name: Expose coverage as a CI download
uses: actions/upload-artifact@v1
if: matrix.os == 'ubuntu-latest'
with:
name: coverage.xml
path: coverage.xml

- name: Upload coverage reports to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3

19 changes: 9 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ name: test-addon

on:
push:
branches:
- main
branches: ["main"]
pull_request:
branches:
- main
branches: ["main", "4.1"]

jobs:
build:
Expand All @@ -15,15 +13,16 @@ jobs:
max-parallel: 4
fail-fast: false
matrix:
blender-version: ["4.0.0"]
blender-version: ["4.1.0"]
python-version: ['3.11.7']
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: ${{ matrix.python-version }}
cache: 'pip'
- run: pip install bpy==${{ matrix.blender-version }}
# - run: pip install bpy==${{ matrix.blender-version }}
- name: Install
run: |
pip install poetry
Expand All @@ -38,7 +37,7 @@ jobs:
patchelf --set-rpath '$ORIGIN/bpy/lib' pyopenvdb.so
- name: Run Tests
run: poetry run python -m pytest --verbose --cov=molecularnodes --cov-report=xml:coverage.xml --ignore=molecularnodes/ui/panel.py
run: poetry run python -m pytest --verbose --cov=molecularnodes --cov-report=xml:coverage.xml --ignore=molecularnodes/ui/panel.py -k "not star"

- name: Expose coverage as a CI download # Related to test_addon_blender_advanced.py
uses: actions/upload-artifact@v1
Expand Down
20 changes: 20 additions & 0 deletions docs/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import subprocess
import sys
import os


def main():

python = os.path.realpath(sys.executable)

commands = [
f'{python} -m pip install .',
f'{python} -m pip install quartodoc'
]

for command in commands:
subprocess.run(command.split(' '))


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion docs/tutorials/01_importing.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Molecules, simulations and other file formats can all be imported via the `Molec

![The panel location.](images/panel-location.png)

You can download a structure directly from the PDB, just from the accession code. Molecular Nodes will download the file as a `.mmtf` file and cache it locally on your computer, then open the file in to Blender. This is the quickest way to import structures that are already available via the wwPDB. Currently this downloads via the RCSB.
You can download a structure directly from the PDB, just from the accession code. Molecular Nodes will download the file as a `.bcif` file and cache it locally on your computer, then open the file in to Blender. This is the quickest way to import structures that are already available via the wwPDB. Currently this downloads via the RCSB.

To download directly from the PDB, you can use the <kbd>PDB</kbd> tab.

Expand Down
4 changes: 3 additions & 1 deletion molecularnodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ def unregister():
except RuntimeError:
pass


# can't register the add-on when these are uncommnted, but they do fix the issue
# of having to call register() when running a script
# unregister()
# register()


# # register won't be called when MN is run as a module
bpy.app.handlers.load_post.append(_rejuvenate_universe)
bpy.app.handlers.load_post.append(_rehydrate_ensembles)
Expand Down
37 changes: 37 additions & 0 deletions molecularnodes/blender/node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from abc import ABCMeta
from typing import Optional, Any
import warnings
import time
import numpy as np
import bpy


class Node(metaclass=ABCMeta):
def __init__(self, node: bpy.types.Node, chain=[]):

self.node = node
self.group = node.id_data
self.chain = chain

@property
def location(self):
return np.array(self.node.location)

def new(self, name):
"Add a new node to the node group."
try:
return self.group.nodes.new(f'GeometryNode{name}')
except RuntimeError:
return self.group.nodes.new(f'ShaderNode{name}')

def link(self, name, linkto=0, linkfrom=0):
"Create a new node along in the chain and create a link to it. Return the new node."
new_node = self.new(name)
new_node.location = self.location + np.array((200, 0))

self.group.links.new(
self.node.outputs[linkfrom],
new_node.inputs[linkto]
)

return Node(new_node, chain=self.chain + [self])
Loading

0 comments on commit e909a1b

Please sign in to comment.