Skip to content

Commit

Permalink
Use format.get_metadata_version(data) to get version
Browse files Browse the repository at this point in the history
Need to create a format instance (of the correct version) since this isn't a static methods
  • Loading branch information
will-moore committed Jul 5, 2022
1 parent 96961bd commit c03b0a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ome_zarr/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def init_store(self, path: str, mode: str = "r") -> FSStore:
def init_channels(self) -> None: # pragma: no cover
raise NotImplementedError()

def _get_metadata_version(self, metadata: dict) -> Optional[str]:
def get_metadata_version(self, metadata: dict) -> Optional[str]:
"""
Checks the metadata dict for a version
Expand Down Expand Up @@ -127,7 +127,7 @@ def version(self) -> str:
return "0.1"

def matches(self, metadata: dict) -> bool:
version = self._get_metadata_version(metadata)
version = self.get_metadata_version(metadata)
LOGGER.debug(f"{self.version} matches {version}?")
return version == self.version

Expand Down
8 changes: 4 additions & 4 deletions ome_zarr/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from jsonschema import validate as jsonschema_validate

from .axes import Axes
from .format import CurrentFormat, format_from_version
from .format import CurrentFormat, detect_format, format_from_version
from .io import ZarrLocation
from .types import JSONDict

Expand Down Expand Up @@ -192,6 +192,9 @@ def matches(zarr: ZarrLocation) -> bool:
def __init__(self, node: Node) -> None:
self.node = node
self.zarr = node.zarr
fmt = detect_format(self.zarr.root_attrs, CurrentFormat())
version = fmt.get_metadata_version(self.zarr.root_attrs)
self.version = version if version is not None else fmt.version
LOGGER.debug(f"treating {self.zarr} as {self.__class__.__name__}")
for k, v in self.zarr.root_attrs.items():
LOGGER.info("root_attr: %s", k)
Expand Down Expand Up @@ -334,7 +337,6 @@ def __init__(self, node: Node) -> None:

try:
multiscales = self.lookup("multiscales", [])
self.version = multiscales[0].get("version", CurrentFormat().version)
datasets = multiscales[0]["datasets"]
axes = multiscales[0].get("axes")
fmt = format_from_version(self.version)
Expand Down Expand Up @@ -458,7 +460,6 @@ def matches(zarr: ZarrLocation) -> bool:
def __init__(self, node: Node) -> None:
super().__init__(node)
self.well_data = self.lookup("well", {})
self.version = self.well_data.get("version", CurrentFormat().version)
LOGGER.info("well_data: %s", self.well_data)

image_paths = [image["path"] for image in self.well_data.get("images")]
Expand Down Expand Up @@ -535,7 +536,6 @@ def __init__(self, node: Node) -> None:
super().__init__(node)
LOGGER.debug(f"Plate created with ZarrLocation fmt:{ self.zarr.fmt}")
self.plate_data = self.lookup("plate", {})
self.version = self.plate_data.get("version", CurrentFormat().version)
LOGGER.info("plate_data: %s", self.plate_data)
self.get_pyramid_lazy(node)

Expand Down

0 comments on commit c03b0a0

Please sign in to comment.