New test for node group versioning #111800

Merged
Lukas Tönne merged 28 commits from LukasTonne/blender:test_nodegroup_compat into main 2023-09-05 14:27:29 +02:00
Member

This simply loads a blend file and tests that the node group interface
as well as a node group instance have all the expected sockets and
default values.

The test files are attached below temporarily for code review,
these will be uploaded to the svn test files repo in time.

Test case for 2.5: image
Test case for 3.6: image

This simply loads a blend file and tests that the node group interface as well as a node group instance have all the expected sockets and default values. The test files are attached below temporarily for code review, these will be uploaded to the svn test files repo in time. Test case for 2.5: ![image](/attachments/43d56d46-ae61-450d-9dc9-0c0a8d3d81ba) Test case for 3.6: ![image](/attachments/bf0478f2-2b91-4bcb-98d9-b7f733e2f499)
Lukas Tönne added 1 commit 2023-09-01 18:56:02 +02:00
This simply loads a blend file and tests that the node group interface
as well as a node group instance have all the expected sockets and
default values.
Lukas Tönne added 1 commit 2023-09-01 19:00:05 +02:00
Lukas Tönne added 1 commit 2023-09-04 10:23:26 +02:00
Lukas Tönne added 2 commits 2023-09-04 11:19:56 +02:00
Lukas Tönne added 1 commit 2023-09-04 11:26:17 +02:00
Lukas Tönne added 1 commit 2023-09-04 16:32:47 +02:00
Links get broken in 2.5 files but fixing is too complicated. Ignore
links to and from the node group for testing.
Jacques Lucke approved these changes 2023-09-04 16:46:45 +02:00
Jacques Lucke left a comment
Member

Added a few inline comments, but generally looks good to me.

Added a few inline comments, but generally looks good to me.
@ -0,0 +64,4 @@
@property
def idname(self):
global type_info
Member

Is this global really necessary?

Is this `global` really necessary?
Author
Member

No it's not, removed it.

No it's not, removed it.
LukasTonne marked this conversation as resolved
@ -0,0 +90,4 @@
else:
self.assertAlmostEqual(value, expected)
def compare_spec(self, item, node, spec: SocketSpec, test_links=True):
Member

Think the function name can be improved to make it more clear that we are only checking a single socket here. It's not necessarily obvious by looking at the signature.

Think the function name can be improved to make it more clear that we are only checking a single socket here. It's not necessarily obvious by looking at the signature.
Author
Member

changed to

    # Test properties of a node group item and associated node socket with spec data.
    def compare_group_socket_to_spec(self, item, node, spec: SocketSpec, test_links=True):
changed to ```python # Test properties of a node group item and associated node socket with spec data. def compare_group_socket_to_spec(self, item, node, spec: SocketSpec, test_links=True): ```
LukasTonne marked this conversation as resolved
@ -0,0 +93,4 @@
def compare_spec(self, item, node, spec: SocketSpec, test_links=True):
group = item.id_data
# Examine the interface item
Member

End comments with dot.

End comments with dot.
LukasTonne marked this conversation as resolved
@ -0,0 +181,4 @@
class NodeGroupVersioning36Test(AbstractNodeGroupInterfaceTest):
def open_file(self):
bpy.ops.wm.open_mainfile(filepath=str(self.testdir / "nodegroup36.blend"))
Member

I wonder if we can check bpy.data.version to make sure that the file hasn't been saved in a newer version already accidentally.

I wonder if we can check `bpy.data.version` to make sure that the file hasn't been saved in a newer version already accidentally.
Author
Member

Added a test for this, works fine.

Added a test for this, works fine.
LukasTonne marked this conversation as resolved
@ -0,0 +193,4 @@
self.assertEqual(node.node_tree, group, "Node group must use compositor node tree")
# autopep8: off
self.compare_spec( group.interface.ui_items[0], node, SocketSpec( "Output Float", "Output_9", "VALUE", hide_value=True, default_value=3.0, min_value=1.0, max_value=1.0))
Member

Break into multiple lines.

Break into multiple lines.
Author
Member

I find it more readable with a single line per socket and the auto-formatting disabled. Can turn that back on if you feel strongly about it.

After make format:

        self.compare_spec(
            group.interface.ui_items[0], node, SocketSpec(
                "Color", "Color", "RGBA", default_value=(
                    0, 0, 0, 1)), test_links=False)
        self.compare_spec(
            group.interface.ui_items[1], node, SocketSpec(
                "Color", "Color.001", "RGBA", default_value=(
                    0, 0, 0, 1)), test_links=False)
        self.compare_spec(
            group.interface.ui_items[2],
            node,
            SocketSpec(
                "Vector",
                "Vector",
                "VECTOR",
                default_value=(
                    0,
                    0,
                    0),
                min_value=0.0,
                max_value=0.0),
            test_links=False)
        self.compare_spec(
            group.interface.ui_items[3],
            node,
            SocketSpec(
                "Value",
                "Value",
                "VALUE",
                default_value=0.0,
                min_value=0.0,
                max_value=0.0),
            test_links=False)

        self.compare_spec(
            group.interface.ui_items[4],
            node,
            SocketSpec(
                "Fac",
                "Fac",
                "VALUE",
                default_value=0.5,
                min_value=0.0,
                max_value=0.0),
            test_links=False)
