From 5bbd5ec2f09c3edeca8e3184e440d45f4fe771d7 Mon Sep 17 00:00:00 2001 From: Dylan Van Assche Date: Fri, 5 Jan 2024 12:44:18 +0100 Subject: [PATCH] Executor: avoid name clashes with other Python modules Include the parent module name so we always import the Python modules from our tool instead of system-wide installed Python modules from PyPi. For example: mysql clashes. --- bench_executor/executor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bench_executor/executor.py b/bench_executor/executor.py index b4d23e1..8add547 100644 --- a/bench_executor/executor.py +++ b/bench_executor/executor.py @@ -94,7 +94,10 @@ def _init_resources(self) -> None: # Discover all classes in each module for m in self._modules: module_name = os.path.splitext(m)[0] - imported_module = importlib.import_module(module_name) + parent_module = os.path.split(os.path.dirname(__file__))[-1] + import_name = '.'.join([parent_module, module_name]) + print(import_name) + imported_module = importlib.import_module(import_name) for name, cls in inspect.getmembers(imported_module, inspect.isclass): if name.startswith('_') or name[0].islower():