Skip to content

Commit d3daa81

Browse files
committed
create driver.sh for each implementation
1 parent f635ab8 commit d3daa81

17 files changed

+160
-53
lines changed

Makefile

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,46 @@
11
IMPLEMENTATIONS=$(wildcard implementations/*)
22

3-
ifeq ($(TEST),)
3+
ifeq ($(TEST),) #################################################
44
# If TEST is not set, by default build everything, generate
55
# data for all implementations, and then run all pytests.
66

7-
.PHONY: test
7+
.PHONY: test data
88
test: data
99
pytest -v -k W
1010

11+
data: $(IMPLEMENTATIONS)
12+
1113
else
1214
# Otherwise, focus on a single implementation, only generating
1315
# its data and using the "-k W-" keyword to limit which pytests
1416
# get run
1517

16-
.PHONY: test
18+
.PHONY: test data
1719
test: implementations/$(TEST)
1820
pytest -v -k W-$(TEST)
1921

20-
endif
22+
data: implementations/$(TEST)
23+
24+
endif ##########################################################
25+
2126

2227
data/reference_image.png:
2328
python generate_reference_image.py
2429

25-
.PHONY: $(IMPLEMENTATIONS)
26-
implementations/%: data/reference_image.png
27-
bash $^/driver.sh
30+
define mk-impl-target
31+
# For each of the items in our "implementations" directory,
32+
# create a target which depends on the reference data and
33+
# calls the "driver.sh" script.
34+
.PHONY: $1
35+
$1: data/reference_image.png
36+
bash $1/driver.sh
37+
38+
# Alias in case the trailing slash is included
39+
.PHONE: $1/
40+
$1/: $1
41+
42+
endef
43+
$(foreach impl,$(IMPLEMENTATIONS),$(eval $(call mk-impl-target,$(impl))))
2844

2945
.PHONY: report
3046
report: data

implementations/.conda_driver.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This is re-usable driver code for all of the implementations
4+
# that make use of a conda environment file.
5+
#
6+
7+
set -e
8+
set -o pipefail
9+
10+
create_or_activate(){
11+
if { conda env list | grep $ENVNAME; } >/dev/null 2>&1; then
12+
echo "Using $ENVNAME"
13+
else
14+
echo "Creating $ENVNAME"
15+
conda env create -n $ENVNAME -f $IMPL/environment.yml
16+
fi
17+
eval "$(conda shell.bash hook)"
18+
echo "Activating $ENVNAME"
19+
conda activate $ENVNAME
20+
}

implementations/js/driver.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ENVNAME=ZI_js
2+
3+
# Standard bootstrapping
4+
IMPL=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5+
ROOT=$( dirname $IMPL)
6+
. $ROOT/.conda_driver.sh
7+
create_or_activate
8+
9+
cd "${IMPL}"
10+
11+
npm install
12+
npm start

implementations/js/generate_data.sh

-6
This file was deleted.

implementations/jzarr/generate_data.sh renamed to implementations/jzarr/driver.sh

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# cd to this directory
22
# https://stackoverflow.com/a/6393573/2700168
3-
cd "${0%/*}"
43

5-
set -e
6-
set -u
7-
set -x
4+
ENVNAME=ZI_jzarr
5+
6+
# Standard bootstrapping
7+
IMPL=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
8+
ROOT=$( dirname $IMPL)
9+
. $ROOT/.conda_driver.sh
10+
create_or_activate
11+
12+
cd "${IMPL}"
813

914
MVN_FLAGS=${MVN_FLAGS:-"--no-transfer-progress"}
1015
mvn "${MVN_FLAGS}" clean package
@@ -16,4 +21,3 @@ java -cp target/jzarr-1.0.0.jar zarr_implementations.jzarr.App "$@" && {
1621
echo jzarr failed
1722
exit 2
1823
}
19-

implementations/n5-java/driver.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ENVNAME=ZI_n5_java
2+
3+
# Standard bootstrapping
4+
IMPL=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5+
ROOT=$( dirname $IMPL)
6+
. $ROOT/.conda_driver.sh
7+
create_or_activate
8+
9+
cd "${IMPL}"
10+
11+
MVN_FLAGS=${MVN_FLAGS:-"--no-transfer-progress"}
12+
mvn "${MVN_FLAGS}" clean package
13+
14+
java -cp target/n5_java-1.0.0.jar zarr_implementations.n5_java.App

implementations/n5-java/generate_data.sh

-8
This file was deleted.

implementations/pyn5/driver.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
#
3+
#
4+
5+
ENVNAME=ZI_pyn5
6+
7+
# Standard bootstrapping
8+
IMPL=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
9+
ROOT=$( dirname $IMPL)
10+
. $ROOT/.conda_driver.sh
11+
create_or_activate
12+
13+
python $IMPL/generate_pyn5.py

implementations/pyn5/environment.yml

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@ channels:
22
- conda-forge
33
- defaults
44
dependencies:
5-
- openimageio
6-
- python == 3.7.9
5+
- rust
6+
- maturin
7+
- python
78
- scikit-image
8-
- pytest
9-
- zarr >= 2.8.3
109
- pip
11-
- pandas
12-
- tabulate
1310
- pip:
1411
- pyn5
15-
- git+https://github.com/grlee77/zarrita.git@codec_update

implementations/xtensor_zarr/generate_data.sh renamed to implementations/xtensor_zarr/driver.sh

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
# cd to this directory
2-
# https://stackoverflow.com/a/6393573/2700168
3-
cd "${0%/*}"
1+
ENVNAME=ZI_xtensor_zarr
2+
3+
# Standard bootstrapping
4+
IMPL=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5+
ROOT=$( dirname $IMPL)
6+
. $ROOT/.conda_driver.sh
7+
create_or_activate
8+
9+
cd "${IMPL}"
10+
11+
set +u # Due to GDAL_DATA
412

513
rm -rf build
614
mkdir build
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
channels:
2+
- conda-forge
3+
- defaults
4+
dependencies:
5+
- make
6+
- cmake
7+
- xtensor-zarr >=0.0.8|=0.0.7=*_1

implementations/z5py/driver.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
#
3+
#
4+
5+
ENVNAME=ZI_z5py
6+
7+
# Standard bootstrapping
8+
IMPL=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
9+
ROOT=$( dirname $IMPL)
10+
. $ROOT/.conda_driver.sh
11+
create_or_activate
12+
13+
python $IMPL/generate_z5py.py

implementations/z5py/environment.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
channels:
2+
- conda-forge
3+
- defaults
4+
dependencies:
5+
- z5py
6+
- python
7+
- scikit-image

implementations/zarr-python/driver.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
#
3+
#
4+
5+
ENVNAME=ZI_zarr_python
6+
7+
# Standard bootstrapping
8+
IMPL=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
9+
ROOT=$( dirname $IMPL)
10+
. $ROOT/.conda_driver.sh
11+
create_or_activate
12+
13+
python $IMPL/generate_zarr.py

implementations/zarr-python/environment.yml

+2-10
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@ channels:
22
- conda-forge
33
- defaults
44
dependencies:
5-
- openimageio
6-
- python == 3.7.9
5+
- python
76
- scikit-image
8-
- pytest
9-
- zarr >= 2.8.3
10-
- pip
11-
- pandas
12-
- tabulate
13-
- pip:
14-
- pyn5
15-
- git+https://github.com/grlee77/zarrita.git@codec_update
7+
- zarr

implementations/zarrita/driver.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
#
3+
4+
ENVNAME=ZI_zarritz
5+
6+
# Standard bootstrapping
7+
IMPL=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
8+
ROOT=$( dirname $IMPL)
9+
. $ROOT/.conda_driver.sh
10+
create_or_activate
11+
12+
python $IMPL/generate_zarrita.py

implementations/zarrita/environment.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@ channels:
22
- conda-forge
33
- defaults
44
dependencies:
5-
- openimageio
6-
- python == 3.7.9
5+
- python
76
- scikit-image
8-
- pytest
9-
- zarr >= 2.8.3
107
- pip
11-
- pandas
12-
- tabulate
138
- pip:
14-
- pyn5
159
- git+https://github.com/grlee77/zarrita.git@codec_update

0 commit comments

Comments
 (0)