Skip to content

Commit

Permalink
Leverage import_path from pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaclarke committed Sep 10, 2021
1 parent a71517c commit 669746a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 26 deletions.
27 changes: 2 additions & 25 deletions conbench/util.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import importlib.util
import json
import os
import sys
import time
import urllib.parse

import click
import requests
import yaml
from _pytest.pathlib import import_path
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry

Expand Down Expand Up @@ -70,19 +69,6 @@ def _print_error(self, msg, red=False):

def places_to_look():
current_dir = os.getcwd()

# Handle projects where the envelope is also the package
# (has both a setup.py and an __init__.py).
#
# project
# ├── __init__.py
# ├── benchmarks
# │ ├── __init__.py
# │ └── benchmark_project.py
# ├── requirements.txt
# └── setup.py
sys.path.append(os.path.join(current_dir, ".."))

benchmarks_dir = os.path.join(current_dir, "benchmarks")
if os.path.exists(benchmarks_dir):
return [current_dir, benchmarks_dir]
Expand Down Expand Up @@ -156,13 +142,4 @@ class ExampleBenchmarkList:
or filename.endswith("benchmark.py")
or filename.endswith("benchmarks.py")
):
import_module(directory, filename)


def import_module(directory, filename):
module_name = filename.split(".")[0]
file_path = os.path.join(directory, filename)
spec = importlib.util.spec_from_file_location(module_name, file_path)
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
spec.loader.exec_module(module)
import_path(f"{directory}/{filename}")
1 change: 1 addition & 0 deletions requirements-build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ openapi-spec-validator
psutil
psycopg2
py-cpuinfo
pytest
python-dotenv
PyYAML
requests
Expand Down
1 change: 1 addition & 0 deletions requirements-cli.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
click
psutil
py-cpuinfo
pytest
PyYAML
requests
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="conbench",
version="1.19.0",
version="1.20.0",
description="Continuous Benchmarking (CB) Framework",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 669746a

Please sign in to comment.