clearml-server/webserver/factory.py
2019-06-11 00:24:35 +03:00

21 lines
458 B
Python

import functools
class Factory:
default_cls = None
registered_cls = None
@classmethod
@functools.lru_cache(maxsize=None)
def get(cls, *args, **kwargs):
return cls.get_class()(*args, **kwargs)
@classmethod
@functools.lru_cache(maxsize=None)
def get_class(cls):
return cls.registered_cls or cls.default_cls
@classmethod
def register(cls, registered_cls):
cls.registered_cls = registered_cls