Skip to content

Commit

Permalink
Merge branch 'v3' into array_create_codec_kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
d-v-b committed Jun 4, 2024
2 parents 7796194 + b431cf7 commit faa6396
Show file tree
Hide file tree
Showing 21 changed files with 3,414 additions and 182 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/issue-metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Monthly issue metrics
on:
workflow_dispatch:
schedule:
- cron: '3 2 1 * *'

permissions:
contents: read

jobs:
build:
name: issue metrics
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: read
steps:
- name: Get dates for last month
shell: bash
run: |
# Calculate the first day of the previous month
first_day=$(date -d "last month" +%Y-%m-01)
# Calculate the last day of the previous month
last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d)
#Set an environment variable with the date range
echo "$first_day..$last_day"
echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV"
- name: Run issue-metrics tool
uses: github/issue-metrics@v3
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEARCH_QUERY: 'repo:zarr-developers/zarr-python is:issue created:${{ env.last_month }} -reason:"not planned"'

- name: Create issue
uses: peter-evans/create-issue-from-file@v5
with:
title: Monthly issue metrics report
token: ${{ secrets.GITHUB_TOKEN }}
content-filepath: ./issue_metrics.md
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.4.5'
rev: 'v0.4.7'
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ extend-select = [
ignore = [
"RUF003",
"RUF005",
"RUF009",
"RUF012",
"RUF015",
]
Expand Down
25 changes: 14 additions & 11 deletions src/zarr/abc/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
if TYPE_CHECKING:
from typing_extensions import Self

from zarr.common import ArraySpec, SliceSelection
from zarr.common import ArraySpec
from zarr.indexing import SelectorTuple
from zarr.metadata import ArrayMetadata


Expand Down Expand Up @@ -155,21 +156,21 @@ class ArrayBytesCodecPartialDecodeMixin:
"""Mixin for array-to-bytes codecs that implement partial decoding."""

async def _decode_partial_single(
self, byte_getter: ByteGetter, selection: SliceSelection, chunk_spec: ArraySpec
self, byte_getter: ByteGetter, selection: SelectorTuple, chunk_spec: ArraySpec
) -> NDBuffer | None:
raise NotImplementedError

async def decode_partial(
self,
batch_info: Iterable[tuple[ByteGetter, SliceSelection, ArraySpec]],
batch_info: Iterable[tuple[ByteGetter, SelectorTuple, ArraySpec]],
) -> Iterable[NDBuffer | None]:
"""Partially decodes a batch of chunks.
This method determines parts of a chunk from the slice selection,
fetches these parts from the store (via ByteGetter) and decodes them.
Parameters
----------
batch_info : Iterable[tuple[ByteGetter, SliceSelection, ArraySpec]]
batch_info : Iterable[tuple[ByteGetter, SelectorTuple, ArraySpec]]
Ordered set of information about slices of encoded chunks.
The slice selection determines which parts of the chunk will be fetched.
The ByteGetter is used to fetch the necessary bytes.
Expand All @@ -196,14 +197,14 @@ async def _encode_partial_single(
self,
byte_setter: ByteSetter,
chunk_array: NDBuffer,
selection: SliceSelection,
selection: SelectorTuple,
chunk_spec: ArraySpec,
) -> None:
raise NotImplementedError

async def encode_partial(
self,
batch_info: Iterable[tuple[ByteSetter, NDBuffer, SliceSelection, ArraySpec]],
batch_info: Iterable[tuple[ByteSetter, NDBuffer, SelectorTuple, ArraySpec]],
) -> None:
"""Partially encodes a batch of chunks.
This method determines parts of a chunk from the slice selection, encodes them and
Expand All @@ -213,7 +214,7 @@ async def encode_partial(
Parameters
----------
batch_info : Iterable[tuple[ByteSetter, NDBuffer, SliceSelection, ArraySpec]]
batch_info : Iterable[tuple[ByteSetter, NDBuffer, SelectorTuple, ArraySpec]]
Ordered set of information about slices of to-be-encoded chunks.
The slice selection determines which parts of the chunk will be encoded.
The ByteSetter is used to write the necessary bytes and fetch bytes for existing chunk data.
Expand Down Expand Up @@ -342,15 +343,16 @@ async def encode(
@abstractmethod
async def read(
self,
batch_info: Iterable[tuple[ByteGetter, ArraySpec, SliceSelection, SliceSelection]],
batch_info: Iterable[tuple[ByteGetter, ArraySpec, SelectorTuple, SelectorTuple]],
out: NDBuffer,
drop_axes: tuple[int, ...] = (),
) -> None:
"""Reads chunk data from the store, decodes it and writes it into an output array.
Partial decoding may be utilized if the codecs and stores support it.
Parameters
----------
batch_info : Iterable[tuple[ByteGetter, ArraySpec, SliceSelection, SliceSelection]]
batch_info : Iterable[tuple[ByteGetter, ArraySpec, SelectorTuple, SelectorTuple]]
Ordered set of information about the chunks.
The first slice selection determines which parts of the chunk will be fetched.
The second slice selection determines where in the output array the chunk data will be written.
Expand All @@ -363,16 +365,17 @@ async def read(
@abstractmethod
async def write(
self,
batch_info: Iterable[tuple[ByteSetter, ArraySpec, SliceSelection, SliceSelection]],
batch_info: Iterable[tuple[ByteSetter, ArraySpec, SelectorTuple, SelectorTuple]],
value: NDBuffer,
drop_axes: tuple[int, ...] = (),
) -> None:
"""Encodes chunk data and writes it to the store.
Merges with existing chunk data by reading first, if necessary.
Partial encoding may be utilized if the codecs and stores support it.
Parameters
----------
batch_info : Iterable[tuple[ByteSetter, ArraySpec, SliceSelection, SliceSelection]]
batch_info : Iterable[tuple[ByteSetter, ArraySpec, SelectorTuple, SelectorTuple]]
Ordered set of information about the chunks.
The first slice selection determines which parts of the chunk will be encoded.
The second slice selection determines where in the value array the chunk data is located.
Expand Down
Loading

0 comments on commit faa6396

Please sign in to comment.