Skip to content

Commit

Permalink
Executor: avoid name clashes with other Python modules
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DylanVanAssche committed Jan 5, 2024
1 parent 7dbe043 commit 5bbd5ec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bench_executor/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 5bbd5ec

Please sign in to comment.