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
6 changes: 5 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ jobs:
- bash: yarn
displayName: 'Install Deps'

- bash: python -m pip install "black==20.8b1" flake8-black
condition: and(succeeded(), ne(variables['python.version'], '2.7'))
displayName: 'Install Python deps'

- bash: yarn build_python --ci $(python_flag) $(manylinux_flag)
displayName: 'build'
env:
Expand Down Expand Up @@ -248,7 +252,7 @@ jobs:
displayName: "Which python"

- script: |
python -m pip install delocate wheel numpy "pyarrow>=0.16.0,<1"
python -m pip install delocate wheel numpy "black==20.8b1" flake8-black "pyarrow>=0.16.0,<1"
displayName: "Python deps"

- script: npm install -g yarn
Expand Down
8 changes: 4 additions & 4 deletions docker/python/manylinux2010/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ RUN cp -arf /opt/python/cp38-cp38/* /usr/local/
ENV PATH=/usr/local/bin:$PATH

# Install dependencies
RUN python2.7 -m pip install numpy scipy pybind11 cython codecov mock flake8 pytest pytest-cov traitlets ipywidgets faker psutil
RUN python3.6 -m pip install numpy scipy pybind11 cython codecov mock flake8 pytest pytest-cov traitlets ipywidgets faker psutil
RUN python3.7 -m pip install numpy scipy pybind11 cython codecov mock flake8 pytest pytest-cov traitlets ipywidgets faker psutil
RUN python3.8 -m pip install numpy scipy pybind11 cython codecov mock flake8 pytest pytest-cov traitlets ipywidgets faker psutil
RUN python2.7 -m pip install numpy scipy pybind11 cython codecov mock pytest pytest-cov traitlets ipywidgets faker psutil
RUN python3.6 -m pip install numpy scipy pybind11 cython codecov mock black>=20 flake8-black pytest pytest-cov traitlets ipywidgets faker psutil
RUN python3.7 -m pip install numpy scipy pybind11 cython codecov mock black>=20 flake8-black pytest pytest-cov traitlets ipywidgets faker psutil
RUN python3.8 -m pip install numpy scipy pybind11 cython codecov mock black>=20 flake8-black pytest pytest-cov traitlets ipywidgets faker psutil

# Install Auditwheel - not available on Python 2
RUN python3.6 -m pip install --ignore-installed auditwheel
Expand Down
6 changes: 3 additions & 3 deletions docker/python/manylinux2014/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ RUN cp -arf /opt/python/cp38-cp38/* /usr/local/
ENV PATH=/usr/local/bin:$PATH

# Install dependencies
RUN python3.6 -m pip install numpy scipy pybind11 cython codecov mock flake8 pytest pytest-cov traitlets ipywidgets faker psutil
RUN python3.7 -m pip install numpy scipy pybind11 cython codecov mock flake8 pytest pytest-cov traitlets ipywidgets faker psutil
RUN python3.8 -m pip install numpy scipy pybind11 cython codecov mock flake8 pytest pytest-cov traitlets ipywidgets faker psutil
RUN python3.6 -m pip install numpy scipy pybind11 cython codecov mock "black==20.8b1" flake8-black pytest pytest-cov traitlets ipywidgets faker psutil
RUN python3.7 -m pip install numpy scipy pybind11 cython codecov mock "black==20.8b1" flake8-black pytest pytest-cov traitlets ipywidgets faker psutil
RUN python3.8 -m pip install numpy scipy pybind11 cython codecov mock "black==20.8b1" flake8-black pytest pytest-cov traitlets ipywidgets faker psutil

# Install Auditwheel - not available on Python 2
RUN python3.6 -m pip install --ignore-installed auditwheel
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,17 @@
"clean": "node scripts/clean.js",
"start": "lerna run start --stream --scope",
"precommit": "npm run lint",
"lint": "npm-run-all lint:* lint_python",
"lint": "npm-run-all lint:*",
"lint:eslint": "eslint \"packages/*/src/**/*.js\" \"packages/*/test/**/*.js\" \"examples/*/*.js\"",
"lint_:tslint": "eslint \"packages/*/src/**/*.ts\" \"packages/*/test/**/*.ts\" \"examples/*/*.ts\"",
"lint_python": "node scripts/lint_python.js",
"lint:python": "node scripts/lint_python.js",
"fix:es": "npm run lint:eslint -- --fix",
"fix:md": "prettier docs/md/*.md --prose-wrap=always --write",
"fix:cpp": "node scripts/fix_cpp.js",
"fix:less": "prettier --tab-width 4 --write packages/**/src/less/*.less",
"fix:html": "html-beautify packages/**/src/html/*.html -r",
"fix:json": "prettier --tab-width 4 --write **/package.json",
"fix_python": "node scripts/lint_python.js --fix",
"fix:python": "node scripts/lint_python.js --fix",
"fix": "npm-run-all --silent fix:*",
"toggle_puppeteer": "node scripts/toggle_puppeteer.js",
"version": "python3 python/perspective/scripts/write_version.py && git add python/perspective/perspective/core/_version.py"
Expand Down
2 changes: 1 addition & 1 deletion python/perspective/bench/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

