Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
d-v-b committed Nov 21, 2024
2 parents e8db526 + 470f4f1 commit 06eed37
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 6 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Run tests

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.11"

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Run tests
# For example, using `pytest`
run: uv run pytest
4 changes: 3 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ It aims to be a reference implementation of the OME-zarr specification.

This package is designed with the following guiding principles:

- Slim, with as few dependencies as possible
- Strict adherence to the OME-zarr specification
- A usable set of Python classes for reading and writing and interacting with OME-zarr metadata
- A separate object for each version of the OME-zarr specification
- Data operations are out of scope

We are trying to make this as usable and useful as possible while still complying with the OME-zarr specification.
55 changes: 52 additions & 3 deletions docs/tutorial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
# # Tutorial

from ome_zarr_models.v04 import Image as OMEZarrImage
# from ome_zarr_models.v04 import Image as OMEZarrImage

my_image = OMEZarrImage(path="path/to/ome/zarr/directory.ome.zarr")
print(my_image.multiscales)
# my_image = OMEZarrImage(path="path/to/ome/zarr/directory.ome.zarr")
# print(my_image.multiscales)

# ## Creating
#
# TODO: exmaple of creating a model from a remote store
# TODO: example of

import gcsfs
import zarr.storage
import zarr

bucket = "ucl-hip-ct-35a68e99feaae8932b1d44da0358940b"
fs = gcsfs.GCSFileSystem(project=bucket, token="anon", access="read_only")
store = zarr.storage.FSStore(url=bucket, fs=fs)
group = zarr.open_group(
store=store, path="S-20-28/heart/25.27um_complete-organ_bm05.ome.zarr"
)
print(group)
exit()

# ## Updating models
#
# All the fields in the models can be updated in place.
# When you do this, any validation on the individual field
# you are updating will take place.
#
# For example, we can [do something valid]:


# but if you try and [do something invalid] it raises an error:

# This means validation happens early, allowing you to catch errors
# before getting too far.

# ## Writing metadata
#
# TODO: example of writing out the metadata again

# ## Accessing data
#
# Although these models do not handle reading or writing data,
# they do expose the zarr arrays.

# ## Not using validation
#
# If you *really* want to create models that are not validated against
# the OME-zarr specifciation, you can use the ``model_construct`` method.
# For example:

# Put some bad code here
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ docs = [
"mkdocstrings-python>=1.12.2",
"mkdocs-material",
"mkdocs-jupyter",
"gcsfs",
"zarr<3",
]
dev = [
"jupyter[notebook]>=1.1.1",
Expand Down
7 changes: 5 additions & 2 deletions src/ome_zarr_models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def _unique_items_validator(values: list[T]) -> list[T]:
raise ValueError(f"Non-unique values in {values}.")
return values


def dataclass_to_pydantic(dataclass_type: type) -> type[pydantic.BaseModel]:
"""Convert a dataclass to a Pydantic model.
Expand Down Expand Up @@ -39,4 +38,8 @@ def dataclass_to_pydantic(dataclass_type: type) -> type[pydantic.BaseModel]:
# No default value
field_definitions[_field.name] = (_field.type, Ellipsis)

return create_model(dataclass_type.__name__, **field_definitions)
<<<<<<< HEAD
return create_model(dataclass_type.__name__, **field_definitions)
=======
return create_model(dataclass_type.__name__, **field_definitions)
>>>>>>> 470f4f1a33aef4ecf2ebf0906c912a3621c8957b

0 comments on commit 06eed37

Please sign in to comment.