Skip to content

Commit fd63ea9

Browse files
committed
PEP-8 style cleanup, GPL headers.
1 parent a51dcbc commit fd63ea9

File tree

7 files changed

+106
-4
lines changed

7 files changed

+106
-4
lines changed

MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
include mbdirector/schema/*.json
22
include mbdirector/static/css/*
33
include mbdirector/templates/*.html
4+
include README.md
5+
include COPYING

mbdirector/benchmark.py

+17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
# Copyright (C) 2019 Redis Labs Ltd.
2+
#
3+
# This file is part of mbdirector.
4+
#
5+
# mbdirector is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, version 2.
8+
#
9+
# mbdirector is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with memtier_benchmark. If not, see <http://www.gnu.org/licenses/>.
16+
117
import os.path
218
import subprocess
319
import logging
420

21+
522
class Benchmark(object):
623
def __init__(self, config, **kwargs):
724
self.config = config

mbdirector/main.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# Copyright (C) 2019 Redis Labs Ltd.
2+
#
3+
# This file is part of mbdirector.
4+
#
5+
# mbdirector is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, version 2.
8+
#
9+
# mbdirector is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with memtier_benchmark. If not, see <http://www.gnu.org/licenses/>.
16+
117
"""
218
Main module.
319
"""
@@ -14,6 +30,7 @@
1430
from mbdirector.runner import Runner
1531
from mbdirector.serve import run_webserver
1632

33+
1734
def config_logging(log_filename, loglevel):
1835
formatter = logging.Formatter(
1936
fmt='%(asctime)s %(levelname)s %(message)s')
@@ -29,10 +46,12 @@ def config_logging(log_filename, loglevel):
2946
root_logger.addHandler(file_handler)
3047
root_logger.setLevel(getattr(logging, loglevel.upper()))
3148

49+
3250
@click.group()
3351
def cli():
3452
pass
3553

54+
3655
@cli.command()
3756
@click.option('--spec', '-s', required=True, type=click.File('r'),
3857
help='Benchmark specifications')
@@ -53,7 +72,7 @@ def benchmark(spec, loglevel, skip_benchmarks, skip_targets):
5372
sys.exit(1)
5473

5574
try:
56-
spec_json = json.load(spec)
75+
spec_json = json.load(spec)
5776
except Exception as err:
5877
click.echo('Error: failed to spec: {}: {}'.format(
5978
spec.name, err))
@@ -75,6 +94,7 @@ def benchmark(spec, loglevel, skip_benchmarks, skip_targets):
7594
skip_benchmarks, skip_targets)
7695
_runner.run()
7796

97+
7898
@cli.command()
7999
@click.option('--bind', '-b', required=False, default='127.0.0.1',
80100
help='Address to bind to')

mbdirector/runner.py

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# Copyright (C) 2019 Redis Labs Ltd.
2+
#
3+
# This file is part of mbdirector.
4+
#
5+
# mbdirector is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, version 2.
8+
#
9+
# mbdirector is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with memtier_benchmark. If not, see <http://www.gnu.org/licenses/>.
16+
117
import os
218
import logging
319
import time
@@ -7,6 +23,7 @@
723
from mbdirector.target import Target
824
from mbdirector.benchmark import Benchmark
925

26+
1027
class RunConfig(object):
1128
next_id = 1
1229

mbdirector/serve.py

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
1+
# Copyright (C) 2019 Redis Labs Ltd.
2+
#
3+
# This file is part of mbdirector.
4+
#
5+
# mbdirector is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, version 2.
8+
#
9+
# mbdirector is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with memtier_benchmark. If not, see <http://www.gnu.org/licenses/>.
16+
117
import os.path
218
import json
319

420
from flask import (Flask, render_template, send_file, abort, Response,
521
send_from_directory)
622
from werkzeug.serving import run_simple
723

24+
825
class Config(object):
926
RESULTS_BASEDIR = 'results'
1027

28+
1129
app = Flask(__name__)
1230
app.config.from_object('mbdirector.serve.Config')
1331

32+
1433
class BenchmarkResults(object):
1534
def __init__(self, dirname):
1635
self.dirname = dirname
@@ -41,6 +60,7 @@ def files(self):
4160
if os.path.exists(os.path.join(self.dirname, f))]
4261
return result
4362

63+
4464
class RunResults(object):
4565
OK = 'ok'
4666
NOTFOUND = 'results-not-found'
@@ -130,36 +150,42 @@ def get_run_results():
130150

131151
return [RunResults(d) for d in sorted(dirs)]
132152

153+
133154
@app.route('/')
134155
def index():
135156
return render_template('index.html', results=get_run_results())
136157

158+
137159
@app.route('/run/<run>')
138160
def get_run(run):
139161
return render_template('run.html', run=RunResults(run))
140162

163+
141164
@app.route('/run/<run>/spec')
142165
def get_run_spec(run):
143166
specfile = open(os.path.join(
144167
app.config['RESULTS_BASEDIR'], run, 'spec.json'), 'r')
145168
return send_file(specfile, mimetype='text/plain')
146169

170+
147171
@app.route('/run/<run>/<benchmark>/json')
148172
def get_benchmark_json(run, benchmark):
149173
run = RunResults(run)
150-
if not benchmark in run.benchmarks:
174+
if benchmark not in run.benchmarks:
151175
abort(404)
152176
return Response(run.benchmarks[benchmark].print_json(),
153177
mimetype='text/plan')
154178

179+
155180
@app.route('/run/<run>/<benchmark>/file/<filename>')
156181
def get_benchmark_file(run, benchmark, filename):
157182
run = RunResults(run)
158-
if not benchmark in run.benchmarks:
183+
if benchmark not in run.benchmarks:
159184
abort(404)
160185
return send_from_directory(
161186
os.path.abspath(run.benchmarks[benchmark].dirname),
162187
filename, mimetype='text/plan')
163188

189+
164190
def run_webserver(bind, port):
165191
run_simple(bind, port, app)

mbdirector/target.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# Copyright (C) 2019 Redis Labs Ltd.
2+
#
3+
# This file is part of mbdirector.
4+
#
5+
# mbdirector is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, version 2.
8+
#
9+
# mbdirector is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with memtier_benchmark. If not, see <http://www.gnu.org/licenses/>.
16+
117
"""
218
Setup and tear down test targets.
319
"""
@@ -9,6 +25,7 @@
925

1026
import redis
1127

28+
1229
class Target(object):
1330
"""
1431
Currently hard coded to RedisProcessTarget, but should be extended in
@@ -22,6 +39,7 @@ def from_json(cls, config, json):
2239
"""
2340
return RedisProcessTarget(config, **json)
2441

42+
2543
class RedisProcessTarget(object):
2644
"""
2745
Implements a local Redis process target.
@@ -75,6 +93,7 @@ def _get_conn(self, retries=10, interval=0.1):
7593
time.sleep(interval)
7694
else:
7795
raise
96+
7897
def _ping(self, retries=20, interval=0.2):
7998
while retries:
8099
try:
@@ -84,4 +103,3 @@ def _ping(self, retries=20, interval=0.2):
84103
if not retries:
85104
raise
86105
time.sleep(interval)
87-

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
setup(
33
name='mbdirector',
44
version='0.1.0',
5+
url='https://github.com/RedisLabs/mbdirector',
6+
license='GPL',
57
packages=find_packages(),
68
include_package_data=True,
79
zip_safe=False,

0 commit comments

Comments
 (0)