Skip to content

Commit

Permalink
Merge branch 'main' into submission-run
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmoore authored Apr 16, 2021
2 parents 9400d7f + 7946172 commit ca7d873
Show file tree
Hide file tree
Showing 10 changed files with 806 additions and 1,380 deletions.
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
known_third_party = fsspec,h5py,pandas,pytest,s3fs,seaborn,tifffile,zarr
known_third_party = fsspec,h5py,matplotlib,numpy,pandas,ptitprince,pytest,requests,s3fs,seaborn,tifffile,zarr
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ repos:
args: ["--profile", "black"]

- repo: https://github.com/ambv/black
rev: 19.10b0
rev: 20.8b1
hooks:
- id: black
args: [--target-version=py36]
args: [--target-version=py37]

- repo: https://github.com/asottile/pyupgrade
rev: v2.7.2
Expand Down Expand Up @@ -45,7 +45,7 @@ repos:
- --autofix

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
rev: 3.9.0
hooks:
- id: flake8
additional_dependencies: [
Expand All @@ -58,7 +58,7 @@ repos:
# default black line length is 88
"--max-line-length=88",
# Conflicts with black: E203 whitespace before ':'
"--ignore=E203",
"--ignore=E203,W503",
"--rst-roles=class,func,ref,module,const",
]

Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# How to use this repository
[![DOI](https://zenodo.org/badge/329595844.svg)](https://zenodo.org/badge/latestdoi/329595844)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ome/ngff-latency-benchmark/master?filepath=notebooks)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ome/ngff-latency-benchmark/)

# OME-NGFF: latency benchmark

To get started, clone this repository locally:
```
Expand Down Expand Up @@ -38,3 +42,4 @@ docker-compose run --rm benchmark -sv

This will store both the benchmarking results ('benchmark_data.json') as well as a plotted graph
('benchmark_plot.png') in the directory along with the input data.

1 change: 1 addition & 0 deletions benchmark/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ COPY plot_results.py /benchmark/plot_results.py
RUN conda run -n benchmark pip install pytest-profiling
RUN conda run -n benchmark pip install seaborn
RUN conda run -n benchmark pip install pytest-csv
RUN conda run -n benchmark pip install ptitprince

ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "benchmark", "bash", "/benchmark/benchmark.sh"]
4 changes: 1 addition & 3 deletions benchmark/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

DIR=${DIR:-./data}
export BENCHMARK_DATA=${DIR}
export BENCHMARK_PLOT=${DIR}/benchmark_plot.png

set -e
set -u
Expand All @@ -15,6 +14,5 @@ do
pytest benchmark.py "$@" --csv=${BENCHMARK_DATA}/${i}_benchmark_data.csv \
--csv-columns status,duration,properties_as_columns,markers_args_as_columns
head ${BENCHMARK_DATA}/${i}_benchmark_data.csv
python plot_results.py ${BENCHMARK_DATA}/${i}_benchmark_data.csv ${BENCHMARK_DATA}/${i}_benchmark_plot.png
done

python plot_results.py
114 changes: 43 additions & 71 deletions benchmark/plot_results.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,73 +1,45 @@
import json
import os
import re
#!/usr/bin/env python
import argparse

import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns

data_path = os.environ.get("BENCHMARK_DATA", "benchmark_data")
plot_path = os.environ.get("BENCHMARK_PLOT", "benchmark_plot.png")
xy = os.environ.get("XY", "unknown")

csv = pd.read_csv(f"{data_path}/0_benchmark_data.csv")

types = ("Overhead", "Zarr", "TIFF", "HDF5")
sources = ("local", "http", "s3")
orders = {"type": types, "source": sources}

pal_points = "colorblind"
pal_violins = "pastel"

g = sns.FacetGrid(
csv,
col="source",
col_order=sources,
sharey=False,
height=5,
aspect=0.6,
)

g = g.map(
sns.boxenplot,
"type",
"seconds",
order=types,
width=0.6,
k_depth=2,
palette=pal_violins,
dodge=True,
showfliers=False,
)

g = g.map(
sns.stripplot,
"type", # was type
"seconds",
dodge=True,
order=types,
jitter=0.2,
size=3,
palette=pal_points,
)

g.despine(left=True)
g.set(yscale ='log', ylim=(0.0009, 1))

# Set axis labels & ticks #
for ax in g.fig.get_axes():
label = ax.get_title().replace("source =", "")
ax.set_xlabel(label)
ax.set_xticklabels(types)
ax.set_title("")
for col in ax.collections:
# Remove outline of violins
col.set_edgecolor("white")

# Only show on far left plot
g.fig.get_axes()[0].set_ylabel("Seconds")
g.fig.get_axes()[0].spines["left"].set_visible(True)

# Add annotations
g.fig.get_axes()[0].text(0.0001, 0.001, "off-\nscale")

g.savefig(plot_path, dpi=600)
import ptitprince as pt


def plot_csv(filename: str, pngpath: str):
csv = pd.read_csv(filename)

f, ax = plt.subplots(figsize=(8, 6))
ax = pt.RainCloud(
x="type",
y="seconds",
hue="source",
data=csv,
palette="Set2",
# bw = .2,
width_viol=0.6,
ax=ax,
orient="h",
alpha=0.65,
# dodge = True,
jitter=0.03,
move=0.2,
# pointplot = True,
)

# ax.set(ylim=(0.0002, 5))
ax.set_xscale("log")
ax.set_xlabel("seconds per chunk")
ax.axes.get_yaxis().get_label().set_visible(False)
handles, labels = ax.get_legend_handles_labels()
plt.legend(handles[0:3], labels[0:3], loc="lower left")
plt.tight_layout()
f.savefig(pngpath, dpi=600)


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("csv", help="input csv file")
parser.add_argument("png", help="output png file")
ns = parser.parse_args()
plot_csv(ns.csv, ns.png)
13 changes: 13 additions & 0 deletions binder/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
channels:
- conda-forge
dependencies:
- h5py
- matplotlib
- numpy
- pandas
- pytest
- request
- s3fs
- seaborn
- tifffile
- zarr
Loading

0 comments on commit ca7d873

Please sign in to comment.