Belle II Software development
__init__.py
12"""
13This package encapsulates different PXD background generator models.
14"""
15
16from importlib import import_module
17from typing import Callable, Type
18
19
20
31def _get_model_cls(model: str) -> Type:
32 cls = None
33 try:
34 cls = import_module(f".{model}", __name__).Model
35 except AttributeError as exc:
36 exc.msg = f"please define a model class for {model!r}"
37 raise
38 except ModuleNotFoundError as exc:
39 exc.msg = f"the selected model {model!r} is not implemented"
40 raise
41 return cls
42
43
44
55def _get_generate_func(model: str) -> Callable:
56 func = None
57 try:
58 func = import_module(f".{model}", __name__).generate
59 except AttributeError as exc:
60 exc.msg = f"please define the generation function for {model!r}"
61 raise
62 except ModuleNotFoundError as exc:
63 exc.msg = f"the selected model {model!r} is not implemented"
64 raise
65 return func
66
67
68
86MODELS = (
87 "convnet",
88 "resnet",
89 "ieagan"
90)