From dd7a89ba321e06a08af40aa14b29c5e7bdacbdb0 Mon Sep 17 00:00:00 2001 From: Florian Fischer <florian.fl.fischer@fau.de> Date: Mon, 12 Aug 2019 20:22:53 +0200 Subject: [PATCH] load benchmarks using importlib instead of eval --- bench.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bench.py b/bench.py index eda6988..6360db5 100755 --- a/bench.py +++ b/bench.py @@ -203,7 +203,11 @@ def main(): os.makedirs(bench_res_dir, exist_ok=True) try: - bench = eval(f"importlib.import_module('src.benchmarks.{bench}').{bench}") + bench_module = importlib.import_module(f"src.benchmarks.{bench}") + if not hasattr(bench_module, bench): + continue + + bench = getattr(bench_module, bench) if args.load: bench.load(path=args.load) -- GitLab