from bench import Benchmark, Suite, Runner

__all__ = ["Benchmark", "Suite", "Runner"]
__all__ = ["Benchmark", "Suite", "Runner"]
69 changes: 40 additions & 29 deletions python/perspective/bench/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
import tornado
from datetime import datetime
from timeit import timeit
sys.path.insert(1, os.path.join(os.path.dirname(__file__), '..'))
from perspective import Table, PerspectiveManager, PerspectiveTornadoHandler # noqa: E402

sys.path.insert(1, os.path.join(os.path.dirname(__file__), ".."))
from perspective import (
Table,
PerspectiveManager,
PerspectiveTornadoHandler,
) # noqa: E402

logging.basicConfig(level=logging.INFO)

Expand All @@ -36,27 +41,26 @@ def virtualenv_exists(self):

def activate_virtualenv(self):
"""Activates the virtualenv at `VIRTUALENV_PATH`."""
logging.info(
"Activating virtualenv at: `{}`".format(self._virtualenv_path))
logging.info("Activating virtualenv at: `{}`".format(self._virtualenv_path))
subprocess.check_output(
"source {}/bin/activate".format(self._virtualenv_path),
shell=True)
"source {}/bin/activate".format(self._virtualenv_path), shell=True
)
self._is_activated = True

def create_virtualenv(self):
"""Clears the folder and creates a new virtualenv at
`self._virtualenv_path`."""
if self.virtualenv_exists():
logging.ERROR("Virtualenv already exists at: `{0}`".format(self._virtualenv_path))
logging.ERROR(
"Virtualenv already exists at: `{0}`".format(self._virtualenv_path)
)
return
logging.info("Creating virtualenv at: `{}`".format(self._virtualenv_path))
venv.create(self._virtualenv_path, clear=True, with_pip=True)

def deactivate_virtualenv(self):
if self.virtualenv_exists() and self._is_activated:
subprocess.check_output(
"deactivate",
shell=True)
subprocess.check_output("deactivate", shell=True)
logging.info("Virtualenv deactivated!")
self._is_activated = False

Expand All @@ -67,7 +71,7 @@ class BenchmarkTornadoHandler(tornado.web.RequestHandler):
def set_default_headers(self):
self.set_header("Access-Control-Allow-Origin", "*")
self.set_header("Access-Control-Allow-Headers", "x-requested-with")
self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS')
self.set_header("Access-Control-Allow-Methods", "POST, GET, OPTIONS")

def get(self):
self.render("benchmark_hosted.html")
Expand Down Expand Up @@ -125,7 +129,8 @@ def register_benchmarks(self):
This function must be implemented in all child classes of `Suite.`
"""
raise NotImplementedError(
"Must implement `register_benchmarks` to run benchmark suite.")
"Must implement `register_benchmarks` to run benchmark suite."
)

def before_all(self):
pass
Expand Down Expand Up @@ -191,14 +196,17 @@ def host_results(self):
return
MANAGER = PerspectiveManager()
MANAGER.host_table("benchmark_results", self._table)
application = tornado.web.Application([
(r"/", BenchmarkTornadoHandler),
# create a websocket endpoint that the client Javascript can access
(r"/websocket", PerspectiveTornadoHandler, {
"manager": MANAGER,
"check_origin": True
})
])
application = tornado.web.Application(
[
(r"/", BenchmarkTornadoHandler),
# create a websocket endpoint that the client Javascript can access
(
r"/websocket",
PerspectiveTornadoHandler,
{"manager": MANAGER, "check_origin": True},
),
]
)
self._HOSTING = True
application.listen(8888)
logging.critical("Displaying results at http://localhost:8888")
Expand All @@ -221,22 +229,25 @@ def run_method(self, func, *args, **kwargs):
`ITERATIONS`, returning a result row that can be fed into Perspective.
"""
overall_result = {
k.replace("__BENCH__", ""):
v for (k, v) in func.__dict__.items() if "__BENCH__" in k
k.replace("__BENCH__", ""): v
for (k, v) in func.__dict__.items()
if "__BENCH__" in k
}

result = timeit(func, number=Runner.ITERATIONS) / Runner.ITERATIONS
overall_result["__TIME__"] = result
return overall_result

def print_result(self, result):
print("{}::{} ({}):{:30}{:>30}".format(
result["group"],
result["name"],
result["version"],
"",
result["__TIME__"],
))
print(
"{}::{} ({}):{:30}{:>30}".format(
result["group"],
result["name"],
result["version"],
"",
result["__TIME__"],
)
)

def run(self, version):
"""Runs each benchmark function from the suite for n `ITERATIONS`,
Expand Down
Loading