-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from aliddell/add-acquire-again
Add Acquire Zarr to benchmark suite
- Loading branch information
Showing
12 changed files
with
171 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ __pycache__/ | |
.vscode/ | ||
example_data/ | ||
build/ | ||
test.* | ||
test.* | ||
venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "acquire-zarr"] | ||
path = external/acquire-zarr | ||
url = [email protected]:aliddell/acquire-zarr.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,48 @@ | ||
cmake_minimum_required(VERSION 3.2) | ||
project(cpp-zarr) | ||
cmake_minimum_required(VERSION 3.23) | ||
project(zarr-benchmarks) | ||
cmake_policy(SET CMP0057 NEW) | ||
cmake_policy(SET CMP0079 NEW) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
# finding the cppZarr lib | ||
# Common dependencies | ||
find_package(Python3 REQUIRED COMPONENTS Interpreter Development) | ||
find_package(pybind11 REQUIRED) | ||
|
||
# Dependencies for acquire-zarr | ||
find_package(nlohmann_json CONFIG REQUIRED) | ||
find_package(blosc CONFIG REQUIRED) | ||
find_package(miniocpp CONFIG REQUIRED) | ||
|
||
include_directories( | ||
/usr/local/include | ||
${Python3_INCLUDE_DIRS} | ||
${pybind11_INCLUDE_DIR} | ||
) | ||
|
||
# construct bindings for cppZarr | ||
find_library(cppZarrLib cppZarr REQUIRED) | ||
pybind11_add_module(pyCppZarr zarr_libraries/cpp_zarr/cpp_zarr.cpp) | ||
target_link_libraries(pyCppZarr PRIVATE ${cppZarrLib}) | ||
|
||
# setting include dir for dependencies | ||
include_directories(/usr/local/include) | ||
# build acquire-zarr | ||
set(BUILD_PYTHON ON CACHE BOOL "Build Python bindings for acquire-zarr") | ||
set(BUILD_TESTING OFF CACHE BOOL "Disable acquire-zarr tests") | ||
add_subdirectory(external/acquire-zarr) | ||
|
||
# pybind11 | ||
find_package(Python3 REQUIRED COMPONENTS Interpreter Development) | ||
include_directories(${Python3_INCLUDE_DIRS}) | ||
add_custom_target(install-acquire-zarr-python | ||
COMMAND ${Python3_EXECUTABLE} -m pip install . | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/external/acquire-zarr | ||
DEPENDS acquire-zarr | ||
COMMENT "Installing acquire-zarr Python package" | ||
) | ||
|
||
find_package(pybind11 REQUIRED) | ||
include_directories(${pybind11_INCLUDE_DIR}) | ||
# Make the Python installation part of the default build | ||
add_dependencies(pyCppZarr install-acquire-zarr-python) | ||
|
||
pybind11_add_module(pyCppZarr zarr_libraries/cpp_zarr/cpp_zarr.cpp) | ||
target_link_libraries(pyCppZarr PRIVATE ${cppZarrLib}) | ||
# Installation rules | ||
install(TARGETS pyCppZarr | ||
LIBRARY DESTINATION ${Python3_SITEARCH}/zarr_benchmarks | ||
RUNTIME DESTINATION ${Python3_SITEARCH}/zarr_benchmarks) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 3, | ||
"configurePresets": [ | ||
{ | ||
"name": "default", | ||
"binaryDir": "${sourceDir}/build", | ||
"cacheVariables": { | ||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule acquire-zarr
added at
b0f23e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"default-registry": { | ||
"kind": "git", | ||
"baseline": "f7423ee180c4b7f40d43402c2feb3859161ef625", | ||
"repository": "https://github.com/microsoft/vcpkg" | ||
}, | ||
"registries": [ | ||
{ | ||
"kind": "artifact", | ||
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", | ||
"name": "microsoft" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"dependencies": [ | ||
{ | ||
"name": "blosc", | ||
"version>=": "1.21.5" | ||
}, | ||
{ | ||
"name": "nlohmann-json", | ||
"version>=": "3.11.3" | ||
}, | ||
{ | ||
"name": "minio-cpp", | ||
"version>=": "0.3.0" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import acquire_zarr as aqz | ||
|
||
from pathlib import Path | ||
import numpy as np | ||
import time | ||
|
||
|
||
class AcquireZarr: | ||
def __init__(self) -> None: | ||
aqz.set_log_level(aqz.LogLevel.Error) | ||
base_dir = Path(__file__).parent | ||
self.__path_to_data = ( | ||
base_dir / "example_data" / "acquire_zarr_data" / "test.zarr" | ||
).resolve() | ||
|
||
if not self.__path_to_data.parent.exists(): | ||
self.__path_to_data.parent.mkdir(parents=True) | ||
|
||
@property | ||
def data_path(self) -> str: | ||
return str(self.__path_to_data) | ||
|
||
def write_zarr(self, shape: list, chunks: list, zarr_data: np.ndarray) -> float: | ||
settings = aqz.StreamSettings() | ||
settings.store_path = self.data_path | ||
settings.compression = aqz.CompressionSettings( | ||
compressor=aqz.Compressor.BLOSC1, | ||
codec=aqz.CompressionCodec.BLOSC_LZ4, | ||
level=1, | ||
shuffle=0 | ||
) | ||
settings.data_type=aqz.DataType.UINT8 | ||
settings.dimensions.extend( | ||
[ | ||
aqz.Dimension( | ||
name="t", | ||
kind=aqz.DimensionType.TIME, | ||
array_size_px=shape[0], | ||
chunk_size_px=chunks[0], | ||
), | ||
aqz.Dimension( | ||
name="y", | ||
kind=aqz.DimensionType.SPACE, | ||
array_size_px=shape[1], | ||
chunk_size_px=chunks[1], | ||
), | ||
aqz.Dimension( | ||
name="x", | ||
kind=aqz.DimensionType.SPACE, | ||
array_size_px=shape[2], | ||
chunk_size_px=chunks[2], | ||
), | ||
] | ||
) | ||
settings.version = aqz.ZarrVersion.V2 | ||
stream = aqz.ZarrStream(settings) | ||
|
||
t = time.perf_counter() | ||
stream.append(zarr_data) | ||
total_time = time.perf_counter() - t | ||
|
||
return total_time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters