Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nto elevate_codec_pipeline
  • Loading branch information
d-v-b committed Jun 12, 2024
2 parents 54dc2e8 + 7ded5d6 commit 6755488
Show file tree
Hide file tree
Showing 58 changed files with 6,419 additions and 690 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -56,7 +56,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -69,4 +69,4 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
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
10 changes: 5 additions & 5 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
submodules: true
fetch-depth: 0

- uses: actions/setup-python@v4.7.1
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'
Expand All @@ -27,7 +27,7 @@ jobs:
pip install hatch
- name: Build wheel and sdist
run: hatch build
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: releases
path: dist
Expand All @@ -36,7 +36,7 @@ jobs:
needs: [build_artifacts]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: releases
path: dist
Expand All @@ -51,11 +51,11 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: releases
path: dist
- uses: pypa/gh-action-pypi-publish@v1.8.10
- uses: pypa/gh-action-pypi-publish@v1.8.14
with:
user: __token__
password: ${{ secrets.pypi_password }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
dependency-set: ["minimal", "optional"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
Expand Down
21 changes: 15 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ default_stages: [commit, push]
default_language_version:
python: python3
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.4.3'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.4.7'
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
args: ["-L", "ba,ihs,kake,nd,noe,nwo,te,fo,zar", "-S", "fixture"]
Expand All @@ -27,7 +27,16 @@ repos:
- id: mypy
files: src
additional_dependencies:
- types-redis
- types-setuptools
- pytest
# Package dependencies
- asciitree
- crc32c
- donfig
- fasteners
- numcodecs
- numpy
- typing_extensions
- zstandard
# Tests
- pytest
# Zarr v2
- types-redis
12 changes: 8 additions & 4 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
version: 2

build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3.10"
commands:
- pip install hatch
- hatch run docs:rtd

sphinx:
configuration: docs/conf.py
fail_on_warning: true

formats: all

python:
install:
- method: pip
path: .
extra_requirements:
- docs
67 changes: 14 additions & 53 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ maintainers = [
{ name = "Ryan Abernathey" }
]
requires-python = ">=3.10"
# If you add a new dependency here, please also add it to .pre-commit-config.yml
dependencies = [
'asciitree',
'numpy>=1.24',
'fasteners',
'numcodecs>=0.10.0',
'fsspec>2024',
'crc32c',
'zstandard',
'typing_extensions',
'donfig'
'donfig',
'pytest'
]
dynamic = [
"version",
Expand Down Expand Up @@ -110,7 +113,12 @@ extra-dependencies = [
"pytest-cov",
"msgpack",
"lmdb",
"s3fs",
"pytest-asyncio",
"moto[s3]",
"flask-cors",
"flask",
"requests",
"mypy"
]
features = ["extra"]
Expand All @@ -136,8 +144,7 @@ list-env = "pip list"
features = ['docs']

[tool.hatch.envs.docs.scripts]
build = "sphinx-build docs/ docs/_build/"
rtd = "sphinx-build docs/ _readthedocs/html/"
build = "cd docs && make html"
serve = "sphinx-autobuild docs docs/_build --ignore 'docs/_autoapi/**/*' --host 0.0.0.0"

[tool.ruff]
Expand Down Expand Up @@ -177,7 +184,6 @@ extend-select = [
ignore = [
"RUF003",
"RUF005",
"RUF009",
"RUF012",
"RUF015",
]
Expand All @@ -187,61 +193,16 @@ python_version = "3.10"
ignore_missing_imports = true
namespace_packages = false

warn_unused_configs = true
warn_redundant_casts = true
warn_unused_ignores = true
strict_equality = true
strict_concatenate = true
strict = true
warn_unreachable = true

check_untyped_defs = true
disallow_untyped_decorators = true
disallow_any_generics = true

disallow_incomplete_defs = true
disallow_untyped_calls = true

disallow_untyped_defs = true

[[tool.mypy.overrides]]
module = [
"zarr.v2.*",
"zarr.group",
"tests.*",
]
check_untyped_defs = false

[[tool.mypy.overrides]]
module = [
"zarr.v2.*",
"zarr.array_v2",
]
disallow_any_generics = false

[[tool.mypy.overrides]]
module = [
"zarr.v2.*",
"zarr.array_v2",
"zarr.group"
]
disallow_incomplete_defs = false

[[tool.mypy.overrides]]
module = [
"zarr.v2.*",
"zarr.array_v2",
"zarr.array",
"zarr.buffer"
]
disallow_untyped_calls = false
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]

[[tool.mypy.overrides]]
module = [
"zarr.v2.*",
"zarr.array_v2",
"zarr.array",
"zarr.group",
]
disallow_untyped_defs = false
ignore_errors = true

[tool.pytest.ini_options]
minversion = "7"
Expand Down
88 changes: 61 additions & 27 deletions src/zarr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,68 @@
from __future__ import annotations

import zarr.codecs # noqa: F401
from zarr._version import version as __version__
from zarr.api.synchronous import (
array,
consolidate_metadata,
copy,
copy_all,
copy_store,
create,
empty,
empty_like,
full,
full_like,
group,
load,
ones,
ones_like,
open,
open_array,
open_consolidated,
open_group,
open_like,
save,
save_array,
save_group,
tree,
zeros,
zeros_like,
)
from zarr.array import Array, AsyncArray
from zarr.config import config # noqa: F401
from zarr.config import config
from zarr.group import AsyncGroup, Group
from zarr.store import (
StoreLike,
make_store_path,
)
from zarr.sync import sync as _sync

# in case setuptools scm screw up and find version to be 0.0.0
assert not __version__.startswith("0.0.0")


async def open_auto_async(store: StoreLike) -> AsyncArray | AsyncGroup:
store_path = make_store_path(store)
try:
return await AsyncArray.open(store_path)
except KeyError:
return await AsyncGroup.open(store_path)


def open_auto(store: StoreLike) -> Array | Group:
object = _sync(
open_auto_async(store),
)
if isinstance(object, AsyncArray):
return Array(object)
if isinstance(object, AsyncGroup):
return Group(object)
raise TypeError(f"Unexpected object type. Got {type(object)}.")
__all__ = [
"__version__",
"config",
"Array",
"AsyncArray",
"Group",
"AsyncGroup",
"tree",
"array",
"consolidate_metadata",
"copy",
"copy_all",
"copy_store",
"create",
"empty",
"empty_like",
"full",
"full_like",
"group",
"load",
"ones",
"ones_like",
"open",
"open_array",
"open_consolidated",
"open_group",
"open_like",
"save",
"save_array",
"save_group",
"zeros",
"zeros_like",
]
Loading

0 comments on commit 6755488

Please sign in to comment.