Python get shader tree in headless mode? I was able to get CompositorNodeTree with this code in headless mode:
scene = bpy.data.scenes['Scene']
print([y.name for y in scene.node_tree.nodes])
print(type(scene.node_tree))

Now how to get ShaderNodeTree?
If I were able to get ShaderNodeTree, I would just do:
shader_tree = get_shader_tree()
image_node = shader_tree.nodes[&quot;Image Texture&quot;]
image_node.image = bpy.data.images[&quot;my_image.png&quot;]

but blender seems to not store shader tree any where in data, how can I do it?

Context:
I want to generate synthetic image dataset of 10 000+ images with different lighting. For lighting I used sun object and set HDRI with image texture connected to background nodes in Shader editor. (Like most of the tutorials suggest).
In order to automate the process of generation, I need to substitude HDRI image in Shader Editor.
Because I don't have powerfull GPU on my PC, generation takes more than a week to render all images. However I have a Ubuntu server with very powerful GPUs, and I want to move rendering process there, here is where the problems come up:
In order to update ShaderNodeTexImage, I need to have access to ShaderNodeTree, but without GUI it's not possible to switch context.area.ui_type to &quot;ShaderNodeTree&quot; because ui_type is not present in headless mode.
I found out that each object has shader node_tree. In order to manipulate HDRI, I need to change Shader Tree of World object.
Shader Tree is attached to World object too, here is how I get Shader Node Tree of world object in headless mode:
bpy.data.worlds['World'].node_tree