Delete utils.py
Browse files
utils.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
from .utils import *
|
| 2 |
-
|
| 3 |
-
import importlib
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
def instantiate_from_config(config):
|
| 7 |
-
if not "target" in config:
|
| 8 |
-
raise KeyError("Expected key `target` to instantiate.")
|
| 9 |
-
return get_obj_from_str(config["target"])(**config.get("params", dict()))
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
def get_obj_from_str(string, reload=False):
|
| 13 |
-
module, cls = string.rsplit(".", 1)
|
| 14 |
-
if reload:
|
| 15 |
-
module_imp = importlib.import_module(module)
|
| 16 |
-
importlib.reload(module_imp)
|
| 17 |
-
return getattr(importlib.import_module(module, package=None), cls)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|