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
13 changes: 13 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[flake8]
max-line-length = 120
max-complexity = 10
select = C,E,F,W,B,B950
ignore = E203,E501,W503,E722,B001,C901
exclude =
.git,
test_*,
__pycache__,
*.egg-info,
.nox,
.pytest_cache,
.mypy_cache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
pytest:
name: pytest
name: Linting, testing, and compliance
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
Expand Down Expand Up @@ -39,10 +39,13 @@ jobs:
run: poetry install
if: steps.cache.outputs.cache-hit != 'true'

- name: Check formatting compliance with black
run: poetry run black --check .

- name: Check PEP8 compliance with flake
run: poetry run flake8

- name: Test with pytest
env:
DJANGO_SETTINGS_MODULE: project.settings
SECRETS_FILE: .confidential/ci.json
run: poetry run pytest --cov redisbench_admin

- name: Upload coverage
Expand Down
56 changes: 55 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "redisbench-admin"
version = "0.1.59"
version = "0.1.60"
description = "Redis benchmark run helper. A wrapper around Redis and Redis Modules benchmark tools ( ftsb_redisearch, memtier_benchmark, redis-benchmark, aibench, etc... )."
authors = ["filipecosta90 <filipecosta.90@gmail.com>"]
readme = "README.md"
Expand Down Expand Up @@ -32,6 +32,7 @@ pytest = "^4.6"
pytest-cov = "^2.9.0"
codecov = "^2.1.4"
black = "^20.8b1"
flake8 = "^3.9.1"

[build-system]
requires = ["poetry>=0.12"]
Expand Down
4 changes: 2 additions & 2 deletions redisbench_admin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def populate_with_poetry_data():


def main():
tool = None
if len(sys.argv) < 2:
print(
"A minimum of 2 arguments is required: redisbench-admin <tool> <arguments>. Use redisbench-admin --help if you need further assistance."
"A minimum of 2 arguments is required: redisbench-admin <tool> <arguments>."
" Use redisbench-admin --help if you need further assistance."
)
sys.exit(1)
requested_tool = sys.argv[1]
Expand Down
3 changes: 2 additions & 1 deletion redisbench_admin/export/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def create_export_arguments(parser):
"--results-format",
type=str,
default="redis-benchmark",
help="results format of the the benchmark results files to read results from ( either memtier_benchmark, redis-benchmark, or ftsb_redisearch )",
help="results format of the the benchmark results files to read "
"results from ( either memtier_benchmark, redis-benchmark, or ftsb_redisearch )",
)
parser.add_argument(
"--use-result",
Expand Down
7 changes: 3 additions & 4 deletions redisbench_admin/export/common/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def split_tags_string(extra_tags):
def split_key_metrics_by_step(key_metrics_specs):
key_metrics_by_step = {}
for key_metric_spec in key_metrics_specs:
step = None
if "step" in key_metric_spec and "metric-name" in key_metric_spec:
step = key_metric_spec["step"]
metric_name = key_metric_spec["metric-name"]
Expand All @@ -66,10 +65,10 @@ def split_key_metrics_by_step(key_metrics_specs):
return key_metrics_by_step


def get_or_none(dict, property):
def get_or_none(dictionary, prop: str):
result = None
if property in dict:
result = dict[property]
if prop in dictionary:
result = dictionary[prop]
return result


Expand Down
13 changes: 3 additions & 10 deletions redisbench_admin/export/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ def export_command_logic(args):
benchmark_files = args.benchmark_result_files
local_path = os.path.abspath(args.local_dir)
results_format = args.results_format
use_result = args.use_result
included_steps = args.steps.split(",")
input_tags_json = args.input_tags_json
start_time_ms = None
extra_tags_array = split_tags_string(args.extra_tags)

if input_tags_json != "":
Expand All @@ -37,13 +34,9 @@ def export_command_logic(args):
benchmark_results = retrieve_local_or_remote_input_json(
benchmark_files, local_path, "--benchmark-result-files", "csv"
)
for filename, benchmark_result in benchmark_results.items():
for _, benchmark_result in benchmark_results.items():
ok, time_series_dict = redis_benchmark_export_logic(
benchmark_result,
extra_tags_array,
results_type,
time_series_dict,
use_result,
benchmark_result, extra_tags_array, results_type, time_series_dict
)

elif results_format == "memtier_benchmark":
Expand All @@ -58,7 +51,7 @@ def export_command_logic(args):
for timeseries_name, time_series in time_series_dict.items():
try:
rts.create(timeseries_name, labels=time_series["tags"])
except redis.exceptions.ResponseError as e:
except redis.exceptions.ResponseError:
# if ts already exists continue
pass
for pos, timestamp in enumerate(time_series["index"]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@
)


def warn_if_tag_none(tagName, tagValue, tool, level="Warning"):
if tagValue is None:
def warn_if_tag_none(tag_name, tag_value, tool, level="Warning"):
if tag_value is None:
print(
'{}! The tag "{}" is None. Given that {} cannot infer it you should pass it via --extra-tags {}=<value>'.format(
level, tagName, tool, tagName
'{}! The tag "{}" is None. Given that {} cannot infer'
" it you should pass it via --extra-tags {}=<value>".format(
level, tag_name, tool, tag_name
)
)


def get_tag_fromextra_tags_array(array, tagName):
def get_tag_fromextra_tags_array(array, tag_name):
result = None
for innerDict in array:
inneResult = get_or_none(innerDict, tagName)
if inneResult is not None:
result = inneResult
for inner_dict in array:
inne_result = get_or_none(inner_dict, tag_name)
if inne_result is not None:
result = inne_result
return result


Expand All @@ -50,7 +51,7 @@ def fill_tags_from_passed_array(extra_tags_array):


def redis_benchmark_export_logic(
benchmark_result, extra_tags_array, results_type, time_series_dict, use_result
benchmark_result, extra_tags_array, results_type, time_series_dict
):
ok = True
start_time_ms = get_tag_fromextra_tags_array(extra_tags_array, "start_time_ms")
Expand All @@ -75,7 +76,6 @@ def redis_benchmark_export_logic(
step,
) = fill_tags_from_passed_array(extra_tags_array)

metrics = {}
col0_row0 = benchmark_result["col_0"][0]
# new format
# "test","rps","avg_latency_ms","min_latency_ms","p50_latency_ms","p95_latency_ms","p99_latency_ms","max_latency_ms"
Expand Down
3 changes: 2 additions & 1 deletion redisbench_admin/extract/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def create_extract_arguments(parser):
"--upload-results-s3",
default=False,
action="store_true",
help="uploads the result files and configuration file to public benchmarks.redislabs bucket. Proper credentials are required",
help="uploads the result files and configuration file to public "
"'benchmarks.redislabs' bucket. Proper credentials are required",
)
parser.add_argument(
"--cluster-mode",
Expand Down
Loading