From 3aef130baf6ffedb52fe003a0b3a1e4d81ade768 Mon Sep 17 00:00:00 2001 From: xocialize Date: Thu, 16 Jul 2026 17:24:42 -0700 Subject: [PATCH] pipelines: route from_pretrained's class lookup through the lazy __getattr__ globals()[config['name']] bypasses the module-level lazy loader, so it raises KeyError: 'Trellis2ImageTo3DPipeline' whenever from_pretrained is the first touch of the module (nothing has populated globals() yet). getattr(sys.modules[__name__], ...) hits __getattr__ and triggers the lazy import as intended. Co-Authored-By: Claude Fable 5 --- trellis2/pipelines/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trellis2/pipelines/__init__.py b/trellis2/pipelines/__init__.py index 9bb68352..5a2066ab 100644 --- a/trellis2/pipelines/__init__.py +++ b/trellis2/pipelines/__init__.py @@ -32,6 +32,7 @@ def from_pretrained(path: str): """ import os import json + import sys is_local = os.path.exists(f"{path}/pipeline.json") if is_local: @@ -42,7 +43,9 @@ def from_pretrained(path: str): with open(config_file, 'r') as f: config = json.load(f) - return globals()[config['name']].from_pretrained(path) + # getattr routes through the module's lazy __getattr__; globals() bypasses it and + # raises KeyError when from_pretrained is the first touch of the module. + return getattr(sys.modules[__name__], config['name']).from_pretrained(path) # For PyLance