Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 5 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,14 @@ jobs:
python-version: [3.12]
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 500
- name: Fetch tags required for run-perf version
run: git fetch --tags --depth 500
- uses: actions/setup-python@v2
fetch-depth: 1
fetch-tags: true
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install missing aexpect dependency (remove when https://github.com/avocado-framework/aexpect/pull/81 is merged)
run: pip install six numpy
- run: pip install -r requirements.txt
- run: pip install -e .[dev]
- run: make check

code_coverage:
name: CodeCoverage
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 500
- name: Fetch tags required for run-perf version
run: git fetch --tags --depth 500
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install missing aexpect dependency (remove when https://github.com/avocado-framework/aexpect/pull/81 is merged)
run: pip install six
- run: pip install -r requirements.txt
- run: |
pip install coverage
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
make develop && ./selftests/run_coverage
./cc-test-reporter after-build
env:
CC_TEST_REPORTER_ID: 009b4c0bfafb850daeb66460df98eded574477a064df0b4a75f65752b18b1d01
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ all:
@echo
@echo "Development related targets:"
@echo "check: Executes selftests"
@echo "develop: Runs 'python setup.py --develop' on this tree alone"
@echo "develop: Deploy run-perf editable from this directory"
@echo "clean: Get rid of scratch, byte files and removes the links to other subprojects"
@echo "docs: Build html docs in docs/build/html/ dir"
@echo "html_result: Refresh the docs/source/_static/html_result.html from selftests/.assets/results"
Expand All @@ -25,7 +25,7 @@ coverage: clean develop
./selftests/run_coverage

develop:
$(PYTHON) -m pip install -e .
$(PYTHON) -m pip install -e ".[dev]"

clean:
$(PYTHON) -m pip uninstall -y runperf
Expand All @@ -36,8 +36,8 @@ clean:
docs: develop
make -C docs html

pypi: clean develop
RUNPERF_RELEASE=yes $(PYTHON) setup.py sdist bdist_wheel
pypi: clean
$(PYTHON) -m build
@echo
@echo
@echo "Use 'python3 -m twine upload dist/*'"
Expand Down
12 changes: 2 additions & 10 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import sys
ROOT_PATH = os.path.abspath(os.path.join(os.path.pardir, os.path.pardir))
sys.path.insert(0, ROOT_PATH)
from setup import _get_git_version # pylint: disable=C0413
from runperf.version import __version__ # pylint: disable=C0413

# -- Project information -----------------------------------------------------

Expand All @@ -26,15 +26,7 @@
author = 'Lukáš Doktor'

# The full version, including alpha/beta/rc tags
release = _get_git_version()
if release == '0.0':
# Probably in shallow-cloned git, fetch the latest tag
try:
subprocess.call([shutil.which("git"), "fetch", # nosec
"--depth=500"])
release = _get_git_version()
except subprocess.SubprocessError:
pass
release = __version__

# -- API docs ----------------------------------------------------------------
API_SOURCE_DIR = os.path.join(ROOT_PATH, 'runperf')
Expand Down
91 changes: 91 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
[build-system]
requires = ["setuptools>=64", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "runperf"
description = "Helper to execute perf-beaker-tasks locally or in VM"
readme = "README.rst"
license = "GPL-2.0-or-later"
authors = [
{name = "Lukas Doktor", email = "ldoktor@redhat.com"}
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Natural Language :: English",
"Operating System :: POSIX",
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
"Programming Language :: Python :: 3",
]
requires-python = ">=3.9"
dependencies = [
"aexpect>=1.5.1",
"PyYAML",
"numpy",
]
dynamic = ["version"]

[project.optional-dependencies]
dev = [
"inspektor",
"Sphinx",
"jinja2",
"build",
]

[project.urls]
Homepage = "https://github.com/distributed-system-analysis/run-perf"

[project.entry-points."runperf.profiles"]
"50Localhost" = "runperf.profiles:Localhost"
"50DefaultLibvirt" = "runperf.profiles:DefaultLibvirt"
"50DefaultLibvirtMulti" = "runperf.profiles:DefaultLibvirtMulti"
"50Overcommit1_5" = "runperf.profiles:Overcommit1p5"
"50TunedLibvirt" = "runperf.profiles:TunedLibvirt"

[project.entry-points."runperf.tests"]
"50DummyTest" = "runperf.tests:DummyTest"
"50PBenchFio" = "runperf.tests:PBenchFio"
"50Linpack" = "runperf.tests:Linpack"
"50UPerf" = "runperf.tests:UPerf"
"50PBenchNBD" = "runperf.tests:PBenchNBD"
"50PBenchLibblkio" = "runperf.tests:PBenchLibblkio"

[project.entry-points."runperf.machine.distro_info"]
"50get_distro_info" = "runperf.machine:get_distro_info"

[project.entry-points."runperf.utils.cloud_image_providers"]
"50Fedora" = "runperf.utils.cloud_image_providers:Fedora"

[project.entry-points."runperf.provisioners"]
"50Beaker" = "runperf.provisioners:Beaker"

[project.entry-points."runperf.utils.pbench"]
"50Dnf" = "runperf.utils.pbench:Dnf"

[tool.setuptools.packages.find]
exclude = ["selftests*"]

[project.scripts]
runperf-contrib-path = "runperf.contrib:main"

[tool.setuptools.package-data]
"*" = ["assets/**/*", "contrib/**/*"]

[tool.setuptools]
script-files = [
"scripts/run-perf",
"scripts/analyze-perf",
"scripts/compare-perf",
"scripts/diff-perf",
"scripts/strip-run-perf",
]

[tool.setuptools_scm]
# Version format:
# - Tagged release: X.Y.Z (e.g., 1.2)
# - Development: X.Y.devN+gHASH (e.g., 1.2.dev86+g62d6338)
# - Dirty: X.Y.devN+gHASH.dirty (e.g., 1.2.dev86+g62d6338.dirty)
local_scheme = "dirty-tag"
6 changes: 0 additions & 6 deletions requirements.txt

This file was deleted.

42 changes: 42 additions & 0 deletions runperf/contrib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/env python3
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat Inc. 2024
# Author: Lukas Doktor <ldoktor@redhat.com>

"""Helper to locate contrib scripts directory"""

import os
import sys


def get_contrib_path():
"""
Return the path to the contrib scripts directory.

Works for both editable installs and regular pip installs.
"""
return os.path.join(os.path.dirname(__file__), 'contrib')


def main():
"""Print the path to contrib scripts directory"""
path = get_contrib_path()
if not os.path.isdir(path):
sys.stderr.write(f"Warning: contrib directory not found at {path}\n")
return 1
print(path)
return 0


if __name__ == '__main__':
sys.exit(main())
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions runperf/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import os
import time

from pkg_resources import iter_entry_points as pkg_entry_points
from importlib.metadata import entry_points

from . import utils

Expand Down Expand Up @@ -549,7 +549,7 @@ def _get_image(self, session, setup_script):
self.log.debug("Image %s ready", self._guest["distro"])
return plugin.image
providers = ", ".join(str(_)
for _ in pkg_entry_points(entry_point))
for _ in entry_points(group=entry_point))
raise RuntimeError(f"Fail to fetch {self._guest['distro']} "
f"using {providers} providers")

Expand Down
4 changes: 2 additions & 2 deletions runperf/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import threading
import time
import traceback
import pkg_resources
from importlib.metadata import entry_points

import aexpect

Expand Down Expand Up @@ -544,7 +544,7 @@ def sorted_entry_points(group):

:param group: entry-point group
"""
return sorted(pkg_resources.iter_entry_points(group),
return sorted(entry_points(group=group),
key=lambda ep: ep.name)


Expand Down
54 changes: 9 additions & 45 deletions runperf/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,58 +13,22 @@
# Copyright: Red Hat Inc. 2020
# Author: Lukas Doktor <ldoktor@redhat.com>
"""
The purpose of this implementation is to return the right version for
installed as well as 'make develop' deployments.
"""

import os
import shutil
import subprocess # nosec

import pkg_resources

# Path to setup.py. It only exists when used from sources
SETUP_PATH = os.path.dirname(os.path.dirname(__file__))

Version handling using importlib.metadata.

def _get_git_version():
"""
Get version from git describe
Version is computed from git tags at build/install time by setuptools_scm.
"""

:warning: This implementation must match the "../setup.py" one
"""
curdir = os.getcwd()
try:
os.chdir(SETUP_PATH)
git = shutil.which("git")
version = subprocess.check_output( # nosec
[git, "describe", "--tags",
"HEAD"]).strip().decode("utf-8")
if version.count("-") == 2:
split = version.split('-')
version = f"{split[0]}.{split[1]}+{split[2]}"
else:
version = version.replace("-", ".")
try:
subprocess.check_output([git, "diff", "--quiet"]) # nosec
except subprocess.CalledProcessError:
version += "+dirty"
except (OSError, subprocess.SubprocessError, NameError):
return '0.0'
finally:
os.chdir(curdir)
return version
from importlib.metadata import version, PackageNotFoundError


def get_version():
"""
Attempt to get the version from git or fallback to pkg_resources
Get version from package metadata (set at build time by setuptools_scm).
"""
if os.path.exists(os.path.join(SETUP_PATH, '.git')):
version = _get_git_version()
if version:
return version
return pkg_resources.get_distribution("runperf").version
try:
return version("runperf")
except PackageNotFoundError:
return "0.0.0+unknown"


__version__ = get_version()
23 changes: 9 additions & 14 deletions selftests/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,28 +143,23 @@ def load(self):
plugin.name = self.loaded_name
plugin.plugin = self.name
return plugin
entries = lambda _: [EP("10"), EP("20"), EP("30")]
with mock.patch("runperf.utils.pkg_resources.iter_entry_points",
entries):
entries = lambda group: [EP("10"), EP("20"), EP("30")]
with mock.patch("runperf.utils.entry_points", entries):
self.assertEqual(["10", "20", "30"],
[_.name for _ in utils.sorted_entry_points('')])
entries = lambda _: [EP("20"), EP("30"), EP("10")]
with mock.patch("runperf.utils.pkg_resources.iter_entry_points",
entries):
entries = lambda group: [EP("20"), EP("30"), EP("10")]
with mock.patch("runperf.utils.entry_points", entries):
self.assertEqual(["10", "20", "30"],
[_.name for _ in utils.sorted_entry_points('')])
entries = lambda _: [EP("20", "foo"), EP("30", "foo"), EP("10", "bar")]
with mock.patch("runperf.utils.pkg_resources.iter_entry_points",
entries):
entries = lambda group: [EP("20", "foo"), EP("30", "foo"), EP("10", "bar")]
with mock.patch("runperf.utils.entry_points", entries):
act = utils.named_entry_point("", "foo")
self.assertEqual(("foo", "20"), (act.name, act.plugin))
entries = lambda _: [EP("30", "foo"), EP("20", "foo"), EP("10", "bar")]
with mock.patch("runperf.utils.pkg_resources.iter_entry_points",
entries):
entries = lambda group: [EP("30", "foo"), EP("20", "foo"), EP("10", "bar")]
with mock.patch("runperf.utils.entry_points", entries):
act = utils.named_entry_point("", "foo")
self.assertEqual(("foo", "20"), (act.name, act.plugin))
with mock.patch("runperf.utils.pkg_resources.iter_entry_points",
entries):
with mock.patch("runperf.utils.entry_points", entries):
self.assertRaises(KeyError, utils.named_entry_point, "", "missing")

def test_human_to_bool(self):
Expand Down
Loading
Loading