Skip to content

Commit

Permalink
Merge pull request #4 from chris-delg/docker
Browse files Browse the repository at this point in the history
Docker
  • Loading branch information
chris-delg authored Aug 8, 2024
2 parents a9b5e0f + 9de307d commit ba70fc5
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 78 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__pycache__/
.vscode/
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM continuumio/miniconda3

# set working dir for docker app
WORKDIR /app

# install system dependencies including OpenGL
RUN apt-get update && apt-get install -y \
python3-opengl \
mesa-utils \
libgl1-mesa-glx \
libgl1-mesa-dri

# move environment.yml from source to docker app
COPY environment.yml ./

# installing dependancies
RUN conda env create -n benchmark --file environment.yml

# had source instead of conda here
RUN echo "source activate benchmark" > ~/.bashrc

# set conda to path
ENV PATH=/opt/conda/envs/benchmark/bin:$PATH

# copy source code into docker app
COPY . .

# running the benchmark
CMD [ "python", "main.py" ]
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@ This benchmarking suite compares the following Zarr writers (click for documenta
- [TensorStore](https://google.github.io/tensorstore/)
- [Zarr-Python](https://zarr.readthedocs.io/en/stable/index.html)
- [OME-Zarr](https://ome-zarr.readthedocs.io/en/stable/)
- [z5](https://github.com/constantinpape/z5)

To run the benchmark, just execute the following command.
```bash
## Building and Running

To build and run the benchmark in this program, you need to install the various Zarr writers on your machine. Refer below to see what options you have for your operating system.

### Linux

An "environment.yml" has been provided for simplifying the dependency process on Linux. Simply download [conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) and execute the following commands to run the program.
```bash
conda env create -n benchmark --file environment.yml
conda activate benchmark
python main.py
```

## Dependencies
### Mac and Windows

To build and run the benchmark in this program, you need to install the various Zarr writers on your machine. Refer to the documentation links above for installation instructions.
Since some of the dependencies are only available on Linux, a Dockerfile has been left to allow building on other systems. Simply download [Docker](https://www.docker.com/) and execute the following commadns to run the program.

```bash
docker build -t benchmark .
docker run -it benchmark
```
16 changes: 16 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: benchmark
channels:
- defaults
- conda-forge
- rapidsai
dependencies:
- pip
- matplotlib
- napari
- pyqt
- ome-zarr
- kvikio
- zarr=2.15*
- pip:
- ml-dtypes
- tensorstore
32 changes: 24 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@


def main() -> None:
bandwidth_map = {}
shape = [64, 1080, 1920]
chunks = [64, 540, 960]
fig, graph = plt.subplots(2, 2)

zarr_python = Zarr_Python(shape=shape, chunks=chunks)
tensorstore = Tensorstore(shape=shape, chunks=chunks)
ome_zarr = Ome_Zarr(shape=shape, chunks=chunks)
z5 = Z5(shape=shape, chunks=chunks)

'''
Append Tests:
Expand All @@ -19,8 +19,12 @@ def main() -> None:
* TensorStore
* Zarr Python
'''
zarr_python.continuous_append_test(graph=graph[1][0], avg_graph=graph[1][1], append_dim_size=100)
tensorstore.continuous_append_test(graph=graph[1][0], avg_graph=graph[1][1], append_dim_size=100)
bandwidth_map["TensorStore Append"] = (
tensorstore.continuous_append_test(graph=graph[1][0], avg_graph=graph[1][1], append_dim_size=400)
)
bandwidth_map["Zarr Python Append"] = (
zarr_python.continuous_append_test(graph=graph[1][0], avg_graph=graph[1][1], append_dim_size=400)
)

# setting up graph for append tests
graph[1][0].set_xlabel("Write Number")
Expand All @@ -34,12 +38,24 @@ def main() -> None:
* TensorStore
* Zarr Python
* OME Zarr
* z5py
'''
tensorstore.continuous_write_test(graph=graph[0][0], avg_graph=graph[0][1], append_dim_size=10, step=1)
zarr_python.continuous_write_test(graph=graph[0][0], avg_graph=graph[0][1], append_dim_size=10, step=1)
ome_zarr.continuous_write_test(graph=graph[0][0], avg_graph=graph[0][1], append_dim_size=10, step=1) # crashes at anything above 16gigs (append_dim_size 90 on my machine)
z5.continuous_write_test(graph=graph[0][0], avg_graph=graph[0][1], append_dim_size=10, step=1)
bandwidth_map["TensorStore Write"] = (
tensorstore.continuous_write_test(graph=graph[0][0], avg_graph=graph[0][1], append_dim_size=80, step=5)
)
bandwidth_map["Zarr Python Write"] = (
zarr_python.continuous_write_test(graph=graph[0][0], avg_graph=graph[0][1], append_dim_size=80, step=5)
)
# ome-zarr crashes at anything above 16gigs on my machine
bandwidth_map["OME Zarr Write"] = (
ome_zarr.continuous_write_test(graph=graph[0][0], avg_graph=graph[0][1], append_dim_size=45, step=5)
)

# print the average bandwidth for each of the tests
print(f"Shape {shape}, Chunks {chunks}")
print("----------Bandwidth----------")
for test, bandwidth in bandwidth_map.items():
print(f"{test} : {bandwidth} GBps")
print("\n\n")

# setting up graphs for write tests
graph[0][0].set_xlabel("Data Size (GB)")
Expand Down
3 changes: 1 addition & 2 deletions zarr_libraries/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from zarr_libraries.common import *
from zarr_libraries.tensorstore.tensorstore_zarr import *
from zarr_libraries.zarr_python.zarr_python import *
from zarr_libraries.ome_ngff.ome_zarr import *
from zarr_libraries.z5py.z5 import *
from zarr_libraries.ome_ngff.ome_zarr import *
5 changes: 4 additions & 1 deletion zarr_libraries/ome_ngff/ome_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def __continuous_write(self, result_path: str, append_dim_size: int, step: int)
return file_sizes, bandwidths


def continuous_write_test(self, graph: matplotlib.axes._axes.Axes, avg_graph: matplotlib.axes._axes.Axes, append_dim_size: int, step: int) -> None:
def continuous_write_test(self, graph: matplotlib.axes._axes.Axes,
avg_graph: matplotlib.axes._axes.Axes,
append_dim_size: int, step: int) -> int:
# calls continuous write function and graphs results
print("\n\n--------OME-Zarr Stress Test--------\n\n")
file_sizes, bandwidths = self.__continuous_write(
Expand All @@ -56,5 +58,6 @@ def continuous_write_test(self, graph: matplotlib.axes._axes.Axes, avg_graph: ma
print("--------------------------------------------------------------\n\n")
graph.plot(file_sizes, bandwidths, label="OME-Zarr", marker='o')
avg_graph.bar("OME-Zarr", np.average(bandwidths))
return np.average(bandwidths)


10 changes: 8 additions & 2 deletions zarr_libraries/tensorstore/tensorstore_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def __continuous_append(self, result_path: str, append_dim_size: int) -> tuple[l
return write_number, bandwidths


def continuous_write_test(self, graph: matplotlib.axes._axes.Axes, avg_graph: matplotlib.axes._axes.Axes, append_dim_size: int, step: int) -> None:
def continuous_write_test(self, graph: matplotlib.axes._axes.Axes,
avg_graph: matplotlib.axes._axes.Axes,
append_dim_size: int, step: int) -> int:
# calls continuous write function and graphs results
print("\n\n--------Tensorstore Stress Test--------\n\n")
file_sizes, bandwidths = self.__continuous_write(
Expand All @@ -125,9 +127,12 @@ def continuous_write_test(self, graph: matplotlib.axes._axes.Axes, avg_graph: ma
print("--------------------------------------------------------------\n\n")
graph.plot(file_sizes, bandwidths, label="TensorStore", marker='o')
avg_graph.bar("TensorStore", np.average(bandwidths))
return np.average(bandwidths)


def continuous_append_test(self, graph: matplotlib.axes._axes.Axes, avg_graph: matplotlib.axes._axes.Axes, append_dim_size: int) -> None:
def continuous_append_test(self, graph: matplotlib.axes._axes.Axes,
avg_graph: matplotlib.axes._axes.Axes,
append_dim_size: int) -> int:
# calls continuous append function and graphs results
print("\n\n--------Tensorstore Stress Test--------\n\n")
write_number, bandwidths = self.__continuous_append(
Expand All @@ -137,5 +142,6 @@ def continuous_append_test(self, graph: matplotlib.axes._axes.Axes, avg_graph: m
print("--------------------------------------------------------------\n\n")
graph.plot(write_number, bandwidths, label="TensorStore")
avg_graph.bar("TensorStore", np.average(bandwidths))
return np.average(bandwidths)


57 changes: 0 additions & 57 deletions zarr_libraries/z5py/z5.py

This file was deleted.

12 changes: 9 additions & 3 deletions zarr_libraries/zarr_python/zarr_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ def __continuous_append(self, result_path: str, append_dim_size: int) -> tuple[l
return write_number, bandwidths


def continuous_write_test(self, graph: matplotlib.axes._axes.Axes, avg_graph: matplotlib.axes._axes.Axes, append_dim_size: int, step: int) -> None:
def continuous_write_test(self, graph: matplotlib.axes._axes.Axes,
avg_graph: matplotlib.axes._axes.Axes,
append_dim_size: int, step: int) -> int:
# calls continuous write function and graphs results
print("\n\n--------Zarr-Python Stress Test--------\n\n")
file_sizes, bandwidths = self.__continuous_write(
Expand All @@ -92,9 +94,12 @@ def continuous_write_test(self, graph: matplotlib.axes._axes.Axes, avg_graph: ma
print("--------------------------------------------------------------\n\n")
graph.plot(file_sizes, bandwidths, label="Zarr-Python", marker='o')
avg_graph.bar("Zarr-Python", np.average(bandwidths))

return np.average(bandwidths)


def continuous_append_test(self, graph: matplotlib.axes._axes.Axes, avg_graph: matplotlib.axes._axes.Axes, append_dim_size: int) -> None:
def continuous_append_test(self, graph: matplotlib.axes._axes.Axes,
avg_graph: matplotlib.axes._axes.Axes,
append_dim_size: int) -> int:
# calls continuous append function and graphs results
print("\n\n--------Zarr-Python Append Stress Test--------\n\n")
write_number, bandwidths = self.__continuous_append(
Expand All @@ -104,5 +109,6 @@ def continuous_append_test(self, graph: matplotlib.axes._axes.Axes, avg_graph: m
print("--------------------------------------------------------------\n\n")
graph.plot(write_number, bandwidths, label="Zarr-Python")
avg_graph.bar("Zarr-Python", np.average(bandwidths))
return np.average(bandwidths)


0 comments on commit ba70fc5

Please sign in to comment.