Load a class at runtime given a full path. Example of the path: mypkg.mysubpkg.myclass
(path)
| 359 | |
| 360 | |
| 361 | def load_class(path): |
| 362 | """Load a class at runtime given a full path. |
| 363 | |
| 364 | Example of the path: mypkg.mysubpkg.myclass |
| 365 | """ |
| 366 | class_data = path.split(".") |
| 367 | if len(class_data) < 2: |
| 368 | raise ValueError("You need to pass a valid path like mymodule.provider_class") |
| 369 | module_path = ".".join(class_data[:-1]) |
| 370 | class_str = class_data[-1] |
| 371 | module = importlib.import_module(module_path) |
| 372 | return getattr(module, class_str) |
| 373 | |
| 374 | |
| 375 | def get_system_memory( |
searching dependent graphs…