bpy.data.libraries.load does not return the right thing (Geometry Nodes, Collections, Shader nodes are fine) #94338

Closed
opened 2021-12-23 05:15:55 +01:00 by yonghao lv · 13 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 750 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 456.71

Blender Version
Broken: version: 3.1.0 Alpha, branch: master, commit date: 2021-12-23 00:38, hash: 1931387799
Worked: 3.0

Caused by 0704570721

Short description of error
When appending node group with libraries.load, it didn't return a right node group in at the first time

Target node group: General MS 1.0
Get node groups in with: ['General MS 1.0']
Get node groups out with: [bpy.data.node_groups['adjt_switch_geo']]
Return node group <bpy_struct, GeometryNodeTree("adjt_switch_geo") at 0x000001C760C1D608>

Exact steps for others to reproduce the error
Use this script to import a node group, it return the wrong node group in the first time

    def get_preset(dir_name, file_name, node_group_name):
        base_dir = os.path.join(bpy.utils.user_resource('SCRIPTS'), 'addons', __folder_name__, 'preset',
                                dir_name, file_name)

        if node_group_name in bpy.data.node_groups:
            preset_node = bpy.data.node_groups[node_group_name]
        else:
            with bpy.data.libraries.load(base_dir, link=False) as (data_from, data_to):
                data_to.node_groups = [name for name in data_from.node_groups if name == node_group_name]

                print('Target node group:',node_group_name)
                print('Get node groups in with:',data_to.node_groups)
            print('Get node groups out with:',data_to.node_groups)

            preset_node = data_to.node_groups[0]
            print('Return node group',preset_node)

        return preset_node

Shader nodes are fine apparently:

#94338.zip

  • extract .zip somewhere
  • Open #94338.blend
  • run script

expected output:

Target node group: PricipledBSDF_wrapped
Get node groups in with: ['PricipledBSDF_wrapped']
Get node groups out with: [bpy.data.node_groups['PricipledBSDF_wrapped']]
Return node group <bpy_struct, ShaderNodeTree("PricipledBSDF_wrapped") at 0x7faef0b4d008>

Geo nodes are not:
T94338_geo.zip

Target node group: Geo Top Group
Get node groups in with: ['Geo Top Group']
Get node groups out with: [bpy.data.node_groups['Geo In Group']]
Return node group <bpy_struct, GeometryNodeTree("Geo In Group") at 0x000001AA21807008>

Collections dont work as well:
T94338_collections.zip

Target collection: foo
Get collections in with: ['foo']
Get collections out with: [bpy.data.collections['bar.001']]
Return collection <bpy_struct, Collection("bar.001") at 0x7fe7a43d8ec8>
**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce GTX 750 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 456.71 **Blender Version** Broken: version: 3.1.0 Alpha, branch: master, commit date: 2021-12-23 00:38, hash: `1931387799` Worked: 3.0 Caused by 0704570721 **Short description of error** When appending node group with libraries.load, it didn't return a right node group in at the first time ``` Target node group: General MS 1.0 Get node groups in with: ['General MS 1.0'] Get node groups out with: [bpy.data.node_groups['adjt_switch_geo']] Return node group <bpy_struct, GeometryNodeTree("adjt_switch_geo") at 0x000001C760C1D608> ``` **Exact steps for others to reproduce the error** Use this script to import a node group, it return the wrong node group in the first time ``` def get_preset(dir_name, file_name, node_group_name): base_dir = os.path.join(bpy.utils.user_resource('SCRIPTS'), 'addons', __folder_name__, 'preset', dir_name, file_name) if node_group_name in bpy.data.node_groups: preset_node = bpy.data.node_groups[node_group_name] else: with bpy.data.libraries.load(base_dir, link=False) as (data_from, data_to): data_to.node_groups = [name for name in data_from.node_groups if name == node_group_name] print('Target node group:',node_group_name) print('Get node groups in with:',data_to.node_groups) print('Get node groups out with:',data_to.node_groups) preset_node = data_to.node_groups[0] print('Return node group',preset_node) return preset_node ``` Shader nodes are fine apparently: [#94338.zip](https://archive.blender.org/developer/F12773098/T94338.zip) - extract .zip somewhere - Open `#94338.blend` - run script expected output: ``` Target node group: PricipledBSDF_wrapped Get node groups in with: ['PricipledBSDF_wrapped'] Get node groups out with: [bpy.data.node_groups['PricipledBSDF_wrapped']] Return node group <bpy_struct, ShaderNodeTree("PricipledBSDF_wrapped") at 0x7faef0b4d008> ``` Geo nodes are not: [T94338_geo.zip](https://archive.blender.org/developer/F12773239/T94338_geo.zip) ``` Target node group: Geo Top Group Get node groups in with: ['Geo Top Group'] Get node groups out with: [bpy.data.node_groups['Geo In Group']] Return node group <bpy_struct, GeometryNodeTree("Geo In Group") at 0x000001AA21807008> ``` Collections dont work as well: [T94338_collections.zip](https://archive.blender.org/developer/F12805109/T94338_collections.zip) ``` Target collection: foo Get collections in with: ['foo'] Get collections out with: [bpy.data.collections['bar.001']] Return collection <bpy_struct, Collection("bar.001") at 0x7fe7a43d8ec8> ```
Author

