Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion trellis2/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down