Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prep for 0.4.0 rc3 #209

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "acquire-imaging"
authors = ["Nathan Clack <[email protected]>"]
version = "0.4.0-rc2"
version = "0.4.0-rc3"
edition = "2021"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() {
serde_json::from_str(drivers_json.as_str()).expect("Failed to parse drivers.json");

let dst = cmake::Config::new("acquire-common")
.profile("RelWithDebInfo")
.profile("Release")
.define("NOTEST", "TRUE")
.define("NO_UNIT_TESTS", "TRUE")
.define("NO_EXAMPLES", "TRUE")
Expand Down
2 changes: 1 addition & 1 deletion drivers.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"acquire-driver-zarr": "0.1.13",
"acquire-driver-zarr": "0.2.0",
"acquire-driver-egrabber": "0.1.5",
"acquire-driver-hdcam": "0.1.9",
"acquire-driver-spinnaker": "0.1.1",
Expand Down
59 changes: 33 additions & 26 deletions tests/test_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ def test_write_external_metadata_to_zarr(
assert dimension_z.shard_size_chunks == 0

props.video[0].storage.settings.acquisition_dimensions = [
dimension_x,
dimension_y,
dimension_z,
dimension_y,
dimension_x,
]

props = runtime.set_configuration(props)
Expand Down Expand Up @@ -186,16 +186,20 @@ def test_write_external_metadata_to_zarr(
assert axis_units == (None, "micrometer", "micrometer")

# We only have one multi-scale level and one transform.
""" acquire-zarr does not yet have support for setting pixel scale
transform = multi_scale_image_metadata["coordinateTransformations"][0][0]
pixel_scale_um = tuple(
transform["scale"][axis_names.index(axis)] for axis in ("x", "y")
)
assert pixel_scale_um == props.video[0].storage.settings.pixel_scale_um
"""

# ome-zarr only reads attributes it recognizes, so use a plain zarr reader
# to read external metadata instead.
group = zarr.open(props.video[0].storage.settings.uri)
assert group["0"].attrs.asdict() == metadata
# read the external metadata directly
with open(
Path(props.video[0].storage.settings.uri) / "acquire.json"
) as fh:
acquire_json = json.load(fh)
assert acquire_json == metadata


@pytest.mark.parametrize(
Expand Down Expand Up @@ -249,10 +253,10 @@ def test_write_compressed_zarr(
assert dimension_t.shard_size_chunks == 0

p.video[0].storage.settings.acquisition_dimensions = [
dimension_x,
dimension_y,
dimension_c,
dimension_t,
dimension_c,
dimension_y,
dimension_x,
]

runtime.set_configuration(p)
Expand All @@ -274,7 +278,11 @@ def test_write_compressed_zarr(
p.video[0].camera.settings.shape[1],
p.video[0].camera.settings.shape[0],
)
assert data.attrs.asdict() == metadata

# validate external metadata
with open(Path(p.video[0].storage.settings.uri) / "acquire.json") as fh:
acquire_json = json.load(fh)
assert acquire_json == metadata

# load from Dask
data = da.from_zarr(p.video[0].storage.settings.uri, component="0")
Expand Down Expand Up @@ -337,9 +345,9 @@ def test_write_zarr_with_chunking(
assert dimension_t.shard_size_chunks == 0

p.video[0].storage.settings.acquisition_dimensions = [
dimension_x,
dimension_y,
dimension_t,
dimension_y,
dimension_x,
]

runtime.set_configuration(p)
Expand Down Expand Up @@ -401,9 +409,9 @@ def test_write_zarr_multiscale(
assert dimension_t.shard_size_chunks == 0

p.video[0].storage.settings.acquisition_dimensions = [
dimension_x,
dimension_y,
dimension_t,
dimension_y,
dimension_x,
]
p.video[0].storage.settings.enable_multiscale = True

Expand Down Expand Up @@ -482,9 +490,9 @@ def test_write_zarr_v3(
)

p.video[0].storage.settings.acquisition_dimensions = [
dimension_x,
dimension_y,
dimension_t,
dimension_y,
dimension_x,
]

runtime.set_configuration(p)
Expand Down Expand Up @@ -540,21 +548,20 @@ def test_metadata_with_trailing_whitespace(
)

p.video[0].storage.settings.acquisition_dimensions = [
dimension_x,
dimension_y,
dimension_t,
dimension_y,
dimension_x,
]

runtime.set_configuration(p)

runtime.start()
runtime.stop()

# load from Zarr
group = zarr.open(p.video[0].storage.settings.uri)
data = group["0"]

assert data.attrs.asdict() == metadata
# check metadata
with open(Path(p.video[0].storage.settings.uri) / "acquire.json") as fh:
acquire_json = json.load(fh)
assert acquire_json == metadata


def test_write_zarr_to_s3(runtime: Runtime, request: pytest.FixtureRequest):
Expand Down Expand Up @@ -614,9 +621,9 @@ def test_write_zarr_to_s3(runtime: Runtime, request: pytest.FixtureRequest):
assert dimension_t.shard_size_chunks == 0

video.storage.settings.acquisition_dimensions = [
dimension_x,
dimension_y,
dimension_t,
dimension_y,
dimension_x,
]

runtime.set_configuration(props)
Expand All @@ -639,7 +646,7 @@ def test_write_zarr_to_s3(runtime: Runtime, request: pytest.FixtureRequest):

assert data.chunks == (64, 540, 960)
assert data.shape == (
64,
video.max_frame_count,
video.camera.settings.shape[1],
video.camera.settings.shape[0],
)
Expand Down
Loading