Added subscriber: @1029910278

Added subscriber: @1029910278

#94825 was marked as duplicate of this issue

#94825 was marked as duplicate of this issue
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

Cannot reproduce in 00965c98cb.

Here is my test scenario:
#94338.zip

  • extract .zip somewhere
  • Open #94338.blend
  • run script

expected output:

Target node group: PricipledBSDF_wrapped
Get node groups in with: ['PricipledBSDF_wrapped']
Get node groups out with: [bpy.data.node_groups['PricipledBSDF_wrapped']]
Return node group <bpy_struct, ShaderNodeTree("PricipledBSDF_wrapped") at 0x7faef0b4d008>

Is this not working for you?
If so (and you have another scenario that is not working, please upload an equivalent example to mine - where you just have to open a file and execute the script).

Cannot reproduce in 00965c98cb. Here is my test scenario: [#94338.zip](https://archive.blender.org/developer/F12773098/T94338.zip) - extract .zip somewhere - Open `#94338.blend` - run script expected output: ``` Target node group: PricipledBSDF_wrapped Get node groups in with: ['PricipledBSDF_wrapped'] Get node groups out with: [bpy.data.node_groups['PricipledBSDF_wrapped']] Return node group <bpy_struct, ShaderNodeTree("PricipledBSDF_wrapped") at 0x7faef0b4d008> ``` Is this not working for you? If so (and you have another scenario that is not working, please upload an equivalent example to mine - where you just have to open a file and execute the script).
Author

I just try it with the geo nodes( Which work very similar like the example)
Please check the example T94338_geo.zip

1640272681(1).png

Target node group: Geo Top Group
Get node groups in with: ['Geo Top Group']
Get node groups out with: [bpy.data.node_groups['Geo In Group']]
Return node group <bpy_struct, GeometryNodeTree("Geo In Group") at 0x000001AA21807008>
I just try it with the geo nodes( Which work very similar like the example) Please check the example [T94338_geo.zip](https://archive.blender.org/developer/F12773239/T94338_geo.zip) ![1640272681(1).png](https://archive.blender.org/developer/F12773240/1640272681_1_.png) ``` Target node group: Geo Top Group Get node groups in with: ['Geo Top Group'] Get node groups out with: [bpy.data.node_groups['Geo In Group']] Return node group <bpy_struct, GeometryNodeTree("Geo In Group") at 0x000001AA21807008> ```
Member

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

OK, can confirm now.

OK, can confirm now.
Philipp Oeser changed title from bpy.data.libraries.load did not return a right node group to Geometry Nodes: bpy.data.libraries.load did not return a right node group (shader nodes are fine) 2021-12-28 15:12:27 +01:00
Member

Added subscriber: @mont29

Added subscriber: @mont29
Member

Caused by 0704570721.

Will set to High prio since this is a regression and the culprit commit has been identified.

@mont29: mind checking?

Caused by 0704570721. Will set to High prio since this is a regression and the culprit commit has been identified. @mont29: mind checking?
Philipp Oeser changed title from Geometry Nodes: bpy.data.libraries.load did not return a right node group (shader nodes are fine) to bpy.data.libraries.load does not return the right thing (Geometry Nodes, Collections, Shader nodes are fine) 2022-01-14 12:08:57 +01:00
Bastien Montagne self-assigned this 2022-01-14 17:14:20 +01:00

This issue was referenced by 7abdd82dfd

This issue was referenced by 7abdd82dfdad893957e8550c15f9557253971d7d

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
4 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#94338
No description provided.