I find it more readable with a single line per socket and the auto-formatting disabled. Can turn that back on if you feel strongly about it. After make format: ```python self.compare_spec( group.interface.ui_items[0], node, SocketSpec( "Color", "Color", "RGBA", default_value=( 0, 0, 0, 1)), test_links=False) self.compare_spec( group.interface.ui_items[1], node, SocketSpec( "Color", "Color.001", "RGBA", default_value=( 0, 0, 0, 1)), test_links=False) self.compare_spec( group.interface.ui_items[2], node, SocketSpec( "Vector", "Vector", "VECTOR", default_value=( 0, 0, 0), min_value=0.0, max_value=0.0), test_links=False) self.compare_spec( group.interface.ui_items[3], node, SocketSpec( "Value", "Value", "VALUE", default_value=0.0, min_value=0.0, max_value=0.0), test_links=False) self.compare_spec( group.interface.ui_items[4], node, SocketSpec( "Fac", "Fac", "VALUE", default_value=0.5, min_value=0.0, max_value=0.0), test_links=False) ```
Member

I think just moving the SocketSpec on the next line is good enough as well (so that the long line is approximately split in half). Autoformatting can still be disabled.

I think just moving the `SocketSpec` on the next line is good enough as well (so that the long line is approximately split in half). Autoformatting can still be disabled.
Author
Member

I've realized that i can just put all the specs in a list since i'm testing all the sockets one by one anyway. Nice and compact now.

I've realized that i can just put all the specs in a list since i'm testing all the sockets one by one anyway. Nice and compact now.
LukasTonne marked this conversation as resolved
Lukas Tönne added 2 commits 2023-09-04 17:37:09 +02:00
Lukas Tönne added 12 commits 2023-09-04 17:46:51 +02:00
In 2.6 the old method of using bNodeSocket lists in bNodeTree directly
as group sockets was replaced with new group input/output nodes. This
required versioning to create those input/output nodes and then redirect
links to the new node sockets. Because creating nodes relies heavily on
node typeinfo this versioning was done in the `_after_linking` section
of the 2.6 versioning code, running after _all other versioning_
(including for much newer versions!) has already happended.

While typinfo is available at that point, doing such late versioning
causes severe problems when the data structure changes, as is the case
with the recent node panels patch (#111348). The new node group
interface also has versioning code for 4.0, but this runs _before_ the
`_after_linking` code for 2.6! Versioning for node panels expects
sockets in bNodeTree to not have any links pointing at them, but this is
not true for old 2.6 files which have not yet been fully versioned at
that point, because of the late versioning stage. Subsequently 2.6
`_after_linking` code crashes when trying to modify node links with
dangling pointers.

The solution here is to move the old versioning code out of the
`after_linking` stage to restore the expected versioning chain. This
requires creating nodes and node sockets without any typeinfo, but
luckily we only need to create simple known group input/output nodes
which don't have much complicated behavior.
2.5 versioning would require an after_linking step to construct correct
socket identifiers of node groups, which would preserve links to and
from the group. This has been broken for a long time and cannot be
easily restored. The code is not running anyway because it depends on
outdated bNodeLink format, so its better to just remove entirely.
This function is supposed to only be called once, or the tree topology
will fail on assert. node names are made unique later on already.
CLOG_ERROR aborts in debug mode, which makes all tests fail (in this
case because a nodes modifier does not have a geometry output, which
should just disable it).
Creating nodes relies on socket typeinfo to be valid before node
typeinfo itself.
Added missing 'compact' flag for sockets.
All checks were successful
buildbot/vexp-code-patch-coordinator Build done.
58ea865f09
Also fixed use of an incorrect flag for interface sockets.
Lukas Tönne added 3 commits 2023-09-04 17:52:04 +02:00
Lukas Tönne added 1 commit 2023-09-05 11:58:41 +02:00
Lukas Tönne added 1 commit 2023-09-05 12:15:53 +02:00
Lukas Tönne added 1 commit 2023-09-05 12:38:05 +02:00
Merge branch 'main' into test_nodegroup_compat
Some checks failed
buildbot/vexp-code-patch-coordinator Build done.
abcdbc871f
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne added 1 commit 2023-09-05 13:32:58 +02:00
Merge branch 'main' into test_nodegroup_compat
All checks were successful
buildbot/vexp-code-patch-coordinator Build done.
60a5e6f426
Lukas Tönne changed title from WIP: New test for node group versioning to New test for node group versioning 2023-09-05 13:35:34 +02:00
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne merged commit 851a32adb5 into main 2023-09-05 14:27:26 +02:00
Lukas Tönne deleted branch test_nodegroup_compat 2023-09-05 14:27:28 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#111800
No description provided.