Spaces:
Runtime error
Runtime error
File size: 1,130 Bytes
0f079b2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import importlib
__modules__ = {}
def register(name):
def decorator(cls):
if name in __modules__:
raise ValueError(
f"Module {name} already exists! Names of extensions conflict!"
)
else:
__modules__[name] = cls
return cls
return decorator
def find(name):
if name in __modules__:
return __modules__[name]
else:
try:
module_string = ".".join(name.split(".")[:-1])
cls_name = name.split(".")[-1]
module = importlib.import_module(module_string, package=None)
return getattr(module, cls_name)
except Exception as e:
raise ValueError(f"Module {name} not found!")
### grammar sugar for logging utilities ###
import logging
logger = logging.getLogger("pytorch_lightning")
from pytorch_lightning.utilities.rank_zero import (
rank_zero_debug,
rank_zero_info,
rank_zero_only,
)
debug = rank_zero_debug
info = rank_zero_info
@rank_zero_only
def warn(*args, **kwargs):
logger.warn(*args, **kwargs)
from . import data, models, systems
|